[client] all: add screen rotation support win:rotate

Currently only supports EGL, if there is enough demand for OpenGL
support this can be added later.

Closes #231
This commit is contained in:
Geoffrey McRae
2021-01-15 12:40:59 +11:00
parent c40a81ddf4
commit 72c86d7125
11 changed files with 252 additions and 73 deletions

View File

@@ -1,6 +1,6 @@
/*
Looking Glass - KVM FrameRelay (KVMFR) Client
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
Copyright (C) 2017-2021 Geoffrey McRae <geoff@hostfission.com>
https://looking-glass.hostfission.com
This program is free software; you can redistribute it and/or modify it under
@@ -34,13 +34,13 @@ 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_yuv.frag.h"
struct DesktopShader
{
EGL_Shader * shader;
GLint uDesktopPos;
GLint uDesktopSize;
GLint uRotate;
GLint uNearest;
GLint uNV, uNVGain;
GLint uCBMode;
@@ -55,11 +55,11 @@ struct EGL_Desktop
EGL_Model * model;
// internals
int width, height;
int width, height;
LG_RendererRotate rotate;
// shader instances
struct DesktopShader shader_generic;
struct DesktopShader shader_yuv;
// night vision
KeybindHandle kbNV;
@@ -91,6 +91,7 @@ static bool egl_init_desktop_shader(
shader->uDesktopPos = egl_shader_get_uniform_location(shader->shader, "position");
shader->uDesktopSize = egl_shader_get_uniform_location(shader->shader, "size" );
shader->uRotate = egl_shader_get_uniform_location(shader->shader, "rotate" );
shader->uNearest = egl_shader_get_uniform_location(shader->shader, "nearest" );
shader->uNV = egl_shader_get_uniform_location(shader->shader, "nv" );
shader->uNVGain = egl_shader_get_uniform_location(shader->shader, "nvGain" );
@@ -203,6 +204,7 @@ bool egl_desktop_setup(EGL_Desktop * desktop, const LG_RendererFormat format, bo
desktop->width = format.width;
desktop->height = format.height;
desktop->rotate = format.rotate;
if (!egl_texture_setup(
desktop->texture,
@@ -252,6 +254,7 @@ bool egl_desktop_render(EGL_Desktop * desktop, const float x, const float y, con
const struct DesktopShader * shader = desktop->shader;
egl_shader_use(shader->shader);
glUniform4f(shader->uDesktopPos , x, y, scaleX, scaleY);
glUniform1i(shader->uRotate , desktop->rotate);
glUniform1i(shader->uNearest , nearest ? 1 : 0);
glUniform2f(shader->uDesktopSize, desktop->width, desktop->height);