From f6e22d69af6bc8f63c3a46535a09e217696a679f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 23 Apr 2008 12:28:30 -0400 Subject: [PATCH] Prefer glxvisuals with stencil buffer for default visuals The first fbconfig which has a depthbuffer > 0 and doublebuf is choosen when associating fbconfigs with the visuals, indepenent of stencil bits. This happens to work ok on intel as there all fbconfigs with a depthbuffer > 0 also have stencil bits. This patch fixes this by first trying to get a fbconfig for default X visuals with both stencilbuf, depthbuf and doublebuffering, and if that fails fallback to trying to get one with only a depthbuf and doublebuffering. --- GL/glx/glxscreens.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/GL/glx/glxscreens.c b/GL/glx/glxscreens.c index 41ee029e6..5859de0b1 100644 --- a/GL/glx/glxscreens.c +++ b/GL/glx/glxscreens.c @@ -437,6 +437,7 @@ initGlxVisual(VisualPtr visual, __GLXconfig *config) typedef struct { GLboolean doubleBuffer; GLboolean depthBuffer; + GLboolean stencilBuffer; } FBConfigTemplateRec, *FBConfigTemplatePtr; static __GLXconfig * @@ -453,6 +454,8 @@ pickFBConfig(__GLXscreen *pGlxScreen, FBConfigTemplatePtr template, int class) continue; if ((config->depthBits > 0) != template->depthBuffer) continue; + if ((config->stencilBits > 0) != template->stencilBuffer) + continue; return config; } @@ -466,8 +469,9 @@ addMinimalSet(__GLXscreen *pGlxScreen) __GLXconfig *config; VisualPtr visuals; int i, j; - FBConfigTemplateRec best = { GL_TRUE, GL_TRUE }; - FBConfigTemplateRec minimal = { GL_FALSE, GL_FALSE }; + FBConfigTemplateRec best = { GL_TRUE, GL_TRUE, GL_TRUE }; + FBConfigTemplateRec good = { GL_TRUE, GL_TRUE, GL_FALSE }; + FBConfigTemplateRec minimal = { GL_FALSE, GL_FALSE, GL_FALSE }; pGlxScreen->visuals = xcalloc(pGlxScreen->pScreen->numVisuals, sizeof (__GLXconfig *)); @@ -480,8 +484,11 @@ addMinimalSet(__GLXscreen *pGlxScreen) for (i = 0, j = 0; i < pGlxScreen->pScreen->numVisuals; i++) { if (visuals[i].nplanes == 32) config = pickFBConfig(pGlxScreen, &minimal, visuals[i].class); - else + else { config = pickFBConfig(pGlxScreen, &best, visuals[i].class); + if (config == NULL) + config = pickFBConfig(pGlxScreen, &good, visuals[i].class); + } if (config == NULL) config = pGlxScreen->fbconfigs; if (config == NULL)