st/wgl: Properly support non-displayble pixel formats, and implement float pixelforma...
[mesa.git] / src / gallium / state_trackers / wgl / stw_context.c
index 1409f240ef5d2fb6e21cea66c47eed3395341c5d..7031af5bb3ac3a2f4b3200f72198c9857c85c245 100644 (file)
@@ -138,6 +138,7 @@ stw_create_context_attribs(
    int contextFlags, int profileMask)
 {
    int iPixelFormat;
+   struct stw_framebuffer *fb;
    const struct stw_pixelformat_info *pfi;
    struct st_context_attribs attribs;
    struct stw_context *ctx = NULL;
@@ -154,6 +155,19 @@ stw_create_context_attribs(
    if(!iPixelFormat)
       return 0;
 
+   /*
+    * GDI only knows about displayable pixel formats, so determine the pixel format
+    * from the framebuffer.
+    *
+    * TODO: Remove the GetPixelFormat() above, and stop relying on GDI.
+    */
+   fb = stw_framebuffer_from_hdc( hdc );
+   if (fb) {
+      assert(iPixelFormat == fb->iDisplayablePixelFormat);
+      iPixelFormat = fb->iPixelFormat;
+      stw_framebuffer_release(fb);
+   }
+
    pfi = stw_pixelformat_get_info( iPixelFormat );
 
    if (hShareContext != 0) {