Commit: a6ebc9a813fab5e3d56b347b763ce4e99704e69e
Author: Joshua Leung
Date:   Fri Feb 27 13:12:21 2015 +1300
Branches: master
https://developer.blender.org/rBa6ebc9a813fab5e3d56b347b763ce4e99704e69e

Compile fixes for mingw64

* m_hDC was always included after m_hWnd in all the constructors and other 
functions,
  but the order was reversed in the struct, meaning that they would not get 
initialised
  correctly

* Got rid of the gotos for the error handling case in initializeDrawingContext()
  This was causing "jump to label ... crosses initialisation" errors for the 
calls
  to get GL version string info (i.e. const char *vendor = ...;  etc.)  I 
wasn't sure
  if those glGetString calls needed the rest of the context to be defined 
first, so
  I decided to leave them where they are now, and got rid of the gotos (which 
were
  making this particular piece of code a bit confusing) instead.


TODO:
There are still a bunch of warnings about around 660, which I haven't managed 
to solve
(but at least they won't prevent Blender from compiling)

  narrowing conversion of '(stereoVisual ? 1063 : 1061)' from 'int' to
  'DWORD {aka long unsigned int}' inside { } is ill-formed in C++11 
[-Wnarrowing]

===================================================================

M       intern/ghost/intern/GHOST_ContextWGL.cpp
M       intern/ghost/intern/GHOST_ContextWGL.h

===================================================================

diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp 
b/intern/ghost/intern/GHOST_ContextWGL.cpp
index c6e0338..0557374 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -733,13 +733,17 @@ GHOST_TSuccess 
GHOST_ContextWGL::initializeDrawingContext()
 
        iPixelFormat = choose_pixel_format(m_stereoVisual, m_numOfAASamples, 
needAlpha, needStencil, sRGB);
 
-       if (iPixelFormat == 0)
-               goto error;
+       if (iPixelFormat == 0) {
+               ::wglMakeCurrent(prevHDC, prevHGLRC);
+               return GHOST_kFailure;
+       }
 
        lastPFD = ::DescribePixelFormat(m_hDC, iPixelFormat, 
sizeof(PIXELFORMATDESCRIPTOR), &chosenPFD);
 
-       if (!WIN32_CHK(lastPFD != 0))
-               goto error;
+       if (!WIN32_CHK(lastPFD != 0)) {
+               ::wglMakeCurrent(prevHDC, prevHGLRC);
+               return GHOST_kFailure;
+       }
 
        if (needAlpha && chosenPFD.cAlphaBits == 0)
                fprintf(stderr, "Warning! Unable to find a pixel format with an 
alpha channel.\n");
@@ -747,8 +751,10 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
        if (needStencil && chosenPFD.cStencilBits == 0)
                fprintf(stderr, "Warning! Unable to find a pixel format with a 
stencil buffer.\n");
 
-       if (!WIN32_CHK(::SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD)))
-               goto error;
+       if (!WIN32_CHK(::SetPixelFormat(m_hDC, iPixelFormat, &chosenPFD))) {
+               ::wglMakeCurrent(prevHDC, prevHGLRC);
+               return GHOST_kFailure;
+       }
 
        activateWGLEW();
 
@@ -845,19 +851,25 @@ GHOST_TSuccess 
GHOST_ContextWGL::initializeDrawingContext()
                        m_hGLRC = s_sharedHGLRC;
        }
 
-       if (!WIN32_CHK(m_hGLRC != NULL))
-               goto error;
+       if (!WIN32_CHK(m_hGLRC != NULL)) {
+               ::wglMakeCurrent(prevHDC, prevHGLRC);
+               return GHOST_kFailure;
+       }
 
        if (s_sharedHGLRC == NULL)
                s_sharedHGLRC = m_hGLRC;
 
        s_sharedCount++;
 
-       if (!s_singleContextMode && s_sharedHGLRC != m_hGLRC && 
!WIN32_CHK(::wglShareLists(s_sharedHGLRC, m_hGLRC)))
-               goto error;
+       if (!s_singleContextMode && s_sharedHGLRC != m_hGLRC && 
!WIN32_CHK(::wglShareLists(s_sharedHGLRC, m_hGLRC))) {
+               ::wglMakeCurrent(prevHDC, prevHGLRC);
+               return GHOST_kFailure;
+       }
 
-       if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC)))
-               goto error;
+       if (!WIN32_CHK(::wglMakeCurrent(m_hDC, m_hGLRC))) {
+               ::wglMakeCurrent(prevHDC, prevHGLRC);
+               return GHOST_kFailure;
+       }
 
        initContextGLEW();
 
@@ -898,11 +910,6 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
        }
 
        return GHOST_kSuccess;
-
-error:
-       ::wglMakeCurrent(prevHDC, prevHGLRC);
-
-       return GHOST_kFailure;
 }
 
 
diff --git a/intern/ghost/intern/GHOST_ContextWGL.h 
b/intern/ghost/intern/GHOST_ContextWGL.h
index 63496d2..9f4f6fa 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.h
+++ b/intern/ghost/intern/GHOST_ContextWGL.h
@@ -160,8 +160,8 @@ private:
 
        void initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD);
 
-       HDC  m_hDC;
        HWND m_hWnd;
+       HDC  m_hDC;
 
        const int m_contextProfileMask;
        const int m_contextMajorVersion;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to