]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/opengl/isosurf/isosurf.cpp
added missing methods/removed duplicated base methods
[wxWidgets.git] / samples / opengl / isosurf / isosurf.cpp
index 1979c71ead7fa8d643350156344c4314974f75f9..3d3bda3dc983ef0de7de25fa73498d4c32bb8724 100644 (file)
 #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"
 
-#include <GL/gl.h>
-#include <GL/glu.h>
+#ifdef __WXMAC__
+#  ifdef __DARWIN__
+#    include <OpenGL/gl.h>
+#    include <OpenGL/glu.h>
+#  else
+#    include <gl.h>
+#    include <glu.h>
+#  endif
+#else
+#  include <GL/gl.h>
+#  include <GL/glu.h>
+#endif
 
 #include "isosurf.h"
 
@@ -249,9 +263,14 @@ 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,
+#  ifdef __WXMAC__
+                       GL_NONE };
+#  else
+                       None };
+#  endif
 #endif
 
   if(!doubleBuffer)
@@ -262,8 +281,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 +332,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" )) {
@@ -334,6 +355,8 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event )
     if (!GetContext()) return;
 #endif
 
+    SetCurrent();
+
     draw1();
     SwapBuffers();
 }