[PATCH 6/7] wined3d: Use wglCreateContextAttribsARB() during adapter initialization too.

Matteo Bruni mbruni at codeweavers.com
Thu Apr 18 14:20:03 CDT 2013


The extension string parsing code is practically ripped off from
parse_extension_string(). Actually, would it be okay to just try to get
the wglCreateContextAttribsARB function pointer, ignoring the extension
string?
---
 dlls/wined3d/directx.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 966bdca..e4cf89a 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -299,10 +299,12 @@ static void WineD3D_ReleaseFakeGLContext(const struct wined3d_fake_gl_ctx *ctx)
 }
 
 /* Do not call while under the GL lock. */
-static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
+static BOOL WineD3D_CreateFakeGLContext(struct wined3d_adapter *adapter, struct wined3d_fake_gl_ctx *ctx)
 {
     PIXELFORMATDESCRIPTOR pfd;
     int iPixelFormat;
+    struct wined3d_gl_info *gl_info = &adapter->gl_info;
+    const char *extensions = NULL;
 
     TRACE("getting context...\n");
 
@@ -357,6 +359,55 @@ static BOOL WineD3D_CreateFakeGLContext(struct wined3d_fake_gl_ctx *ctx)
         goto fail;
     }
 
+    GL_EXTCALL(wglGetExtensionsStringARB) = (void *)wglGetProcAddress("wglGetExtensionsStringARB");
+    if (GL_EXTCALL(wglGetExtensionsStringARB))
+        extensions = (const char *)GL_EXTCALL(wglGetExtensionsStringARB(ctx->dc));
+    while (extensions && *extensions)
+    {
+        const char *start;
+        size_t len;
+
+        while (isspace(*extensions))
+            ++extensions;
+        start = extensions;
+        while (!isspace(*extensions) && *extensions)
+            ++extensions;
+
+        len = extensions - start;
+        if (!len)
+            continue;
+
+        if (len == strlen("WGL_ARB_create_context") && !memcmp(start, "WGL_ARB_create_context", len))
+        {
+            gl_info->p_wglCreateContextAttribsARB = (void *)wglGetProcAddress("wglCreateContextAttribsARB");
+            break;
+        }
+    }
+
+    if (gl_info->p_wglCreateContextAttribsARB)
+    {
+        if (!wglMakeCurrent(NULL, NULL))
+            ERR("Failed to disable fake GL context.\n");
+        if (!wglDeleteContext(ctx->gl_ctx))
+        {
+            DWORD err = GetLastError();
+            ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx->gl_ctx, err);
+        }
+
+        TRACE("Creating a new GL context via wglCreateContextAttribsARB.\n");
+        if (!(ctx->gl_ctx = gl_info->p_wglCreateContextAttribsARB(ctx->dc, NULL, NULL)))
+        {
+            ERR("Failed to create a WGL context.\n");
+            goto fail;
+        }
+
+        if (!wglMakeCurrent(ctx->dc, ctx->gl_ctx))
+        {
+            ERR("Failed to make fake GL context current.\n");
+            goto fail;
+        }
+    }
+
     return TRUE;
 
 fail:
@@ -4917,7 +4968,7 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal)
     TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
             adapter->luid.HighPart, adapter->luid.LowPart, adapter);
 
-    if (!WineD3D_CreateFakeGLContext(&fake_gl_ctx))
+    if (!WineD3D_CreateFakeGLContext(adapter, &fake_gl_ctx))
     {
         ERR("Failed to get a GL context for adapter %p.\n", adapter);
         return FALSE;
-- 
1.8.1.5




More information about the wine-patches mailing list