From 802dd6b5fe5b1b7549cfbd0bfb6526377ba3f3a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 1 Jan 2011 19:34:16 +0100 Subject: [PATCH] Cache the matrix for cube cap mirroring --- effects/cube/cube.cpp | 7 +++---- effects/cube/cube.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index e3654cf299..aee9ad8ca4 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -99,6 +99,8 @@ CubeEffect::CubeEffect() m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); const QString capshader = KGlobal::dirs()->findResource("data", "kwin/cube-cap.glsl"); m_capShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, capshader); + m_textureMirrorMatrix.scale(1.0, -1.0, 1.0); + m_textureMirrorMatrix.translate(0.0, -1.0, 0.0); reconfigure( ReconfigureAll ); } @@ -819,11 +821,8 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) #ifndef KWIN_HAVE_OPENGLES glMatrixMode( GL_TEXTURE ); #endif - QMatrix4x4 textureMirrorMatrix; - textureMirrorMatrix.scale(1.0, -1.0, 1.0); - textureMirrorMatrix.translate(0.0, -1.0, 0.0); pushMatrix(); - loadMatrix(textureMirrorMatrix); + loadMatrix(m_textureMirrorMatrix); #ifndef KWIN_HAVE_OPENGLES glMatrixMode( GL_MODELVIEW ); diff --git a/effects/cube/cube.h b/effects/cube/cube.h index 1a546f38c0..71c4bc321e 100644 --- a/effects/cube/cube.h +++ b/effects/cube/cube.h @@ -167,6 +167,7 @@ class CubeEffect QMatrix4x4 m_rotationMatrix; QMatrix4x4 m_reflectionMatrix; + QMatrix4x4 m_textureMirrorMatrix; GLVertexBuffer *m_cubeCapBuffer; // Shortcuts - needed to toggle the effect