protect against broken apps
authorDaniel Borca <dborca@users.sourceforge.net>
Wed, 7 Jan 2004 13:54:17 +0000 (13:54 +0000)
committerDaniel Borca <dborca@users.sourceforge.net>
Wed, 7 Jan 2004 13:54:17 +0000 (13:54 +0000)
src/mesa/drivers/glide/fxwgl.c

index bba6c98cfc5cb10da09a4f7171ba141a781b4fa2..cf2d820bc7400c0c2ba7eb0600d68bfd9addba8f 100644 (file)
@@ -827,10 +827,17 @@ wglSetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR * ppfd)
 
    qt_valid_pix = qt_pix;
 
-   if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix
-       || ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
-      SetLastError(0);
-      return (FALSE);
+   if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix) {
+      if (ppfd == NULL) {
+         PIXELFORMATDESCRIPTOR my_pfd;
+         if (!wglDescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &my_pfd)) {
+            SetLastError(0);
+            return (FALSE);
+         }
+      } else if (ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR)) {
+         SetLastError(0);
+         return (FALSE);
+      }
    }
    curPFD = iPixelFormat;