Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/src/porting.cpp b/src/porting.cpp
index 885b36e..286b4e1 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -602,7 +602,16 @@ float getDisplayDensity()
/* return manually specified dpi */
return g_settings->getFloat("screen_dpi")/96.0;
}
-
+#elif defined(_WIN32)
+float getDisplayDensity()
+{
+ SetProcessDPIAware();
+ HDC screen = GetDC(NULL);
+ float dpi_x = GetDeviceCaps(screen, LOGPIXELSX);
+ float dpi_y = GetDeviceCaps(screen, LOGPIXELSY);
+ ReleaseDC(NULL, screen);
+ return (dpi_x + dpi_y) * 0.5;
+}
#else
float getDisplayDensity()
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.