static int checkOverlayAcceptability(XVisualInfo * vi, unsigned int mode) { int value; /* Must support OpenGL. */ glXGetConfig(__glutDisplay, vi, GLX_USE_GL, &value); if (!value) return 1; /* Must be color index. */ glXGetConfig(__glutDisplay, vi, GLX_RGBA, &value); if (value) return 1; /* Must match single/double buffering request. */ glXGetConfig(__glutDisplay, vi, GLX_DOUBLEBUFFER, &value); if (GLUT_WIND_IS_DOUBLE(mode) != (value != 0)) return 1; /* Must match mono/stereo request. */ glXGetConfig(__glutDisplay, vi, GLX_STEREO, &value); if (GLUT_WIND_IS_STEREO(mode) != (value != 0)) return 1; /* Alpha and accumulation buffers incompatible with color index. */ if (GLUT_WIND_HAS_ALPHA(mode) || GLUT_WIND_HAS_ACCUM(mode)) return 1; /* Look for depth buffer if requested. */ glXGetConfig(__glutDisplay, vi, GLX_DEPTH_SIZE, &value); if (GLUT_WIND_HAS_DEPTH(mode) && (value <= 0)) return 1; /* Look for stencil buffer if requested. */ glXGetConfig(__glutDisplay, vi, GLX_STENCIL_SIZE, &value); if (GLUT_WIND_HAS_STENCIL(mode) && (value <= 0)) return 1; #if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) /* XXX Multisampled overlay color index?? Pretty unlikely. */ /* Look for multisampling if requested. */ if (__glutIsSupportedByGLX("GLX_SGIS_multisample")) glXGetConfig(__glutDisplay, vi, GLX_SAMPLES_SGIS, &value); else value = 0; if (GLUT_WIND_IS_MULTISAMPLE(mode) && (value <= 0)) return 1; #endif return 0; }
XVisualInfo * __glutDetermineVisual( unsigned int displayMode, Bool * treatAsSingle, XVisualInfo * (getVisualInfo) (unsigned int)) { XVisualInfo *vis; /* Should not be looking at display mode mask if __glutDisplayString is non-NULL. */ assert(!__glutDisplayString); *treatAsSingle = GLUT_WIND_IS_SINGLE(displayMode); vis = getVisualInfo(displayMode); if (!vis) { /* Fallback cases when can't get exactly what was asked for... */ if (GLUT_WIND_IS_SINGLE(displayMode)) { /* If we can't find a single buffered visual, try looking for a double buffered visual. We can treat a double buffered visual as a single buffer visual by changing the draw buffer to GL_FRONT and treating any swap buffers as no-ops. */ displayMode |= GLUT_DOUBLE; vis = getVisualInfo(displayMode); *treatAsSingle = True; } if (!vis && GLUT_WIND_IS_MULTISAMPLE(displayMode)) { /* If we can't seem to get multisampling (ie, not Reality Engine class graphics!), go without multisampling. It is up to the application to query how many multisamples were allocated (0 equals no multisampling) if the application is going to use multisampling for more than just antialiasing. */ displayMode &= ~GLUT_MULTISAMPLE; vis = getVisualInfo(displayMode); } } return vis; }
static XVisualInfo * getVisualInfoRGB(unsigned int mode) { #if POKA int list[32]; int n = 0; /* Should not be looking at display mode mask if __glutDisplayString is non-NULL. */ assert(!__glutDisplayString); /* XXX Would a caching mechanism to minize the calls to glXChooseVisual? You'd have to reference count XVisualInfo* pointers. Would also have to properly interact with glutInitDisplayString. */ list[n++] = GLX_RGBA; list[n++] = GLX_RED_SIZE; list[n++] = 1; list[n++] = GLX_GREEN_SIZE; list[n++] = 1; list[n++] = GLX_BLUE_SIZE; list[n++] = 1; if (GLUT_WIND_HAS_ALPHA(mode)) { list[n++] = GLX_ALPHA_SIZE; list[n++] = 1; } if (GLUT_WIND_IS_DOUBLE(mode)) { list[n++] = GLX_DOUBLEBUFFER; } if (GLUT_WIND_IS_STEREO(mode)) { list[n++] = GLX_STEREO; } if (GLUT_WIND_HAS_DEPTH(mode)) { list[n++] = GLX_DEPTH_SIZE; list[n++] = 1; } if (GLUT_WIND_HAS_STENCIL(mode)) { list[n++] = GLX_STENCIL_SIZE; list[n++] = 1; } if (GLUT_WIND_HAS_ACCUM(mode)) { list[n++] = GLX_ACCUM_RED_SIZE; list[n++] = 1; list[n++] = GLX_ACCUM_GREEN_SIZE; list[n++] = 1; list[n++] = GLX_ACCUM_BLUE_SIZE; list[n++] = 1; if (GLUT_WIND_HAS_ALPHA(mode)) { list[n++] = GLX_ACCUM_ALPHA_SIZE; list[n++] = 1; } } #if defined(GLX_VERSION_1_1) && (defined(GLX_SGIS_multisample) || defined(GLX_ARB_multisample)) if (GLUT_WIND_IS_MULTISAMPLE(mode)) { if (!__glutIsSupportedByGLX("GLX_SGIS_multisample") && !__glutIsSupportedByGLX("GLX_ARB_multisample")) return NULL; #if defined(GLX_ARB_multisample) list[n++] = GLX_SAMPLES_ARB; #elif defined(GLX_SGIS_multisample) list[n++] = GLX_SAMPLES_SGIS; #endif /* XXX Is 4 a reasonable minimum acceptable number of samples? */ list[n++] = 4; } #endif list[n] = (int) None; /* terminate list */ return glXChooseVisual(__glutDisplay, __glutScreen, list); #else /* POKA */ return glXChooseVisual(mode); #endif }
static XVisualInfo * getVisualInfoRGB(unsigned int mode) { int list[32]; int n = 0; /* Should not be looking at display mode mask if __glutDisplayString is non-NULL. */ assert(!__glutDisplayString); /* XXX Would a caching mechanism to minize the calls to glXChooseVisual? You'd have to reference count XVisualInfo* pointers. Would also have to properly interact with glutInitDisplayString. */ list[n++] = GLX_RGBA; list[n++] = GLX_RED_SIZE; list[n++] = 1; list[n++] = GLX_GREEN_SIZE; list[n++] = 1; list[n++] = GLX_BLUE_SIZE; list[n++] = 1; if (GLUT_WIND_HAS_ALPHA(mode)) { list[n++] = GLX_ALPHA_SIZE; list[n++] = 1; } if (GLUT_WIND_IS_DOUBLE(mode)) { list[n++] = GLX_DOUBLEBUFFER; } if (GLUT_WIND_IS_STEREO(mode)) { list[n++] = GLX_STEREO; } if (GLUT_WIND_HAS_DEPTH(mode)) { list[n++] = GLX_DEPTH_SIZE; list[n++] = 1; } if (GLUT_WIND_HAS_STENCIL(mode)) { list[n++] = GLX_STENCIL_SIZE; list[n++] = 1; } if (GLUT_WIND_HAS_ACCUM(mode)) { list[n++] = GLX_ACCUM_RED_SIZE; list[n++] = 1; list[n++] = GLX_ACCUM_GREEN_SIZE; list[n++] = 1; list[n++] = GLX_ACCUM_BLUE_SIZE; list[n++] = 1; if (GLUT_WIND_HAS_ALPHA(mode)) { list[n++] = GLX_ACCUM_ALPHA_SIZE; list[n++] = 1; } } /* GLX_SAMPLES_SGIS has the same value as GLX_SAMPLES_ARB. */ # ifndef GLX_SAMPLES_ARB # define GLX_SAMPLES_ARB 100001 # endif if (GLUT_WIND_IS_MULTISAMPLE(mode)) { if ( #ifdef _WIN32 !has_WGL_ARB_multisample #else !__glutIsSupportedByGLX("GLX_SGIS_multisample") && !__glutIsSupportedByGLX("GLX_ARB_multisample") #endif ) { return NULL; } /* Accept either the SGIS or ARB GLX multisample extensions. */ list[n++] = GLX_SAMPLES_ARB; list[n++] = 2; } list[n] = (int) None; /* terminate list */ return glXChooseVisual(__glutDisplay, __glutScreen, list); }
static XVisualInfo * getVisualInfoRGB(unsigned int mode) { int list[32]; int n = 0; /* XXX Would a caching mechanism to minize the calls to glXChooseVisual? You'd have to reference count XVisualInfo* pointers. */ list[n++] = GLX_RGBA; list[n++] = GLX_RED_SIZE; list[n++] = 1; list[n++] = GLX_GREEN_SIZE; list[n++] = 1; list[n++] = GLX_BLUE_SIZE; list[n++] = 1; if (GLUT_WIND_HAS_ALPHA(mode)) { list[n++] = GLX_ALPHA_SIZE; list[n++] = 1; } if (GLUT_WIND_IS_DOUBLE(mode)) { list[n++] = GLX_DOUBLEBUFFER; } if (GLUT_WIND_IS_STEREO(mode)) { list[n++] = GLX_STEREO; } if (GLUT_WIND_HAS_DEPTH(mode)) { list[n++] = GLX_DEPTH_SIZE; list[n++] = 1; } if (GLUT_WIND_HAS_STENCIL(mode)) { list[n++] = GLX_STENCIL_SIZE; list[n++] = 1; } if (GLUT_WIND_HAS_ACCUM(mode)) { list[n++] = GLX_ACCUM_RED_SIZE; list[n++] = 1; list[n++] = GLX_ACCUM_GREEN_SIZE; list[n++] = 1; list[n++] = GLX_ACCUM_BLUE_SIZE; list[n++] = 1; if (GLUT_WIND_HAS_ALPHA(mode)) { list[n++] = GLX_ACCUM_ALPHA_SIZE; list[n++] = 1; } } #if defined(GLX_VERSION_1_1) && defined(GLX_SGIS_multisample) if (GLUT_WIND_IS_MULTISAMPLE(mode)) { if (!__glutIsSupportedByGLX("GLX_SGIS_multisample")) return NULL; list[n++] = GLX_SAMPLES_SGIS; /* XXX Is 4 a reasonable minimum acceptable number of samples? */ list[n++] = 4; } #endif list[n] = (int) None; /* terminate list */ return glXChooseVisual(__glutDisplay, __glutScreen, list); }