Add an option for highdpi

This commit is contained in:
Learath 2020-04-07 23:37:46 +03:00
parent 65673ab402
commit 388d792205
5 changed files with 21 additions and 7 deletions

View file

@ -2321,7 +2321,9 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
} }
// set flags // set flags
int SdlFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_ALLOW_HIGHDPI; int SdlFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN;
if(Flags&IGraphicsBackend::INITFLAG_HIGHDPI)
SdlFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
#if defined(SDL_VIDEO_DRIVER_X11) #if defined(SDL_VIDEO_DRIVER_X11)
if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE) if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE)
SdlFlags |= SDL_WINDOW_RESIZABLE; SdlFlags |= SDL_WINDOW_RESIZABLE;

View file

@ -2049,6 +2049,7 @@ int CGraphics_Threaded::IssueInit()
if(g_Config.m_GfxBorderless) Flags |= IGraphicsBackend::INITFLAG_BORDERLESS; if(g_Config.m_GfxBorderless) Flags |= IGraphicsBackend::INITFLAG_BORDERLESS;
if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN; if(g_Config.m_GfxFullscreen) Flags |= IGraphicsBackend::INITFLAG_FULLSCREEN;
if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC; if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC;
if(g_Config.m_GfxHighdpi) Flags |= IGraphicsBackend::INITFLAG_HIGHDPI;
#ifndef CONF_VIDEORECORDER #ifndef CONF_VIDEORECORDER
if(g_Config.m_GfxResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE; if(g_Config.m_GfxResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE;
#endif #endif

View file

@ -561,10 +561,11 @@ class IGraphicsBackend
public: public:
enum enum
{ {
INITFLAG_FULLSCREEN = 1, INITFLAG_FULLSCREEN = 1<<0,
INITFLAG_VSYNC = 2, INITFLAG_VSYNC = 1<<1,
INITFLAG_RESIZABLE = 4, INITFLAG_RESIZABLE = 1<<2,
INITFLAG_BORDERLESS = 8, INITFLAG_BORDERLESS = 1<<3,
INITFLAG_HIGHDPI = 1 <<4,
}; };
virtual ~IGraphicsBackend() {} virtual ~IGraphicsBackend() {}

View file

@ -91,6 +91,7 @@ MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG
MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution height") MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution height")
MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)") MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Fullscreen") MACRO_CONFIG_INT(GfxFullscreen, gfx_fullscreen, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Fullscreen")
MACRO_CONFIG_INT(GfxHighdpi, gfx_highdpi, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable high-dpi")
MACRO_CONFIG_INT(GfxAlphabits, gfx_alphabits, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Alpha bits for framebuffer (fullscreen only)") MACRO_CONFIG_INT(GfxAlphabits, gfx_alphabits, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Alpha bits for framebuffer (fullscreen only)")
MACRO_CONFIG_INT(GfxColorDepth, gfx_color_depth, 24, 16, 24, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Colors bits for framebuffer (fullscreen only)") MACRO_CONFIG_INT(GfxColorDepth, gfx_color_depth, 24, 16, 24, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Colors bits for framebuffer (fullscreen only)")
//MACRO_CONFIG_INT(GfxClear, gfx_clear, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Clear screen before rendering") //MACRO_CONFIG_INT(GfxClear, gfx_clear, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Clear screen before rendering")
@ -373,4 +374,3 @@ MACRO_CONFIG_INT(GfxUsePreinitBuffer, gfx_use_preinitialized_buffer, 0, 0, 1, CF
#if defined(CONF_VIDEORECORDER) #if defined(CONF_VIDEORECORDER)
MACRO_CONFIG_INT(ClVideoRecorderFPS, cl_video_recorder_fps, 60, 1, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "At which FPS the videorecorder should record demos.") MACRO_CONFIG_INT(ClVideoRecorderFPS, cl_video_recorder_fps, 60, 1, 1000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "At which FPS the videorecorder should record demos.")
#endif #endif

View file

@ -932,6 +932,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
static int s_GfxOpenGLVersion = g_Config.m_GfxOpenGL3; static int s_GfxOpenGLVersion = g_Config.m_GfxOpenGL3;
static int s_GfxEnableTextureUnitOptimization = g_Config.m_GfxEnableTextureUnitOptimization; static int s_GfxEnableTextureUnitOptimization = g_Config.m_GfxEnableTextureUnitOptimization;
static int s_GfxUsePreinitBuffer = g_Config.m_GfxUsePreinitBuffer; static int s_GfxUsePreinitBuffer = g_Config.m_GfxUsePreinitBuffer;
static int s_GfxHighdpi = g_Config.m_GfxHighdpi;
CUIRect ModeList; CUIRect ModeList;
MainView.VSplitLeft(300.0f, &MainView, &ModeList); MainView.VSplitLeft(300.0f, &MainView, &ModeList);
@ -1077,6 +1078,14 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
} }
} }
MainView.HSplitTop(20.0f, &Button, &MainView);
if(DoButton_CheckBox(&g_Config.m_GfxHighdpi, Localize("Use high DPI"), g_Config.m_GfxHighdpi, &Button))
{
CheckSettings = true;
g_Config.m_GfxHighdpi ^= 1;
}
// check if the new settings require a restart // check if the new settings require a restart
if(CheckSettings) if(CheckSettings)
{ {
@ -1089,7 +1098,8 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
s_GfxTextureCompression == g_Config.m_GfxTextureCompression && s_GfxTextureCompression == g_Config.m_GfxTextureCompression &&
s_GfxOpenGLVersion == g_Config.m_GfxOpenGL3 && s_GfxOpenGLVersion == g_Config.m_GfxOpenGL3 &&
s_GfxUsePreinitBuffer == g_Config.m_GfxUsePreinitBuffer && s_GfxUsePreinitBuffer == g_Config.m_GfxUsePreinitBuffer &&
s_GfxEnableTextureUnitOptimization == g_Config.m_GfxEnableTextureUnitOptimization) s_GfxEnableTextureUnitOptimization == g_Config.m_GfxEnableTextureUnitOptimization &&
s_GfxHighdpi == g_Config.m_GfxHighdpi)
m_NeedRestartGraphics = false; m_NeedRestartGraphics = false;
else else
m_NeedRestartGraphics = true; m_NeedRestartGraphics = true;