From a35cf8e9547f51394927781c2d4d321ce0c351bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 16 Nov 2006 09:02:03 +0000 Subject: [PATCH] Try to use direct rendering. svn path=/branches/work/kwin_composite/; revision=605288 --- scene_opengl.cpp | 31 ++++++++++++++++++++++++++----- scene_opengl.h | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) 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;