]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/opengl/isosurf/isosurf.cpp
Fix recreating of wxBitmapComboBox using untyped client data.
[wxWidgets.git] / samples / opengl / isosurf / isosurf.cpp
index a2ea654f916d98f1d7f5fcec5c4d304480a224d1..fb9c1ac9cf740bd107714014a8064f565784c0ee 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Brian Paul (original gltk version), Wolfram Gloger
 // Modified by: Julian Smart, Francesco Montorsi
 // Created:     04/01/98
-// RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -57,7 +56,7 @@ bool MyApp::OnInit()
         return false;
 
     // Create the main frame window
-    MyFrame *frame = new MyFrame(NULL, wxT("wxWidgets OpenGL Isosurf Sample"));
+    new MyFrame(NULL, wxT("wxWidgets OpenGL Isosurf Sample"));
 
     return true;
 }
@@ -136,10 +135,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 +179,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()
@@ -210,7 +205,7 @@ void TestGLCanvas::LoadSurface(const wxString& filename)
 
     {
         // we suppose to have in input a text file containing floating numbers
-        // space/newline-separed... first 3 numbers are the coordinates of a
+        // space/newline-separated... first 3 numbers are the coordinates of a
         // vertex and the following 3 are the relative vertex normal and so on...
 
         wxTextInputStream inFile(*stream);
@@ -279,6 +274,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 +403,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 +428,8 @@ void TestGLCanvas::InitGL()
         glEnable( GL_VERTEX_ARRAY );
         glEnable( GL_NORMAL_ARRAY );
     }
+
+    InitMaterials();
+    LoadSurface("isosurf.dat.gz");
 }