-
-void wxGLCanvas::GetGLAttribListFromWX(int *wx_attribList, int *gl_attribList )
-{
- if (!wx_attribList)
- {
- if (wxGLCanvas::GetGLXVersion() >= 13)
- // leave GLX >= 1.3 choose the default attributes
- gl_attribList[0] = 0;
- else
- {
- int i = 0;
- // default settings if attriblist = 0
- gl_attribList[i++] = GLX_RGBA;
- gl_attribList[i++] = GLX_DOUBLEBUFFER;
- gl_attribList[i++] = GLX_DEPTH_SIZE; gl_attribList[i++] = 1;
- gl_attribList[i++] = GLX_RED_SIZE; gl_attribList[i++] = 1;
- gl_attribList[i++] = GLX_GREEN_SIZE; gl_attribList[i++] = 1;
- gl_attribList[i++] = GLX_BLUE_SIZE; gl_attribList[i++] = 1;
- gl_attribList[i++] = GLX_ALPHA_SIZE; gl_attribList[i++] = 0;
- gl_attribList[i++] = None;
- }
- }
- else
- {
- int arg=0, p=0;
- while( (wx_attribList[arg]!=0) && (p<510) )
- {
- switch( wx_attribList[arg++] )
- {
- case WX_GL_RGBA:
- if (wxGLCanvas::GetGLXVersion() <= 12)
- // for GLX >= 1.3, GLX_RGBA is useless (setting this flags will crash on most opengl implm)
- gl_attribList[p++] = GLX_RGBA;
- break;
- case WX_GL_BUFFER_SIZE:
- gl_attribList[p++] = GLX_BUFFER_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_LEVEL:
- gl_attribList[p++] = GLX_LEVEL;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_DOUBLEBUFFER:
- if (wxGLCanvas::GetGLXVersion() <= 12)
- gl_attribList[p++] = GLX_DOUBLEBUFFER;
- else
- // for GLX >= 1.3, GLX_DOUBLEBUFFER format is different (1 <=> True)
- // it seems this flag is useless for some hardware opengl implementation.
- // but for Mesa 6.2.1, this flag is used so don't ignore it.
- gl_attribList[p++] = GLX_DOUBLEBUFFER;
- gl_attribList[p++] = 1;
- break;
- case WX_GL_STEREO:
- gl_attribList[p++] = GLX_STEREO;
- break;
- case WX_GL_AUX_BUFFERS:
- gl_attribList[p++] = GLX_AUX_BUFFERS;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_RED:
- gl_attribList[p++] = GLX_RED_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_GREEN:
- gl_attribList[p++] = GLX_GREEN_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_BLUE:
- gl_attribList[p++] = GLX_BLUE_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_ALPHA:
- gl_attribList[p++] = GLX_ALPHA_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_DEPTH_SIZE:
- gl_attribList[p++] = GLX_DEPTH_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_STENCIL_SIZE:
- gl_attribList[p++] = GLX_STENCIL_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_ACCUM_RED:
- gl_attribList[p++] = GLX_ACCUM_RED_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_ACCUM_GREEN:
- gl_attribList[p++] = GLX_ACCUM_GREEN_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_ACCUM_BLUE:
- gl_attribList[p++] = GLX_ACCUM_BLUE_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- case WX_GL_MIN_ACCUM_ALPHA:
- gl_attribList[p++] = GLX_ACCUM_ALPHA_SIZE;
- gl_attribList[p++] = wx_attribList[arg++];
- break;
- default:
- break;
- }
- }
-
- gl_attribList[p] = 0;
- }
-}
-
-void wxGLCanvas::QueryGLXVersion()
-{
- if (m_glxVersion == 0)
- {
- // check the GLX version
- int glxMajorVer, glxMinorVer;
- bool ok = glXQueryVersion(GDK_DISPLAY(), &glxMajorVer, &glxMinorVer);
- wxASSERT_MSG( ok, _T("GLX version not found") );
- if (!ok)
- m_glxVersion = 10; // 1.0 by default
- else
- m_glxVersion = glxMajorVer*10 + glxMinorVer;
- }
-}
-
-int wxGLCanvas::GetGLXVersion()
-{
- wxASSERT_MSG( m_glxVersion>0, _T("GLX version has not been initialized with wxGLCanvas::QueryGLXVersion()") );
- return m_glxVersion;
-}
-
-
-void wxGLCanvas::SwapBuffers()