- }
-
- if(attribList) {
- int data[512], arg=0, p=0;
-
- while( (attribList[arg]!=0) && (p<512) )
- {
- 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;
-
- // Get an appropriate visual
- vi = glXChooseVisual(display, DefaultScreen(display), data);
- if(!vi) return false;
-
- // Here we should make sure that vi is the same visual as the
- // one used by the xwindow drawable in wxCanvas. However,
- // there is currently no mechanism for this in wx_canvs.cc.
- }
- else // default attributes
- {
- // By default, we use the visual of xwindow
- XGetWindowAttributes(display, wxGetClientAreaWindow(this), &xwa);
- vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
- vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
- if(!vi) return false;
- glXGetConfig(display, vi, GLX_USE_GL, &val);
- if(!val) return false;
- }
-
- m_vi = vi; // safe for later use
-
- wxCHECK_MSG( m_vi, false, wxT("required visual couldn't be found") );