+ // Set the OpenGL viewport according to the client size of this canvas.
+ // This is done here rather than in a wxSizeEvent handler because our
+ // OpenGL rendering context (and thus viewport setting) is used with
+ // 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();
+
+ TestGLContext& canvas = wxGetApp().GetContext(this, m_useStereo);
+ glViewport(0, 0, ClientSize.x, ClientSize.y);
+
+ // Render the graphics and swap the buffers.
+ GLboolean quadStereoSupported;
+ glGetBooleanv( GL_STEREO, &quadStereoSupported);
+ if ( quadStereoSupported )
+ {
+ glDrawBuffer( GL_BACK_LEFT );
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-0.47f, 0.53f, -0.5f, 0.5f, 1.0f, 3.0f);
+ canvas.DrawRotatedCube(m_xangle, m_yangle);
+ CheckGLError();
+ glDrawBuffer( GL_BACK_RIGHT );
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-0.53f, 0.47f, -0.5f, 0.5f, 1.0f, 3.0f);
+ canvas.DrawRotatedCube(m_xangle, m_yangle);
+ CheckGLError();
+ }
+ else
+ {
+ canvas.DrawRotatedCube(m_xangle, m_yangle);
+ if ( m_useStereo && !m_stereoWarningAlreadyDisplayed )
+ {
+ m_stereoWarningAlreadyDisplayed = true;
+ wxLogError("Stereo not supported by the graphics card.");
+ }
+ }
+ SwapBuffers();