}
+/**
+ * Return the stw pixel format that most closely matches the pixel format
+ * on HDC.
+ * Used to get a pixel format when SetPixelFormat() hasn't been called before.
+ */
+static int
+get_matching_pixel_format(HDC hdc)
+{
+ int iPixelFormat = GetPixelFormat(hdc);
+ PIXELFORMATDESCRIPTOR pfd;
+
+ if (!iPixelFormat)
+ return 0;
+ if (!DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd))
+ return 0;
+ return stw_pixelformat_choose(hdc, &pfd);
+}
+
+
/**
* Called via DrvCreateContext(), DrvCreateLayerContext() and
* wglCreateContextAttribsARB() to actually create a rendering 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);
+ iPixelFormat = get_matching_pixel_format(hdc);
if (!iPixelFormat)
return 0;
}
* pixel format in some cases, so we must create a framebuffer for
* those here.
*/
- int iPixelFormat = GetPixelFormat(hDrawDC);
+ int iPixelFormat = get_matching_pixel_format(hDrawDC);
if (iPixelFormat)
fb = stw_framebuffer_create( hDrawDC, iPixelFormat );
if (!fb)