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

Alexandre Julliard julliard at winehq.org
Fri Sep 7 13:26:21 CDT 2012


Module: wine
Branch: master
Commit: c01d723a4fd91fbde6d9dc201329be3c2cccdea2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c01d723a4fd91fbde6d9dc201329be3c2cccdea2

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Sep  7 15:43:01 2012 +0200

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

---

 dlls/winex11.drv/opengl.c |   48 +++++++++++++++------------------------------
 1 files changed, 16 insertions(+), 32 deletions(-)

diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c
index 3c557db..dccee22 100644
--- a/dlls/winex11.drv/opengl.c
+++ b/dlls/winex11.drv/opengl.c
@@ -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;
 }
 




More information about the wine-cvs mailing list