diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 2944b6ca58..201a3a6781 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -188,11 +188,7 @@ SceneOpenGL::SceneOpenGL( Workspace* ws ) glXGetFBConfigAttrib( display(), fbcdrawable, GLX_VISUAL_ID, &vis_drawable ); kDebug() << "Buffer visual: 0x" << QString::number( vis_buffer, 16 ) << ", drawable visual: 0x" << QString::number( vis_drawable, 16 ) << endl; - ctxbuffer = glXCreateNewContext( display(), fbcbuffer, GLX_RGBA_TYPE, NULL, GL_FALSE ); - if( !tfp_mode && !shm_mode ) - ctxdrawable = glXCreateNewContext( display(), fbcdrawable, GLX_RGBA_TYPE, ctxbuffer, GL_FALSE ); - if( !glXMakeContextCurrent( display(), glxbuffer, glxbuffer, ctxbuffer ) ) - assert( false ); + initRenderingContext(); // Initialize OpenGL initGL(); @@ -293,6 +289,31 @@ void SceneOpenGL::cleanupShm() #endif } +void SceneOpenGL::initRenderingContext() + { + bool direct_rendering = true; + KXErrorHandler errs; + ctxbuffer = glXCreateNewContext( display(), fbcbuffer, GLX_RGBA_TYPE, NULL, + direct_rendering ? GL_TRUE : GL_FALSE ); + if( ctxbuffer == NULL || !glXMakeContextCurrent( display(), glxbuffer, glxbuffer, ctxbuffer ) + || errs.error( true )) + { // failed + if( !direct_rendering ) + assert( false ); + glXDestroyContext( display(), ctxbuffer ); + direct_rendering = false; // try again + ctxbuffer = glXCreateNewContext( display(), fbcbuffer, GLX_RGBA_TYPE, NULL, GL_FALSE ); + if( ctxbuffer == NULL || !glXMakeContextCurrent( display(), glxbuffer, glxbuffer, ctxbuffer )) + assert( false ); + } + if( !tfp_mode && !shm_mode ) + { + ctxdrawable = glXCreateNewContext( display(), fbcdrawable, GLX_RGBA_TYPE, ctxbuffer, + direct_rendering ? GL_TRUE : GL_FALSE ); + } + kDebug() << "Direct rendering:" << direct_rendering << endl; + } + // create destination buffer void SceneOpenGL::initBuffer() { diff --git a/scene_opengl.h b/scene_opengl.h index d45682c0ff..335a2698f4 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -41,6 +41,7 @@ class SceneOpenGL bool initShm(); void cleanupShm(); void initBuffer(); + void initRenderingContext(); bool findConfig( const int* attrs, GLXFBConfig* config, VisualID visual = None ); typedef GLuint Texture; GC gcroot;