Browse Source

Ignore windows scaling

Panagiotis Christopoulos Charitos 11 months ago
parent
commit
8c18b66cbc
2 changed files with 14 additions and 0 deletions
  1. 6 0
      AnKi/Util/Win32Minimal.h
  2. 8 0
      AnKi/Window/NativeWindowSdl.cpp

+ 6 - 0
AnKi/Util/Win32Minimal.h

@@ -130,6 +130,7 @@ ANKI_WINBASEAPI DWORD ANKI_WINAPI FormatMessageA(DWORD dwFlags, LPCVOID lpSource
 												 va_list* Arguments);
 ANKI_WINBASEAPI HLOCAL ANKI_WINAPI LocalFree(HLOCAL hMem);
 ANKI_WINBASEAPI BOOL ANKI_WINAPI IsDebuggerPresent();
+ANKI_WINBASEAPI BOOL ANKI_WINAPI SetProcessDPIAware();
 
 #undef ANKI_WINBASEAPI
 #undef ANKI_DECLARE_HANDLE
@@ -492,4 +493,9 @@ inline BOOL IsDebuggerPresent()
 	return ::IsDebuggerPresent();
 }
 
+inline BOOL SetProcessDPIAware()
+{
+	return ::SetProcessDPIAware();
+}
+
 } // end namespace anki

+ 8 - 0
AnKi/Window/NativeWindowSdl.cpp

@@ -60,6 +60,14 @@ NativeWindowSdl::~NativeWindowSdl()
 
 Error NativeWindowSdl::initSdl(const NativeWindowInitInfo& init)
 {
+#if ANKI_OS_WINDOWS
+	// Tell windows that the app will handle scaling. Otherwise SDL_GetDesktopDisplayMode will return a resolution that has the scaling applied
+	if(!SetProcessDPIAware())
+	{
+		ANKI_WIND_LOGE("SetProcessDPIAware() failed");
+	}
+#endif
+
 	if(SDL_Init(kInitSubsystems) != 0)
 	{
 		ANKI_WIND_LOGE("SDL_Init() failed: %s", SDL_GetError());