[PATCH 2/2] winex11.drv: Make the GL context current even if no drawables were given.

Alexandre Julliard julliard at winehq.org
Tue Feb 23 03:07:17 CST 2016


Charles Davis <cdavis5x at gmail.com> writes:

> @@ -1833,26 +1833,29 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
>          return TRUE;
>      }
>  
> -    if ((gl = get_gl_drawable( WindowFromDC( hdc ), hdc )))
> +    if (!hdc || (gl = get_gl_drawable( WindowFromDC( hdc ), hdc )))
>      {
> -        if (ctx->fmt != gl->format)
> +        if (gl && ctx->fmt != gl->format)
>          {
>              WARN( "mismatched pixel format hdc %p %p ctx %p %p\n", hdc, gl->format, ctx, ctx->fmt );
>              SetLastError( ERROR_INVALID_PIXEL_FORMAT );
>              goto done;
>          }
>  
> -        TRACE("hdc %p drawable %lx fmt %p ctx %p %s\n", hdc, gl->drawable, gl->format, ctx->ctx,
> -              debugstr_fbconfig( gl->format->fbconfig ));
> +        if (gl)
> +            TRACE("hdc %p drawable %lx fmt %p ctx %p %s\n", hdc, gl->drawable, gl->format, ctx->ctx,
> +                  debugstr_fbconfig( gl->format->fbconfig ));
> +        else
> +            TRACE("ctx %p (no drawable)\n", ctx->ctx);
>  
> -        ret = pglXMakeCurrent(gdi_display, gl->drawable, ctx->ctx);
> +        ret = pglXMakeCurrent(gdi_display, gl ? gl->drawable : None, ctx->ctx);
>          if (ret)
>          {
>              NtCurrentTeb()->glContext = ctx;
>              ctx->has_been_current = TRUE;
>              ctx->hdc = hdc;
> -            ctx->drawables[0] = gl->drawable;
> -            ctx->drawables[1] = gl->drawable;
> +            ctx->drawables[0] = gl ? gl->drawable : 0;
> +            ctx->drawables[1] = gl ? gl->drawable : 0;

You really want a separate code path instead of adding pointer checks
everywhere.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list