mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-09 20:24:14 +00:00
[client] egl: make scale algorithms toggleable
The $escape+S keybinding now cycles through the available scale algorithms. This allows the user to switch between algorithms if the automatic detection turns out to be problematic. The algorithms are renumbered so that 0 can be LG_SCALE_AUTO.
This commit is contained in:
@@ -33,7 +33,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
// these headers are auto generated by cmake
|
||||
#include "desktop.vert.h"
|
||||
#include "desktop_rgb.frag.h"
|
||||
#include "desktop_rgh.def.h"
|
||||
#include "desktop_rgb.def.h"
|
||||
|
||||
struct DesktopShader
|
||||
{
|
||||
@@ -61,6 +61,9 @@ struct EGL_Desktop
|
||||
// shader instances
|
||||
struct DesktopShader shader_generic;
|
||||
|
||||
// scale algorithm
|
||||
int scaleAlgo;
|
||||
|
||||
// night vision
|
||||
int nvMax;
|
||||
int nvGain;
|
||||
@@ -71,6 +74,7 @@ struct EGL_Desktop
|
||||
|
||||
// forwards
|
||||
void egl_desktop_toggle_nv(int key, void * opaque);
|
||||
void egl_desktop_toggle_scale_algo(int key, void * opaque);
|
||||
|
||||
static bool egl_init_desktop_shader(
|
||||
struct DesktopShader * shader,
|
||||
@@ -136,6 +140,7 @@ bool egl_desktop_init(EGL_Desktop ** desktop, EGLDisplay * display)
|
||||
egl_model_set_texture((*desktop)->model, (*desktop)->texture);
|
||||
|
||||
app_registerKeybind(KEY_N, egl_desktop_toggle_nv, *desktop, "Toggle night vision mode");
|
||||
app_registerKeybind(KEY_S, egl_desktop_toggle_scale_algo, *desktop, "Toggle scale algorithm");
|
||||
|
||||
(*desktop)->nvMax = option_get_int("egl", "nvGainMax");
|
||||
(*desktop)->nvGain = option_get_int("egl", "nvGain" );
|
||||
@@ -155,6 +160,30 @@ void egl_desktop_toggle_nv(int key, void * opaque)
|
||||
else app_alert(LG_ALERT_INFO, "NV Gain + %d", desktop->nvGain - 1);
|
||||
}
|
||||
|
||||
static const char * egl_desktop_scale_algo_name(int algorithm)
|
||||
{
|
||||
switch (algorithm)
|
||||
{
|
||||
case EGL_SCALE_AUTO:
|
||||
return "Automatic (downscale: linear, upscale: nearest)";
|
||||
case EGL_SCALE_NEAREST:
|
||||
return "Nearest";
|
||||
case EGL_SCALE_LINEAR:
|
||||
return "Linear";
|
||||
default:
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
void egl_desktop_toggle_scale_algo(int key, void * opaque)
|
||||
{
|
||||
EGL_Desktop * desktop = (EGL_Desktop *)opaque;
|
||||
if (++desktop->scaleAlgo == EGL_SCALE_MAX)
|
||||
desktop->scaleAlgo = 0;
|
||||
|
||||
app_alert(LG_ALERT_INFO, "Scale Algorithm: %s", egl_desktop_scale_algo_name(desktop->scaleAlgo));
|
||||
}
|
||||
|
||||
void egl_desktop_free(EGL_Desktop ** desktop)
|
||||
{
|
||||
if (!*desktop)
|
||||
@@ -248,18 +277,26 @@ bool egl_desktop_render(EGL_Desktop * desktop, const float x, const float y,
|
||||
if (!desktop->shader)
|
||||
return false;
|
||||
|
||||
int scaleAlgo = LG_SCALE_NEAREST;
|
||||
int scaleAlgo = EGL_SCALE_NEAREST;
|
||||
|
||||
switch (scaleType)
|
||||
switch (desktop->scaleAlgo)
|
||||
{
|
||||
case EGL_DESKTOP_NOSCALE:
|
||||
case EGL_DESKTOP_UPSCALE:
|
||||
scaleAlgo = LG_SCALE_NEAREST;
|
||||
case EGL_SCALE_AUTO:
|
||||
switch (scaleType)
|
||||
{
|
||||
case EGL_DESKTOP_NOSCALE:
|
||||
case EGL_DESKTOP_UPSCALE:
|
||||
scaleAlgo = EGL_SCALE_NEAREST;
|
||||
break;
|
||||
|
||||
case EGL_DESKTOP_DOWNSCALE:
|
||||
scaleAlgo = EGL_SCALE_LINEAR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case EGL_DESKTOP_DOWNSCALE:
|
||||
scaleAlgo = LG_SCALE_LINEAR;
|
||||
break;
|
||||
default:
|
||||
scaleAlgo = desktop->scaleAlgo;
|
||||
}
|
||||
|
||||
const struct DesktopShader * shader = desktop->shader;
|
||||
|
Reference in New Issue
Block a user