From 9bd30ce4472fbb0abf7cdd48603da6fd1c8017ea Mon Sep 17 00:00:00 2001 From: def Date: Sat, 7 May 2016 17:47:05 +0200 Subject: [PATCH] Make high-dpi screen support optional --- src/engine/client/backend_sdl.cpp | 7 ++++++- src/engine/client/graphics_threaded.cpp | 1 + src/engine/client/graphics_threaded.h | 1 + src/engine/shared/config_variables.h | 1 + src/game/client/components/menus_settings.cpp | 11 ++++++++++- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 93d119648..cb58ba713 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -602,7 +602,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt } // set flags - int SdlFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI; + int SdlFlags = SDL_WINDOW_OPENGL; #if defined(SDL_VIDEO_DRIVER_X11) if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE) SdlFlags |= SDL_WINDOW_RESIZABLE; @@ -620,6 +620,11 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt #endif } + if(Flags&IGraphicsBackend::INITFLAG_HIGHDPI) + SdlFlags |= SDL_WINDOW_ALLOW_HIGHDPI; + else + SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1"); + // set gl attributes SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if(FsaaSamples) diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 200babe32..1e5f7e372 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -787,6 +787,7 @@ int CGraphics_Threaded::IssueInit() if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN; if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC; if(g_Config.m_GfxResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE; + if(g_Config.m_GfxHighdpi) Flags |= IGraphicsBackend::INITFLAG_HIGHDPI; return m_pBackend->Init("DDNet Client", &g_Config.m_GfxScreen, &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags, &m_DesktopScreenWidth, &m_DesktopScreenHeight); } diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index bc14fba3a..adcecc887 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -318,6 +318,7 @@ public: INITFLAG_VSYNC = 2, INITFLAG_RESIZABLE = 4, INITFLAG_BORDERLESS = 8, + INITFLAG_HIGHDPI = 16, }; virtual ~IGraphicsBackend() {} diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 4fe21acc1..9f0d8211c 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -127,6 +127,7 @@ MACRO_CONFIG_INT(GfxQuadAsTriangle, gfx_quad_as_triangle, 0, 0, 0, CFGFLAG_SAVE| #else MACRO_CONFIG_INT(GfxQuadAsTriangle, gfx_quad_as_triangle, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Render quads as triangles (fixes quad coloring on some GPUs)") #endif +MACRO_CONFIG_INT(GfxHighdpi, gfx_highdpi, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Try to use high-dpi screen features") MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity") MACRO_CONFIG_INT(InpMouseOld, inp_mouseold, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use old mouse mode (warp mouse instead of raw input)") diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 7bb232eef..b42655a77 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -818,6 +818,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples; static int s_GfxTextureQuality = g_Config.m_GfxTextureQuality; static int s_GfxTextureCompression = g_Config.m_GfxTextureCompression; + static int s_GfxHighdpi = g_Config.m_GfxHighdpi; CUIRect ModeList; MainView.VSplitLeft(300.0f, &MainView, &ModeList); @@ -937,6 +938,13 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_GfxHighDetail, Localize("High Detail"), g_Config.m_GfxHighDetail, &Button)) g_Config.m_GfxHighDetail ^= 1; + MainView.HSplitTop(20.0f, &Button, &MainView); + if(DoButton_CheckBox(&g_Config.m_GfxHighdpi, Localize("High-DPI screen support"), g_Config.m_GfxHighdpi, &Button)) + { + g_Config.m_GfxHighdpi ^= 1; + CheckSettings = true; + } + // check if the new settings require a restart if(CheckSettings) { @@ -946,7 +954,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) s_GfxVsync == g_Config.m_GfxVsync && s_GfxFsaaSamples == g_Config.m_GfxFsaaSamples && s_GfxTextureQuality == g_Config.m_GfxTextureQuality && - s_GfxTextureCompression == g_Config.m_GfxTextureCompression) + s_GfxTextureCompression == g_Config.m_GfxTextureCompression && + s_GfxHighdpi == g_Config.m_GfxHighdpi) m_NeedRestartGraphics = false; else m_NeedRestartGraphics = true;