[2/6] winex11.drv: Try to get an opengl visual with aux buffers

Ivan Gyurdiev ivg231 at gmail.com
Wed Feb 28 19:59:41 CST 2007


Something's wrong with this patch: it has more 2 nested if statements.
I suggest early returns on negated condition, gotos, and subroutines to 
fix the problem :)

> I don't know if that patch wasn't applied because other patches of my patchset 
> weren't applied, or because something is wrong with this patch. If something 
> is wrong with this patch please tell me
>   
> ------------------------------------------------------------------------
>
> From 029e9756abed6c2647950f86e9227ba47d366ebe Mon Sep 17 00:00:00 2001
> From: Stefan Doesinger <stefan at codeweavers.com>
> Date: Tue, 27 Feb 2007 15:53:43 +0100
> Subject: [PATCH] winex11.drv: Try to get an opengl visual with aux buffers
>
> Applications may profit from auxilliary buffers. Because we have to find
> the visual at initialization time try to find a visual with aux buffers
> first, if none is found fall back to the usual default visual without
> aux buffers
> ---
>  dlls/winex11.drv/opengl.c |   35 +++++++++++++++++++++++------------
>  1 files changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
> index fdb92ae..9c1060a 100644
> --- a/dlls/winex11.drv/opengl.c
> +++ b/dlls/winex11.drv/opengl.c
> @@ -3083,33 +3083,44 @@ BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev)
>  XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
>  {
>      XVisualInfo *visual = NULL;
> -    /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support, */
> -    int dblBuf[] = {GLX_RGBA,GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DOUBLEBUFFER, None};
> +    /* In order to support OpenGL or D3D, we require a double-buffered visual and stencil buffer support,
> +     * WineD3D and Some applications can make use of aux buffers
> +     */
> +    int dblBuf[] = {GLX_RGBA,GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_AUX_BUFFERS, 1, GLX_DOUBLEBUFFER, None};
>      if (!has_opengl()) return NULL;
>  
>      wine_tsx11_lock();
>      visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf);
>      wine_tsx11_unlock();
>      if (visual == NULL) {
> -        /* fallback to 16 bits depth, no alpha */
> -        int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, None};
> -        WARN("Failed to get a visual with at least 24 bits depth\n");
> +        /* Try without aux buffers */
> +        int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DOUBLEBUFFER, None};
> +        WARN("Failed to get a visual with at least one aux buffer\n");
>  
>          wine_tsx11_lock();
>          visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf2);
>          wine_tsx11_unlock();
>          if (visual == NULL) {
> -            /* fallback to no stencil */
> -            int dblBuf2[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None};
> -            WARN("Failed to get a visual with at least 8 bits of stencil\n");
> +            /* fallback to 16 bits depth, no alpha */
> +            int dblBuf3[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, GLX_STENCIL_SIZE, 8, GLX_DOUBLEBUFFER, None};
> +            WARN("Failed to get a visual with at least 24 bits depth\n");
>  
>              wine_tsx11_lock();
> -            visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf2);
> +            visual = pglXChooseVisual(display, DefaultScreen(display), dblBuf3);
>              wine_tsx11_unlock();
>              if (visual == NULL) {
> -                /* This should only happen if we cannot find a match with a depth size 16 */
> -                FIXME("Failed to find a suitable visual\n");
> -                return visual;
> +                /* fallback to no stencil */
> +                int dblBuf4[] = {GLX_RGBA,GLX_DEPTH_SIZE, 16, 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), dblBuf4);
> +                wine_tsx11_unlock();
> +                if (visual == NULL) {
> +                    /* This should only happen if we cannot find a match with a depth size 16 */
> +                    FIXME("Failed to find a suitable visual\n");
> +                    return visual;
> +                }
>              }
>          }
>      }
>   
> ------------------------------------------------------------------------
>
>
>   




More information about the wine-devel mailing list