Add GetOpenGLScaleFactor() to abstract OpenGL coordinates scaling

The fix for OpenGL coordinates when using high DPI in b134589cbb (Fix
OpenGL samples when using HiDPI displays, 2019-08-06) did fix it for GTK
3 and macOS, but broke it for MSW and other platforms not using pixel
scaling, as window coordinates are the same as OpenGL ones there, while
GetContentScaleFactor() can still return values > 1 even on these
platforms.

Provide new GetOpenGLScaleFactor() function abstracting this platform
difference and use it in all OpenGL samples to make them work correctly
in high DPI under all platforms.

Closes https://github.com/wxWidgets/wxWidgets/pull/1944

Closes #17391.
This commit is contained in:
tm
2020-07-10 18:37:47 +02:00
committed by Vadim Zeitlin
parent 01d7fa8116
commit f6cc8ff52c
12 changed files with 50 additions and 7 deletions

View File

@@ -306,7 +306,7 @@ void TestGLCanvas::ResetProjectionMode()
// or more than one wxGLContext in the application.
SetCurrent(*m_glRC);
const wxSize ClientSize = GetClientSize() * GetContentScaleFactor();
const wxSize ClientSize = GetClientSize() * GetOpenGLScaleFactor();
// It's up to the application code to update the OpenGL viewport settings.
// In order to avoid extensive context switching, consider doing this in