mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "interface/app.h"
|
||||||
|
|
||||||
// these headers are auto generated by cmake
|
// these headers are auto generated by cmake
|
||||||
#include "desktop.vert.h"
|
#include "desktop.vert.h"
|
||||||
#include "desktop_rgb.frag.h"
|
#include "desktop_rgb.frag.h"
|
||||||
@ -45,6 +47,7 @@ struct EGL_Desktop
|
|||||||
|
|
||||||
// uniforms
|
// uniforms
|
||||||
GLint uDesktopPos;
|
GLint uDesktopPos;
|
||||||
|
GLint uNV, uNVGain;
|
||||||
|
|
||||||
// internals
|
// internals
|
||||||
enum EGL_PixelFormat pixFmt;
|
enum EGL_PixelFormat pixFmt;
|
||||||
@ -52,8 +55,16 @@ struct EGL_Desktop
|
|||||||
unsigned int pitch;
|
unsigned int pitch;
|
||||||
const uint8_t * data;
|
const uint8_t * data;
|
||||||
bool update;
|
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)
|
bool egl_desktop_init(EGL_Desktop ** desktop)
|
||||||
{
|
{
|
||||||
*desktop = (EGL_Desktop *)malloc(sizeof(EGL_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_default((*desktop)->model);
|
||||||
egl_model_set_texture((*desktop)->model, (*desktop)->texture);
|
egl_model_set_texture((*desktop)->model, (*desktop)->texture);
|
||||||
|
|
||||||
|
(*desktop)->kbNV = app_register_keybind(SDL_SCANCODE_N, egl_desktop_toggle_nv, *desktop);
|
||||||
|
|
||||||
return true;
|
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)
|
void egl_desktop_free(EGL_Desktop ** desktop)
|
||||||
{
|
{
|
||||||
if (!*desktop)
|
if (!*desktop)
|
||||||
@ -121,6 +142,8 @@ void egl_desktop_free(EGL_Desktop ** desktop)
|
|||||||
egl_shader_free (&(*desktop)->shader_yuv );
|
egl_shader_free (&(*desktop)->shader_yuv );
|
||||||
egl_model_free (&(*desktop)->model );
|
egl_model_free (&(*desktop)->model );
|
||||||
|
|
||||||
|
app_release_keybind(&(*desktop)->kbNV);
|
||||||
|
|
||||||
free(*desktop);
|
free(*desktop);
|
||||||
*desktop = NULL;
|
*desktop = NULL;
|
||||||
}
|
}
|
||||||
@ -172,7 +195,11 @@ bool egl_desktop_perform_update(EGL_Desktop * desktop, const bool sourceChanged)
|
|||||||
if (sourceChanged)
|
if (sourceChanged)
|
||||||
{
|
{
|
||||||
if (desktop->shader)
|
if (desktop->shader)
|
||||||
|
{
|
||||||
desktop->uDesktopPos = egl_shader_get_uniform_location(desktop->shader, "position");
|
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(
|
if (!egl_texture_setup(
|
||||||
desktop->texture,
|
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);
|
egl_shader_use(desktop->shader);
|
||||||
glUniform4f(desktop->uDesktopPos, x, y, scaleX, scaleY);
|
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);
|
egl_model_render(desktop->model);
|
||||||
}
|
}
|
@ -4,8 +4,12 @@ in highp vec2 uv;
|
|||||||
out highp vec4 color;
|
out highp vec4 color;
|
||||||
|
|
||||||
uniform sampler2D sampler1;
|
uniform sampler2D sampler1;
|
||||||
|
uniform int nv;
|
||||||
|
uniform highp float nvGain;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
color = texture(sampler1, uv);
|
color = texture(sampler1, uv);
|
||||||
|
if (nv == 1)
|
||||||
|
color *= nvGain;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
in highp vec2 uv;
|
in highp vec2 uv;
|
||||||
out highp vec4 color;
|
out highp vec4 color;
|
||||||
|
|
||||||
|
uniform int nv;
|
||||||
|
uniform highp float nvGain;
|
||||||
|
|
||||||
uniform sampler2D sampler1;
|
uniform sampler2D sampler1;
|
||||||
uniform sampler2D sampler2;
|
uniform sampler2D sampler2;
|
||||||
uniform sampler2D sampler3;
|
uniform sampler2D sampler3;
|
||||||
@ -24,4 +27,6 @@ void main()
|
|||||||
);
|
);
|
||||||
|
|
||||||
color = yuv * yuv_to_rgb;
|
color = yuv * yuv_to_rgb;
|
||||||
|
if (nv == 1)
|
||||||
|
color *= nvGain;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user