Apply BGE patch 12799: Fix quad buffer stereo mode for Windows
[blender.git] / intern / ghost / intern / GHOST_WindowWin32.cpp
index 230df02c3594237a1584bc5bd685f1eb19d4231b..905b2f7ac6349487d6c1b6371690f3db4927ba27 100644 (file)
@@ -871,12 +871,25 @@ static int EnumPixelFormats(HDC hdc) {
        for(i=1; i<=n; i++) { /* not the idiom, but it's right */
                ::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
                w = WeightPixelFormat(pfd);
-               if(w > weight) {
-                       weight = w;
-                       iPixelFormat = i;
+               // be strict on stereo
+               if (!((sPreferredFormat.dwFlags ^ pfd.dwFlags) & PFD_STEREO))   {
+                       if(w > weight) {
+                               weight = w;
+                               iPixelFormat = i;
+                       }
+               }
+       }
+       if (weight == 0) {
+               // we could find the correct stereo setting, just find any suitable format 
+               for(i=1; i<=n; i++) { /* not the idiom, but it's right */
+                       ::DescribePixelFormat( hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
+                       w = WeightPixelFormat(pfd);
+                       if(w > weight) {
+                               weight = w;
+                               iPixelFormat = i;
+                       }
                }
        }
-       
        return iPixelFormat;
 }