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:
@@ -376,6 +376,11 @@ bool wxGLCanvasBase::ParseAttribList(const int *attribList,
|
||||
return true;
|
||||
}
|
||||
|
||||
double wxGLCanvasBase::GetOpenGLScaleFactor() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// compatibility layer for OpenGL 3 and OpenGL ES
|
||||
// ============================================================================
|
||||
|
||||
@@ -271,4 +271,13 @@ void wxGLCanvas::GTKInitImplicitContext()
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_8
|
||||
|
||||
double wxGLCanvas::GetOpenGLScaleFactor() const
|
||||
{
|
||||
#ifdef __WXGTK3__
|
||||
return GetContentScaleFactor();
|
||||
#else
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxUSE_GLCANVAS
|
||||
|
||||
@@ -562,6 +562,11 @@ bool wxGLCanvas::IsAGLMultiSampleAvailable()
|
||||
return s_isMultiSampleAvailable != 0;
|
||||
}
|
||||
|
||||
double wxGLCanvas::GetOpenGLScaleFactor() const
|
||||
{
|
||||
return GetContentScaleFactor();
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool wxGLCanvasBase::IsDisplaySupported(const wxGLAttributes& dispAttrs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user