[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36070] trunk/blender/intern/ghost/intern/ GHOST_WindowWin32.cpp: Fix crash for Windows+Intel video card configuration
Sergey Sharybin
g.ulairi at gmail.com
Sat Apr 9 20:29:44 CEST 2011
Revision: 36070
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36070
Author: nazgul
Date: 2011-04-09 18:29:43 +0000 (Sat, 09 Apr 2011)
Log Message:
-----------
Fix crash for Windows+Intel video card configuration
Intel video cards don't work fine with multiple contexts and
have to share the same context for all windows. This could work
incorrect with multiple video cards configuration, so suppose
there'll be no such situation (Intel cards are mostly in portable
devices like notebooks and laptops, where there's actually no
dual video cards). Anyway, it should work much better now.
Non-Intel cards behavior was kept unchanged.
Thanks to Ton for debug session :)
Modified Paths:
--------------
trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
Modified: trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2011-04-09 11:16:37 UTC (rev 36069)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowWin32.cpp 2011-04-09 18:29:43 UTC (rev 36070)
@@ -105,6 +105,22 @@
0, 0, 0 /* no layer, visible, damage masks */
};
+/* Intel videocards don't work fine with multiple contexts and
+ have to share the same context for all windows.
+ But if we just share context for all windows it could work incorrect
+ with multiple videocards configuration. Suppose, that Intel videocards
+ can't be in multiple-devices configuration. */
+static int is_crappy_intel_card(void)
+{
+ int crappy = 0;
+ const char *vendor = (const char*)glGetString(GL_VENDOR);
+
+ if (strstr(vendor, "Intel"))
+ crappy = 1;
+
+ return crappy;
+}
+
GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_SystemWin32 * system,
const STR_String& title,
@@ -707,15 +723,22 @@
}
// Create the context
- m_hGlRc = ::wglCreateContext(m_hDC);
- if (m_hGlRc) {
- if (s_firsthGLRc) {
- ::wglCopyContext(s_firsthGLRc, m_hGlRc, GL_ALL_ATTRIB_BITS);
- wglShareLists(s_firsthGLRc, m_hGlRc);
- } else {
- s_firsthGLRc = m_hGlRc;
+ if (s_firsthGLRc && is_crappy_intel_card()) {
+ m_hGlRc = s_firsthGLRc;
+ } else {
+ m_hGlRc = ::wglCreateContext(m_hDC);
+
+ if (m_hGlRc) {
+ if (s_firsthGLRc) {
+ ::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;
}
else {
@@ -743,14 +766,21 @@
::DescribePixelFormat(m_hDC, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &preferredFormat);
// Create the context
- m_hGlRc = ::wglCreateContext(m_hDC);
- if (m_hGlRc) {
- if (s_firsthGLRc) {
- ::wglShareLists(s_firsthGLRc, m_hGlRc);
- } else {
- s_firsthGLRc = m_hGlRc;
+ if (s_firsthGLRc && is_crappy_intel_card()) {
+ m_hGlRc = s_firsthGLRc;
+ } else {
+ m_hGlRc = ::wglCreateContext(m_hDC);
+
+ if (m_hGlRc) {
+ if (s_firsthGLRc) {
+ ::wglShareLists(s_firsthGLRc, m_hGlRc);
+ } else {
+ s_firsthGLRc = m_hGlRc;
+ }
}
+ }
+ if (m_hGlRc) {
success = ::wglMakeCurrent(m_hDC, m_hGlRc) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
}
else {
More information about the Bf-blender-cvs
mailing list