forked from bartvdbraak/blender
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 :)
This commit is contained in:
parent
5457c871ef
commit
66cee63665
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user