From 48be58378cb224e20a12d721fecc16c9970c3cb2 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sun, 21 Feb 2021 01:34:32 -0500 Subject: [PATCH] [client] opengl: scale UI elements on high DPI displays This is done by simply scaling up the rendered text bitmap. --- client/renderers/OpenGL/opengl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/renderers/OpenGL/opengl.c b/client/renderers/OpenGL/opengl.c index 8a531b1e..583c73cc 100644 --- a/client/renderers/OpenGL/opengl.c +++ b/client/renderers/OpenGL/opengl.c @@ -111,6 +111,7 @@ struct Inst LG_DSGLContext glContext; SDL_Point window; + float uiScale; bool frameUpdate; const LG_Font * font; @@ -305,6 +306,7 @@ void opengl_on_resize(void * opaque, const int width, const int height, const do this->window.x = width * scale; this->window.y = height * scale; + this->uiScale = (float) scale; if (destRect.valid) { @@ -661,6 +663,7 @@ bool opengl_render(void * opaque, LG_RendererRotate rotate) glPushMatrix(); glLoadIdentity(); glTranslatef(this->window.x / 2, this->window.y / 2, 0.0f); + glScalef(this->uiScale, this->uiScale, 1.0f); glCallList(this->alertList); glPopMatrix(); break; @@ -703,9 +706,6 @@ void opengl_update_fps(void * opaque, const float avgUPS, const float avgFPS) this->fpsTexture = true; glNewList(this->fpsList, GL_COMPILE); - glPushMatrix(); - glLoadIdentity(); - glEnable(GL_BLEND); glDisable(GL_TEXTURE_2D); glColor4f(0.0f, 0.0f, 1.0f, 0.5f); @@ -727,8 +727,6 @@ void opengl_update_fps(void * opaque, const float avgUPS, const float avgFPS) glEnd(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_BLEND); - - glPopMatrix(); glEndList(); }