gallium/wgl: Allow context creation even if SetPixelFormat() wasn't called
authorFrank Richter <frank.richter@dynardo.de>
Wed, 7 Jun 2017 07:43:43 +0000 (09:43 +0200)
committerBrian Paul <brianp@vmware.com>
Fri, 9 Jun 2017 14:51:45 +0000 (08:51 -0600)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101326
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/state_trackers/wgl/stw_context.c

index f3145a9e637d8cf7f8e88419a55f5e03f93a95bf..58fe3b0b6e66accd15a4b90bbecc71cdc120c72a 100644 (file)
@@ -170,7 +170,13 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
       iPixelFormat = fb->iPixelFormat;
       stw_framebuffer_unlock(fb);
    } else {
-      return 0;
+      /* Applications should call SetPixelFormat before creating a context,
+       * but not all do, and the opengl32 runtime seems to use a default
+       * pixel format in some cases, so use that.
+       */
+      iPixelFormat = GetPixelFormat(hdc);
+      if (!iPixelFormat)
+         return 0;
    }
 
    pfi = stw_pixelformat_get_info( iPixelFormat );