- int data[512];
- if (!attribList)
- {
- // default settings if attriblist = 0
- data[0] = GLX_RGBA;
- data[1] = GLX_DOUBLEBUFFER;
- data[2] = GLX_DEPTH_SIZE; data[3] = 1;
- data[4] = GLX_RED_SIZE; data[5] = 1;
- data[6] = GLX_GREEN_SIZE; data[7] = 1;
- data[8] = GLX_BLUE_SIZE; data[9] = 1;
- data[10] = GLX_ALPHA_SIZE; data[11] = 0;
- data[12] = None;
-
- attribList = (int*) data;
- }
- else
- {
- int arg=0, p=0;
-
- while( (attribList[arg]!=0) && (p<510) )
- {
- switch( attribList[arg++] )
- {
- case WX_GL_RGBA: data[p++] = GLX_RGBA; break;
- case WX_GL_BUFFER_SIZE:
- data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_LEVEL:
- data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break;
- case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break;
- case WX_GL_STEREO: data[p++] = GLX_STEREO; break;
- case WX_GL_AUX_BUFFERS:
- data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_RED:
- data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_GREEN:
- data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_BLUE:
- data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ALPHA:
- data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_DEPTH_SIZE:
- data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_STENCIL_SIZE:
- data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_RED:
- data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_GREEN:
- data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_BLUE:
- data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break;
- case WX_GL_MIN_ACCUM_ALPHA:
- data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
- default:
- break;
- }
- }
- data[p] = 0;
-
- attribList = (int*) data;
- }
-
-
- Display *dpy = GDK_DISPLAY();
-
- return glXChooseVisual( dpy, DefaultScreen(dpy), attribList );
-}
-
-void wxGLCanvas::SwapBuffers()
-{
- if (m_glContext) m_glContext->SwapBuffers();
-}
-
-void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
-{
- int width, height;
- GetClientSize( &width, &height );
-
- if (m_glContext && GTK_WIDGET_REALIZED(m_glWidget) )
- {
- SetCurrent();
-
- glViewport(0, 0, (GLint)width, (GLint)height );
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 15.0 );
- glMatrixMode(GL_MODELVIEW);
- }
-}
-
-void wxGLCanvas::SetCurrent()
-{
- if (m_glContext) m_glContext->SetCurrent();
-}
-
-void wxGLCanvas::SetColour( const char *colour )
-{
- if (m_glContext) m_glContext->SetColour( colour );