X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7f1b6179cd5d14910f5e838109f123cc027b40dd..97f851007c07fa09d5ee9b3e26a46fe29f2575b8:/samples/opengl/isosurf/isosurf.cpp diff --git a/samples/opengl/isosurf/isosurf.cpp b/samples/opengl/isosurf/isosurf.cpp index 707b48c424..66cc2a31c4 100644 --- a/samples/opengl/isosurf/isosurf.cpp +++ b/samples/opengl/isosurf/isosurf.cpp @@ -136,10 +136,13 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, 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() @@ -177,13 +180,6 @@ TestGLCanvas::TestGLCanvas(wxWindow *parent, // 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() @@ -279,6 +275,8 @@ void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) ) 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); @@ -406,6 +404,9 @@ void TestGLCanvas::InitMaterials() 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); @@ -428,5 +429,8 @@ void TestGLCanvas::InitGL() glEnable( GL_VERTEX_ARRAY ); glEnable( GL_NORMAL_ARRAY ); } + + InitMaterials(); + LoadSurface("isosurf.dat.gz"); }