X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/df344ba9df2d455286b67f9f03b6d7ea28bc61fa..8a31648287be0ef976f133de2786b137f1e98340:/samples/opengl/isosurf/isosurf.cpp diff --git a/samples/opengl/isosurf/isosurf.cpp b/samples/opengl/isosurf/isosurf.cpp index 8798d37922..66cc2a31c4 100644 --- a/samples/opengl/isosurf/isosurf.cpp +++ b/samples/opengl/isosurf/isosurf.cpp @@ -57,7 +57,7 @@ bool MyApp::OnInit() return false; // Create the main frame window - SetTopWindow(new MyFrame(NULL, wxT("wxWidgets OpenGL Isosurf Sample"))); + new MyFrame(NULL, wxT("wxWidgets OpenGL Isosurf Sample")); return true; } @@ -103,9 +103,9 @@ MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, // Make a menubar wxMenu *fileMenu = new wxMenu; - fileMenu->Append(wxID_EXIT, _T("E&xit")); + fileMenu->Append(wxID_EXIT, wxT("E&xit")); wxMenuBar *menuBar = new wxMenuBar; - menuBar->Append(fileMenu, _T("&File")); + menuBar->Append(fileMenu, wxT("&File")); SetMenuBar(menuBar); @@ -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() @@ -210,7 +206,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); @@ -230,9 +226,9 @@ void TestGLCanvas::LoadSurface(const wxString& filename) delete stream; - wxLogMessage(_T("Loaded %d vertices, %d triangles from '%s'"), + wxLogMessage(wxT("Loaded %d vertices, %d triangles from '%s'"), m_numverts, m_numverts-2, filename.c_str()); - + // NOTE: for some reason under wxGTK the following is required to avoid that // the surface gets rendered in a small rectangle in the top-left corner of the frame PostSizeEventToParent(); @@ -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"); }