[PATCH 1/2] opengl32: Store the OpenGL context version in the handle value. (v2)

Matteo Bruni mbruni at codeweavers.com
Fri Jan 16 12:38:54 CST 2015


v2: Don't add a separate enum for the context version.

Definitely nicer without the separate enum.
---
 dlls/opengl32/wgl.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c
index 3a5e148..32d241c 100644
--- a/dlls/opengl32/wgl.c
+++ b/dlls/opengl32/wgl.c
@@ -51,8 +51,9 @@ extern struct opengl_funcs null_opengl_funcs;
 
 enum wgl_handle_type
 {
-    HANDLE_CONTEXT = 0 << 12,
-    HANDLE_PBUFFER = 1 << 12,
+    HANDLE_PBUFFER = 0 << 12,
+    HANDLE_CONTEXT = 1 << 12,
+    HANDLE_CONTEXT_V3 = 3 << 12,
     HANDLE_TYPE_MASK = 15 << 12
 };
 
@@ -270,8 +271,24 @@ HGLRC WINAPI wglCreateContextAttribsARB( HDC hdc, HGLRC share, const int *attrib
     {
         if ((context = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context) )))
         {
+            enum wgl_handle_type type = HANDLE_CONTEXT;
+
+            if (attribs)
+            {
+                while (*attribs)
+                {
+                    if (attribs[0] == WGL_CONTEXT_MAJOR_VERSION_ARB)
+                    {
+                        if (attribs[1] >= 3)
+                            type = HANDLE_CONTEXT_V3;
+                        break;
+                    }
+                    attribs += 2;
+                }
+            }
+
             context->drv_ctx = drv_ctx;
-            if (!(ret = alloc_handle( HANDLE_CONTEXT, funcs, context )))
+            if (!(ret = alloc_handle( type, funcs, context )))
                 HeapFree( GetProcessHeap(), 0, context );
         }
         if (!ret) funcs->wgl.p_wglDeleteContext( drv_ctx );
-- 
2.0.5




More information about the wine-patches mailing list