X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b089c5e8c8a2140258d150ca1ce42afd3b79e1b..015e69f36dfbc469eef59456f973d0567e865d70:/samples/opengl/isosurf/isosurf.cpp?ds=sidebyside diff --git a/samples/opengl/isosurf/isosurf.cpp b/samples/opengl/isosurf/isosurf.cpp index 6ba560cff1..6ab145c64b 100644 --- a/samples/opengl/isosurf/isosurf.cpp +++ b/samples/opengl/isosurf/isosurf.cpp @@ -25,6 +25,10 @@ #include "wx/wx.h" #endif +#if !wxUSE_GLCANVAS +#error Please set wxUSE_GLCANVAS to 1 in setup.h. +#endif + #include "wx/timer.h" #include "wx/glcanvas.h" @@ -249,9 +253,9 @@ bool MyApp::OnInit(void) #ifdef __WXMSW__ int *gl_attrib = NULL; #else - int gl_attrib[20] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1, - GLX_DOUBLEBUFFER, None }; + int gl_attrib[20] = { WX_GL_RGBA, WX_GL_MIN_RED, 1, WX_GL_MIN_GREEN, 1, + WX_GL_MIN_BLUE, 1, WX_GL_DEPTH_SIZE, 1, + WX_GL_DOUBLEBUFFER, None }; #endif if(!doubleBuffer) @@ -262,8 +266,9 @@ bool MyApp::OnInit(void) #endif doubleBuffer = GL_FALSE; } - frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200), 0, "TestGLCanvas", - gl_attrib); + + frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200), + 0, "TestGLCanvas", gl_attrib ); // Show the frame frame->Show(TRUE); @@ -312,6 +317,7 @@ TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id, { parent->Show(TRUE); SetCurrent(); + /* Make sure server supports the vertex array extension */ char* extensions = (char *) glGetString( GL_EXTENSIONS ); if (!extensions || !strstr( extensions, "GL_EXT_vertex_array" )) { @@ -330,12 +336,22 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event ) // OnPaint handlers must always create a wxPaintDC. wxPaintDC dc(this); +#ifndef __WXMOTIF__ + if (!GetContext()) return; +#endif + + SetCurrent(); + draw1(); SwapBuffers(); } void TestGLCanvas::OnSize(wxSizeEvent& event) { +#ifndef __WXMOTIF__ + if (!GetContext()) return; +#endif + SetCurrent(); int width, height; GetClientSize(& width, & height);