mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +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:
parent
46758efc8f
commit
0512c88ea8
@ -36,7 +36,7 @@ make_object(
|
||||
|
||||
make_defines(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/shader/desktop_rgb.frag"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/shader/desktop_rgh.def.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/shader/desktop_rgb.def.h"
|
||||
)
|
||||
|
||||
add_library(renderer_EGL STATIC
|
||||
@ -53,7 +53,7 @@ add_library(renderer_EGL STATIC
|
||||
splash.c
|
||||
alert.c
|
||||
${EGL_SHADER_OBJS}
|
||||
"${EGL_SHADER_INCS}/desktop_rgh.def.h"
|
||||
"${EGL_SHADER_INCS}/desktop_rgb.def.h"
|
||||
)
|
||||
|
||||
target_link_libraries(renderer_EGL
|
||||
|
@ -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;
|
||||
|
@ -1,7 +1,9 @@
|
||||
#version 300 es
|
||||
|
||||
#define LG_SCALE_NEAREST 0
|
||||
#define LG_SCALE_LINEAR 1
|
||||
#define EGL_SCALE_AUTO 0
|
||||
#define EGL_SCALE_NEAREST 1
|
||||
#define EGL_SCALE_LINEAR 2
|
||||
#define EGL_SCALE_MAX 3
|
||||
|
||||
in highp vec2 uv;
|
||||
out highp vec4 color;
|
||||
@ -41,11 +43,11 @@ void main()
|
||||
|
||||
switch (scaleAlgo)
|
||||
{
|
||||
case LG_SCALE_NEAREST:
|
||||
case EGL_SCALE_NEAREST:
|
||||
color = texelFetch(sampler1, ivec2(ruv * size), 0);
|
||||
break;
|
||||
|
||||
case LG_SCALE_LINEAR:
|
||||
case EGL_SCALE_LINEAR:
|
||||
color = texture(sampler1, ruv);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user