X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fa399c9e241e99132733b09673cbcb76c9f77e1..8916d00747c8e7b704ad549afcd8d0f88b6d861e:/samples/opengl/isosurf/isosurf.cpp?ds=sidebyside diff --git a/samples/opengl/isosurf/isosurf.cpp b/samples/opengl/isosurf/isosurf.cpp index 3a5cc72b01..fbb0a5e752 100644 --- a/samples/opengl/isosurf/isosurf.cpp +++ b/samples/opengl/isosurf/isosurf.cpp @@ -32,8 +32,24 @@ #include "wx/timer.h" #include "wx/glcanvas.h" -#include -#include +#ifdef __WXMAC__ +# ifdef __DARWIN__ +# include +# include +# else +# include +# include +# endif +#else +# include +# include +#endif + +// disabled because this has apparently changed in OpenGL 1.2, so doesn't link +// correctly if this is on... +#ifdef GL_EXT_vertex_array +#undef GL_EXT_vertex_array +#endif #include "isosurf.h" @@ -187,13 +203,6 @@ static void Init(void) #endif } - -static void Reshape(int width, int height) -{ - glViewport(0, 0, (GLint)width, (GLint)height); -} - - static GLenum Args(int argc, char **argv) { GLint i; @@ -253,9 +262,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) @@ -266,8 +280,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, wxDefaultPosition, wxDefaultSize, + 0, "TestGLCanvas", gl_attrib ); // Show the frame frame->Show(TRUE); @@ -316,6 +331,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" )) { @@ -338,20 +354,27 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event ) if (!GetContext()) return; #endif + SetCurrent(); + draw1(); SwapBuffers(); } void TestGLCanvas::OnSize(wxSizeEvent& event) { + // this is also necessary to update the context on some platforms + wxGLCanvas::OnSize(event); + + // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) + int w, h; + GetClientSize(&w, &h); #ifndef __WXMOTIF__ - if (!GetContext()) return; + if (GetContext()) #endif - + { SetCurrent(); - int width, height; - GetClientSize(& width, & height); - Reshape(width, height); + glViewport(0, 0, (GLint) w, (GLint) h); + } } void TestGLCanvas::OnChar(wxKeyEvent& event)