Commit c01d723a authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent 356f9897
......@@ -1608,43 +1608,27 @@ static BOOL glxdrv_wglCopyContext(struct wgl_context *src, struct wgl_context *d
*/
static struct wgl_context *glxdrv_wglCreateContext( HDC hdc )
{
struct x11drv_escape_get_drawable escape;
struct wgl_context *ret;
const struct wgl_pixel_format *fmt;
TRACE( "(%p)\n", hdc );
struct wgl_context *ret = NULL;
struct gl_drawable *gl;
HWND hwnd = WindowFromDC( hdc );
escape.code = X11DRV_GET_DRAWABLE;
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape.code), (LPCSTR)&escape.code,
sizeof(escape), (LPSTR)&escape ))
return 0;
EnterCriticalSection( &context_section );
fmt = get_pixel_format(gdi_display, escape.pixel_format, TRUE /* Offscreen */);
/* We can render using the iPixelFormat (1) of Wine's Main visual AND using some offscreen formats.
* Note that standard WGL-calls don't recognize offscreen-only formats. For that reason pbuffers
* use a sort of 'proxy' HDC (wglGetPbufferDCARB).
* If this fails something is very wrong on the system. */
if(!fmt) {
ERR("Cannot get FB Config for iPixelFormat %d, expect problems!\n", escape.pixel_format);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
if (!XFindContext( gdi_display, (XID)hwnd, gl_hwnd_context, (char **)&gl ) ||
!XFindContext( gdi_display, (XID)hdc, gl_pbuffer_context, (char **)&gl ))
{
if (!(ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret)))) goto done;
ret->hdc = hdc;
ret->fmt = gl->format;
ret->vis = pglXGetVisualFromFBConfig(gdi_display, gl->format->fbconfig);
ret->ctx = create_glxcontext(gdi_display, ret, NULL);
list_add_head( &context_list, &ret->entry );
}
else SetLastError( ERROR_INVALID_PIXEL_FORMAT );
if (!(ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret)))) return 0;
ret->hdc = hdc;
ret->fmt = fmt;
ret->has_been_current = FALSE;
ret->sharing = FALSE;
ret->vis = pglXGetVisualFromFBConfig(gdi_display, fmt->fbconfig);
ret->ctx = create_glxcontext(gdi_display, ret, NULL);
EnterCriticalSection( &context_section );
list_add_head( &context_list, &ret->entry );
done:
LeaveCriticalSection( &context_section );
TRACE(" creating context %p (GL context creation delayed)\n", ret);
TRACE( "%p -> %p\n", hdc, 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