Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-04-09 22:29:43 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-04-09 22:29:43 +0400
commit66cee6366587989dce4d9be782a1086a941cad0a (patch)
treeab57a00d1861021ed95a2cf2427a18d9029a1899 /intern
parent5457c871ef71f69e9a17b9dcb462becf86c41577 (diff)
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 :)
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp56
1 files changed, 43 insertions, 13 deletions
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index 0a660161cde..9b98cb8c0ac 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -105,6 +105,22 @@ static PIXELFORMATDESCRIPTOR sPreferredFormat = {
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 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp
}
// 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 @@ GHOST_TSuccess GHOST_WindowWin32::installDrawingContext(GHOST_TDrawingContextTyp
::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 {