Roderick Colenbrander : wined3d: Check the results of SetPixelFormat.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 13 06:31:53 CDT 2007


Module: wine
Branch: master
Commit: 1dc0298a55b6050f19cf2df298268dcda4b85081
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1dc0298a55b6050f19cf2df298268dcda4b85081

Author: Roderick Colenbrander <thunderbird2k at gmx.net>
Date:   Sat Aug 11 17:04:26 2007 +0200

wined3d: Check the results of SetPixelFormat.

---

 dlls/wined3d/context.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 9edbd73..0727aee 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -208,6 +208,7 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
         short red, green, blue, alpha;
         short colorBits;
         short depthBits, stencilBits;
+        int res;
 
         hdc = GetDC(win_handle);
         if(hdc == NULL) {
@@ -249,7 +250,20 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
         }
 
         DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd);
-        SetPixelFormat(hdc, iPixelFormat, NULL);
+        res = SetPixelFormat(hdc, iPixelFormat, NULL);
+        if(!res) {
+            int oldPixelFormat = GetPixelFormat(hdc);
+
+            if(oldPixelFormat) {
+                /* OpenGL doesn't allow pixel format adjustments. Print an error and continue using the old format.
+                 * There's a big chance that the old format works although with a performance hit and perhaps rendering errors. */
+                ERR("HDC=%p is already set to iPixelFormat=%d and OpenGL doesn't allow changes!\n", hdc, oldPixelFormat);
+            }
+            else {
+                ERR("SetPixelFormat failed on HDC=%p for iPixelFormat=%d\n", hdc, iPixelFormat);
+                return FALSE;
+            }
+        }
     }
 
     ctx = wglCreateContext(hdc);




More information about the wine-cvs mailing list