Commit 11013af0 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Get the current pixel format from the drawable structure in wglMakeCurrent.

parent d52c2de7
...@@ -1662,8 +1662,9 @@ static PROC glxdrv_wglGetProcAddress(LPCSTR lpszProc) ...@@ -1662,8 +1662,9 @@ static PROC glxdrv_wglGetProcAddress(LPCSTR lpszProc)
*/ */
static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx) static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
{ {
BOOL ret; BOOL ret = FALSE;
struct x11drv_escape_get_drawable escape; HWND hwnd;
struct gl_drawable *gl;
TRACE("(%p,%p)\n", hdc, ctx); TRACE("(%p,%p)\n", hdc, ctx);
...@@ -1674,51 +1675,41 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx) ...@@ -1674,51 +1675,41 @@ static BOOL glxdrv_wglMakeCurrent(HDC hdc, struct wgl_context *ctx)
return TRUE; return TRUE;
} }
escape.code = X11DRV_GET_DRAWABLE; hwnd = WindowFromDC( hdc );
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code, EnterCriticalSection( &context_section );
sizeof(escape), (LPSTR)&escape ))
return FALSE;
if (!escape.pixel_format) if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&gl ) ||
{ !XFindContext( gdi_display, (XID)hdc, gl_pbuffer_context, (char **)&gl ))
WARN("Trying to use an invalid drawable\n");
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (ctx->fmt - pixel_formats != escape.pixel_format - 1)
{
WARN( "mismatched pixel format hdc %p %u ctx %p\n", hdc, escape.pixel_format, ctx );
SetLastError( ERROR_INVALID_PIXEL_FORMAT );
return FALSE;
}
else
{ {
if (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;
}
if (TRACE_ON(wgl)) { if (TRACE_ON(wgl)) {
int vis_id;
pglXGetFBConfigAttrib(gdi_display, ctx->fmt->fbconfig, GLX_VISUAL_ID, &vis_id);
describeContext(ctx); describeContext(ctx);
TRACE("hdc %p drawable %lx fmt %u vis %x ctx %p\n", hdc, TRACE("hdc %p drawable %lx fmt %p ctx %p\n", hdc, gl->drawable, gl->format, ctx->ctx );
escape.gl_drawable, escape.pixel_format, vis_id, ctx->ctx);
} }
ret = pglXMakeCurrent(gdi_display, escape.gl_drawable, ctx->ctx); ret = pglXMakeCurrent(gdi_display, gl->drawable, ctx->ctx);
if (ret) if (ret)
{ {
NtCurrentTeb()->glContext = ctx; NtCurrentTeb()->glContext = ctx;
EnterCriticalSection( &context_section );
ctx->has_been_current = TRUE; ctx->has_been_current = TRUE;
ctx->hdc = hdc; ctx->hdc = hdc;
ctx->drawables[0] = escape.gl_drawable; ctx->drawables[0] = gl->drawable;
ctx->drawables[1] = escape.gl_drawable; ctx->drawables[1] = gl->drawable;
ctx->refresh_drawables = FALSE; ctx->refresh_drawables = FALSE;
LeaveCriticalSection( &context_section ); goto done;
} }
else
SetLastError(ERROR_INVALID_HANDLE);
} }
TRACE(" returning %s\n", (ret ? "True" : "False")); SetLastError( ERROR_INVALID_HANDLE );
done:
LeaveCriticalSection( &context_section );
TRACE( "%p,%p returning %d\n", hdc, ctx, ret );
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment