Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / intern / ghost / intern / GHOST_WindowWin32.cpp
index ef7294c235403b56c571d4170211937e17183152..fef58d071a457a3412c72bfbe1344e8875c4d097 100644 (file)
@@ -1,14 +1,11 @@
 /**
  * $Id$
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -26,7 +23,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 /**
 #define M_PI 3.1415926536
 #endif
 
+// win64 doesn't define GWL_USERDATA
+#ifdef WIN32
+#ifndef GWL_USERDATA
+#define GWL_USERDATA GWLP_USERDATA
+#define GWL_WNDPROC GWLP_WNDPROC
+#endif
+#endif
+
 LPCSTR GHOST_WindowWin32::s_windowClassName = "GHOST_WindowClass";
 const int GHOST_WindowWin32::s_maxTitleLength = 128;
 HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;
@@ -874,12 +879,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;
 }