From d760208a5aa8b427d5f817c9ff83b60149cbba8b Mon Sep 17 00:00:00 2001 From: Oliver Stieber Date: Tue, 5 Jul 2005 10:58:41 +0000 Subject: [PATCH] Make sure that the OpenGL visual created for a window has a stencil buffer. --- dlls/x11drv/opengl.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/dlls/x11drv/opengl.c b/dlls/x11drv/opengl.c index a0cb522c9eb..82c989dc11e 100644 --- a/dlls/x11drv/opengl.c +++ b/dlls/x11drv/opengl.c @@ -474,14 +474,26 @@ BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) { XVisualInfo *X11DRV_setup_opengl_visual( Display *display ) { XVisualInfo *visual = NULL; - int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None}; - + /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support, */ + int dblBuf[] = {GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_STENCIL_SIZE,8,GLX_DOUBLEBUFFER,None}; if (!has_opengl()) return NULL; - - /* In order to support OpenGL or D3D, we require a double-buffered visual */ + wine_tsx11_lock(); visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf); wine_tsx11_unlock(); + if (visual == NULL) { + /* fallback to a 1 bit stencil (opengl states that at least 1 bit of stencil must be provided for on of the available configurations) */ + int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_STENCIL_SIZE,1,GLX_DOUBLEBUFFER,None}; + WARN("Failed to get a visual with at least 8 bits of stencil\n"); + + wine_tsx11_lock(); + visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf2); + wine_tsx11_unlock(); + if (visual == NULL) { + /* This should only happen if we cannot fidn a match with a depth size 16 */ + FIXME("Failed to find a suitable visual\n"); + } + } return visual; }