diff --git a/samples/opengl/cube/cube.cpp b/samples/opengl/cube/cube.cpp index f469826b67..254812e0d8 100644 --- a/samples/opengl/cube/cube.cpp +++ b/samples/opengl/cube/cube.cpp @@ -349,7 +349,7 @@ void TestGLCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) // multiple canvases: If we updated the viewport in the wxSizeEvent // handler, changing the size of one canvas causes a viewport setting that // is wrong when next another canvas is repainted. - const wxSize ClientSize = GetClientSize(); + const wxSize ClientSize = GetClientSize() * GetContentScaleFactor(); TestGLContext& canvas = wxGetApp().GetContext(this, m_useStereo); glViewport(0, 0, ClientSize.x, ClientSize.y); diff --git a/samples/opengl/isosurf/isosurf.cpp b/samples/opengl/isosurf/isosurf.cpp index 6e1dae45a8..9dd47a162f 100644 --- a/samples/opengl/isosurf/isosurf.cpp +++ b/samples/opengl/isosurf/isosurf.cpp @@ -280,7 +280,8 @@ void TestGLCanvas::OnSize(wxSizeEvent& event) // This is OK here only because there is only one canvas that uses the // context. See the cube sample for that case that multiple canvases are // made current with one context. - glViewport(0, 0, event.GetSize().x, event.GetSize().y); + const wxSize size = event.GetSize() * GetContentScaleFactor(); + glViewport(0, 0, size.x, size.y); } void TestGLCanvas::OnChar(wxKeyEvent& event) diff --git a/samples/opengl/penguin/penguin.cpp b/samples/opengl/penguin/penguin.cpp index 9365d6c900..b5992a6b46 100644 --- a/samples/opengl/penguin/penguin.cpp +++ b/samples/opengl/penguin/penguin.cpp @@ -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(); } diff --git a/samples/opengl/pyramid/pyramid.cpp b/samples/opengl/pyramid/pyramid.cpp index 20ef5a33da..5123a917ab 100644 --- a/samples/opengl/pyramid/pyramid.cpp +++ b/samples/opengl/pyramid/pyramid.cpp @@ -565,8 +565,9 @@ void MyGLCanvas::OnSize(wxSizeEvent& event) SetCurrent(*m_oglContext); // It's up to the application code to update the OpenGL viewport settings. - m_winHeight = event.GetSize().y; - m_oglManager->SetViewport(0, 0, event.GetSize().x, m_winHeight); + const wxSize size = event.GetSize() * GetContentScaleFactor(); + m_winHeight = size.y; + m_oglManager->SetViewport(0, 0, size.x, m_winHeight); // Generate paint event without erasing the background. Refresh(false);