From 5de53a53e66c8b195bb31cf47ea24507ff9dddfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 12 Oct 2006 21:12:13 +0000 Subject: [PATCH] A new way of adjusting opacity of non-alpha windows from glcompmgr, the alpha way doesn't work with TFP for some reason. svn path=/branches/work/kwin_composite/; revision=594941 --- scene_opengl.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index 67f590fc50..6e9df83c07 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -553,10 +553,23 @@ void SceneOpenGL::Window::draw() glTranslatef( glX(), glY(), depth ); if( toplevel->opacity() != 1.0 ) { - glEnable( GL_BLEND ); - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - glColor4f( toplevel->opacity(), toplevel->opacity(), toplevel->opacity(), - toplevel->opacity()); + if( toplevel->hasAlpha()) + { + glEnable( GL_BLEND ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + glColor4f( toplevel->opacity(), toplevel->opacity(), toplevel->opacity(), + toplevel->opacity()); + } + else + { + float constant_alpha[] = { 0, 0, 0, toplevel->opacity() }; + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); + glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE ); + glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE ); + glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE ); + glTexEnvi( GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_CONSTANT ); + glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant_alpha ); + } } glEnable( GL_TEXTURE_RECTANGLE_ARB ); glBegin( GL_QUADS );