From 5245ef9e10b826b355f91c2435dd2236f8908855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Tue, 7 Nov 2006 22:04:57 +0000 Subject: [PATCH] In non-tfp mode, a different context must be used when doing opengl operations with the window drawable. Patch by Philip Falkner. svn path=/branches/work/kwin_composite/; revision=603122 --- scene_opengl.cpp | 15 +++++++++------ scene_opengl.h | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 68dfc32068..b005d423b7 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -74,7 +74,8 @@ namespace KWinInternal // the config used for windows GLXFBConfig SceneOpenGL::fbcdrawable; // GLX content -GLXContext SceneOpenGL::context; +GLXContext SceneOpenGL::ctxroot; +GLXContext SceneOpenGL::ctxdrawable; // the destination drawable where the compositing is done GLXDrawable SceneOpenGL::glxroot; bool SceneOpenGL::tfp_mode; // using glXBindTexImageEXT (texture_from_pixmap) @@ -198,8 +199,9 @@ SceneOpenGL::SceneOpenGL( Workspace* ws ) else if( !findConfig( drawable_attrs, fbcdrawable )) assert( false ); - context = glXCreateNewContext( display(), fbcroot, GLX_RGBA_TYPE, NULL, GL_FALSE ); - glXMakeContextCurrent( display(), glxroot, glxroot, context ); + ctxroot = glXCreateNewContext( display(), fbcroot, GLX_RGBA_TYPE, NULL, GL_FALSE ); + ctxdrawable = glXCreateNewContext( display(), fbcdrawable, GLX_RGBA_TYPE, ctxroot, GL_FALSE ); + glXMakeContextCurrent( display(), glxroot, glxroot, ctxroot ); // OpenGL scene setup glMatrixMode( GL_PROJECTION ); glLoadIdentity(); @@ -224,7 +226,8 @@ SceneOpenGL::~SceneOpenGL() XFreeGC( display(), gcroot ); XFreePixmap( display(), buffer ); } - glXDestroyContext( display(), context ); + glXDestroyContext( display(), ctxroot ); + glXDestroyContext( display(), ctxdrawable ); checkGLError( "Cleanup" ); } @@ -522,7 +525,7 @@ void SceneOpenGL::Window::bindTexture() else { // non-tfp case, copy pixmap contents to a texture GLXDrawable pixmap = glXCreatePixmap( display(), fbcdrawable, pix, NULL ); - glXMakeContextCurrent( display(), pixmap, pixmap, context ); + glXMakeContextCurrent( display(), pixmap, pixmap, ctxdrawable ); glReadBuffer( GL_FRONT ); glDrawBuffer( GL_FRONT ); if( texture == None ) @@ -558,7 +561,7 @@ void SceneOpenGL::Window::bindTexture() XFreePixmap( display(), pix ); if( root_db ) glDrawBuffer( GL_BACK ); - glXMakeContextCurrent( display(), glxroot, glxroot, context ); + glXMakeContextCurrent( display(), glxroot, glxroot, ctxroot ); } if( copy_buffer ) XFreePixmap( display(), window_pix ); diff --git a/scene_opengl.h b/scene_opengl.h index 515121e6ad..54c4a7d7e8 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -45,7 +45,8 @@ class SceneOpenGL static bool root_db; static GLXFBConfig fbcdrawable; static GLXDrawable glxroot; - static GLXContext context; + static GLXContext ctxroot; + static GLXContext ctxdrawable; static bool tfp_mode; static bool copy_buffer_hack; class Window;