mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[client] egl: added new super+N binding to increase image gain
This feture is to allow the use of the key combination <super>+N to increase the brightness of the screen when using monitors with poor backlighting. Can help in some games. N = Night vision
This commit is contained in:
parent
fd4cfc2ff3
commit
c4001c727a
@ -28,6 +28,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "interface/app.h"
|
||||
|
||||
// these headers are auto generated by cmake
|
||||
#include "desktop.vert.h"
|
||||
#include "desktop_rgb.frag.h"
|
||||
@ -45,6 +47,7 @@ struct EGL_Desktop
|
||||
|
||||
// uniforms
|
||||
GLint uDesktopPos;
|
||||
GLint uNV, uNVGain;
|
||||
|
||||
// internals
|
||||
enum EGL_PixelFormat pixFmt;
|
||||
@ -52,8 +55,16 @@ struct EGL_Desktop
|
||||
unsigned int pitch;
|
||||
const uint8_t * data;
|
||||
bool update;
|
||||
|
||||
// night vision
|
||||
KeybindHandle kbNV;
|
||||
bool nv;
|
||||
int nvGain;
|
||||
};
|
||||
|
||||
// forwards
|
||||
void egl_desktop_toggle_nv(SDL_Scancode key, void * opaque);
|
||||
|
||||
bool egl_desktop_init(EGL_Desktop ** desktop)
|
||||
{
|
||||
*desktop = (EGL_Desktop *)malloc(sizeof(EGL_Desktop));
|
||||
@ -108,9 +119,19 @@ bool egl_desktop_init(EGL_Desktop ** desktop)
|
||||
egl_model_set_default((*desktop)->model);
|
||||
egl_model_set_texture((*desktop)->model, (*desktop)->texture);
|
||||
|
||||
(*desktop)->kbNV = app_register_keybind(SDL_SCANCODE_N, egl_desktop_toggle_nv, *desktop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void egl_desktop_toggle_nv(SDL_Scancode key, void * opaque)
|
||||
{
|
||||
EGL_Desktop * desktop = (EGL_Desktop *)opaque;
|
||||
if (++desktop->nvGain == 4)
|
||||
desktop->nvGain = 0;
|
||||
}
|
||||
|
||||
void egl_desktop_free(EGL_Desktop ** desktop)
|
||||
{
|
||||
if (!*desktop)
|
||||
@ -121,6 +142,8 @@ void egl_desktop_free(EGL_Desktop ** desktop)
|
||||
egl_shader_free (&(*desktop)->shader_yuv );
|
||||
egl_model_free (&(*desktop)->model );
|
||||
|
||||
app_release_keybind(&(*desktop)->kbNV);
|
||||
|
||||
free(*desktop);
|
||||
*desktop = NULL;
|
||||
}
|
||||
@ -172,7 +195,11 @@ bool egl_desktop_perform_update(EGL_Desktop * desktop, const bool sourceChanged)
|
||||
if (sourceChanged)
|
||||
{
|
||||
if (desktop->shader)
|
||||
{
|
||||
desktop->uDesktopPos = egl_shader_get_uniform_location(desktop->shader, "position");
|
||||
desktop->uNV = egl_shader_get_uniform_location(desktop->shader, "nv" );
|
||||
desktop->uNVGain = egl_shader_get_uniform_location(desktop->shader, "nvGain" );
|
||||
}
|
||||
|
||||
if (!egl_texture_setup(
|
||||
desktop->texture,
|
||||
@ -208,5 +235,13 @@ void egl_desktop_render(EGL_Desktop * desktop, const float x, const float y, con
|
||||
|
||||
egl_shader_use(desktop->shader);
|
||||
glUniform4f(desktop->uDesktopPos, x, y, scaleX, scaleY);
|
||||
if (desktop->nvGain)
|
||||
{
|
||||
glUniform1i(desktop->uNV, 1);
|
||||
glUniform1f(desktop->uNVGain, (float)(desktop->nvGain+1));
|
||||
}
|
||||
else
|
||||
glUniform1i(desktop->uNV, 0);
|
||||
|
||||
egl_model_render(desktop->model);
|
||||
}
|
@ -4,8 +4,12 @@ in highp vec2 uv;
|
||||
out highp vec4 color;
|
||||
|
||||
uniform sampler2D sampler1;
|
||||
uniform int nv;
|
||||
uniform highp float nvGain;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = texture(sampler1, uv);
|
||||
if (nv == 1)
|
||||
color *= nvGain;
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
in highp vec2 uv;
|
||||
out highp vec4 color;
|
||||
|
||||
uniform int nv;
|
||||
uniform highp float nvGain;
|
||||
|
||||
uniform sampler2D sampler1;
|
||||
uniform sampler2D sampler2;
|
||||
uniform sampler2D sampler3;
|
||||
@ -24,4 +27,6 @@ void main()
|
||||
);
|
||||
|
||||
color = yuv * yuv_to_rgb;
|
||||
if (nv == 1)
|
||||
color *= nvGain;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user