X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/378a3872eb0bfaaff6f32144ddef0dd144b056b2..9617f65bccba124625546fd798e03e59d97b35c9:/samples/opengl/cube/cube.cpp diff --git a/samples/opengl/cube/cube.cpp b/samples/opengl/cube/cube.cpp index 6a5bc37778..3255201819 100644 --- a/samples/opengl/cube/cube.cpp +++ b/samples/opengl/cube/cube.cpp @@ -146,6 +146,8 @@ TestGLContext& MyApp::GetContext(wxGLCanvas *canvas) { if ( !m_glContext ) m_glContext = new TestGLContext(canvas); + else + m_glContext->SetCurrent(*canvas); return *m_glContext; } @@ -165,6 +167,10 @@ TestGLContext::TestGLContext(wxGLCanvas *canvas) glEnable(GL_LIGHT0); glEnable(GL_TEXTURE_2D); + // add slightly more light, the default lightning is rather dark + GLfloat ambient[] = { 0.5, 0.5, 0.5, 0.5 }; + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); + // set viewing projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -298,7 +304,7 @@ void TestGLCanvas::OnSize(wxSizeEvent& event) // don't prevent default processing from taking place event.Skip(); - if ( !IsShown() ) + if ( !IsShownOnScreen() ) return; // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) @@ -379,6 +385,11 @@ MyFrame::MyFrame() SetClientSize(400, 400); Show(); + + // test IsDisplaySupported() function: + static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; + wxLogStatus("Double-buffered display %s supported", + wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not"); } void MyFrame::OnClose(wxCommandEvent& WXUNUSED(event))