Ver código fonte

Attempt to fix DPI scaling on Windows

Ivan Savenko 2 anos atrás
pai
commit
f403766fbb
2 arquivos alterados com 8 adições e 9 exclusões
  1. 0 9
      client/DPIaware.manifest
  2. 8 0
      client/renderSDL/WindowHandler.cpp

+ 0 - 9
client/DPIaware.manifest

@@ -1,9 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
-  <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
-    <asmv3:windowsSettings
-         xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
-      <dpiAware>true</dpiAware>
-    </asmv3:windowsSettings>
-  </asmv3:application>
-</assembly> 

+ 8 - 0
client/renderSDL/WindowHandler.cpp

@@ -114,6 +114,14 @@ EWindowMode WindowHandler::getPreferredWindowMode() const
 
 WindowHandler::WindowHandler()
 {
+#ifdef VCMI_WINDOWS
+	// set VCMI as "per-monitor DPI awareness". This completely disables any DPI-scaling by system.
+	// Might not be the best solution since VCMI can't automatically adjust to DPI changes (including moving to monitors with different DPI scaling)
+	// However this fixed unintuitive bug where player selects specific resolution for windowed mode, but ends up with completely different one due to scaling
+	// NOTE: requires SDL 2.24.
+	SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitor");
+#endif
+
 	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE))
 	{
 		logGlobal->error("Something was wrong: %s", SDL_GetError());