Fix OpenGL samples when using HiDPI displays
OpenGL seems to operate using physical pixels, so we need to factor in the scale factor when setting the GL viewport. Closes #17391. Closes https://github.com/wxWidgets/wxWidgets/pull/1470
This commit is contained in:
committed by
Vadim Zeitlin
parent
0ff713c945
commit
b134589cbb
@@ -306,17 +306,16 @@ void TestGLCanvas::ResetProjectionMode()
|
||||
// or more than one wxGLContext in the application.
|
||||
SetCurrent(*m_glRC);
|
||||
|
||||
int w, h;
|
||||
GetClientSize(&w, &h);
|
||||
const wxSize ClientSize = GetClientSize() * GetContentScaleFactor();
|
||||
|
||||
// It's up to the application code to update the OpenGL viewport settings.
|
||||
// In order to avoid extensive context switching, consider doing this in
|
||||
// OnPaint() rather than here, though.
|
||||
glViewport(0, 0, (GLint) w, (GLint) h);
|
||||
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(45.0f, (GLfloat)w/h, 1.0, 100.0);
|
||||
gluPerspective(45.0f, (GLfloat)ClientSize.x/ClientSize.y, 1.0, 100.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
Reference in New Issue
Block a user