diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-04-11 23:22:43 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-04-11 23:22:43 +0400 |
commit | e210d82f17c89b92e8c9c60ff059c9f1d644b155 (patch) | |
tree | 64e2d302039f22110b1994372657692c30a7d478 /intern | |
parent | 96995926283d99876882950ba05e0a0a01335a0a (diff) |
FIx crash when opening User Preferences even with NVidia card
This crash was discovered by Dalai and this happened because of
unset current context (as result of call wglMakeCurrent(NULL, NULL)).
In this case glGetString(GL_VENDOR) returns NULL. Rather than add check
for vendor != NULL before string comparison, I've changed a bit logic of
context creation:
- Create context and set it as current
- If it's crappy Intel card -- delete this context and
share the only one context between all Windows
- Otherwise, use initial logic (with sharing lists and so on)
This could also fix crash when opening userprefs from a menu with Intel card.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_WindowWin32.cpp | 92 |
1 files changed, 65 insertions, 27 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 9b98cb8c0ac..629338e70d8 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -723,28 +723,47 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp } // Create the context - if (s_firsthGLRc && is_crappy_intel_card()) { - m_hGlRc = s_firsthGLRc; - } else { - m_hGlRc = ::wglCreateContext(m_hDC); - - if (m_hGlRc) { + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { if (s_firsthGLRc) { - ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS); - ::wglShareLists(s_firsthGLRc, m_hGlRc); - } else { + if (is_crappy_intel_card()) { + if (::wglMakeCurrent(NULL, NULL) == TRUE) { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = s_firsthGLRc; + } + else { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = NULL; + } + } + else { + ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS); + ::wglShareLists(s_firsthGLRc, m_hGlRc); + } + } + else { s_firsthGLRc = m_hGlRc; } - } - } - if (m_hGlRc) { - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + if (m_hGlRc) { + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + success = GHOST_kFailure; + } + } + else { + success = GHOST_kFailure; + } } else { - printf("Failed to get a context....\n"); success = GHOST_kFailure; } + + if (success == GHOST_kFailure) { + printf("Failed to get a context....\n"); + } } else { @@ -766,27 +785,46 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp ::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat); // Create the context - if (s_firsthGLRc && is_crappy_intel_card()) { - m_hGlRc = s_firsthGLRc; - } else { - m_hGlRc = ::wglCreateContext(m_hDC); - - if (m_hGlRc) { + m_hGlRc = ::wglCreateContext(m_hDC); + if (m_hGlRc) { + if (::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE) { if (s_firsthGLRc) { - ::wglShareLists(s_firsthGLRc, m_hGlRc); - } else { + if (is_crappy_intel_card()) { + if (::wglMakeCurrent(NULL, NULL) == TRUE) { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = s_firsthGLRc; + } + else { + ::wglDeleteContext(m_hGlRc); + m_hGlRc = NULL; + } + } + else { + ::wglShareLists(s_firsthGLRc, m_hGlRc); + } + } + else { s_firsthGLRc = m_hGlRc; } - } - } - if (m_hGlRc) { - success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + if (m_hGlRc) { + success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure; + } + else { + success = GHOST_kFailure; + } + } + else { + success = GHOST_kFailure; + } } else { - printf("Failed to get a context....\n"); success = GHOST_kFailure; } + + if (success == GHOST_kFailure) { + printf("Failed to get a context....\n"); + } // Attempt to enable multisample if (m_multisample && WGL_ARB_multisample && !m_multisampleEnabled) |