// is wrong when next another canvas is repainted.
const wxSize ClientSize = GetClientSize();
+ TestGLContext& canvas = wxGetApp().GetContext(this);
glViewport(0, 0, ClientSize.x, ClientSize.y);
// Render the graphics and swap the buffers.
- wxGetApp().GetContext(this).DrawRotatedCube(m_xangle, m_yangle);
+ canvas.DrawRotatedCube(m_xangle, m_yangle);
SwapBuffers();
}
g_doubleBuffer = GL_FALSE;
}
+ m_canvas = new TestGLCanvas(this, wxID_ANY, gl_attrib);
+
// Show the frame
Show(true);
+ Raise();
- m_canvas = new TestGLCanvas(this, wxID_ANY, gl_attrib);
+ m_canvas->InitGL();
}
MyFrame::~MyFrame()
// Explicitly create a new rendering context instance for this canvas.
m_glRC = new wxGLContext(this);
-
- // Make the new context current (activate it for use) with this canvas.
- SetCurrent(*m_glRC);
-
- InitGL();
- InitMaterials();
- LoadSurface("isosurf.dat.gz");
}
TestGLCanvas::~TestGLCanvas()
void TestGLCanvas::OnSize(wxSizeEvent& event)
{
+ if ( !IsShownOnScreen() )
+ return;
// This is normally only necessary if there is more than one wxGLCanvas
// or more than one wxGLContext in the application.
SetCurrent(*m_glRC);
void TestGLCanvas::InitGL()
{
+ // Make the new context current (activate it for use) with this canvas.
+ SetCurrent(*m_glRC);
+
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glShadeModel(GL_SMOOTH);
glEnable( GL_VERTEX_ARRAY );
glEnable( GL_NORMAL_ARRAY );
}
+
+ InitMaterials();
+ LoadSurface("isosurf.dat.gz");
}
// Explicitly create a new rendering context instance for this canvas.
m_glRC = new wxGLContext(this);
- // Make the new context current (activate it for use) with this canvas.
- SetCurrent(*m_glRC);
-
m_gldata.initialized = false;
// initialize view matrix
void TestGLCanvas::ResetProjectionMode()
{
+ if ( !IsShownOnScreen() )
+ return;
+
// This is normally only necessary if there is more than one wxGLCanvas
// or more than one wxGLContext in the application.
SetCurrent(*m_glRC);