diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 17b223be3c..dfce08f099 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -67,16 +67,20 @@ CoverSwitchEffect::CoverSwitchEffect() captionFont.setBold(true); captionFont.setPointSize(captionFont.pointSize() * 2); - QString shadersDir = "kwin/shaders/1.10/"; + if (effects->compositingType() == OpenGL2Compositing) { + QString shadersDir = "kwin/shaders/1.10/"; #ifdef KWIN_HAVE_OPENGLES - const qint64 coreVersionNumber = kVersionNumber(3, 0); + const qint64 coreVersionNumber = kVersionNumber(3, 0); #else - const qint64 coreVersionNumber = kVersionNumber(1, 40); + const qint64 coreVersionNumber = kVersionNumber(1, 40); #endif - if (GLPlatform::instance()->glslVersion() >= coreVersionNumber) - shadersDir = "kwin/shaders/1.40/"; - const QString fragmentshader = KGlobal::dirs()->findResource("data", shadersDir + "coverswitch-reflection.glsl"); - m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); + if (GLPlatform::instance()->glslVersion() >= coreVersionNumber) + shadersDir = "kwin/shaders/1.40/"; + const QString fragmentshader = KGlobal::dirs()->findResource("data", shadersDir + "coverswitch-reflection.glsl"); + m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); + } else { + m_reflectionShader = NULL; + } connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int))); connect(effects, SIGNAL(tabBoxClosed()), this, SLOT(slotTabBoxClosed())); @@ -309,7 +313,7 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d glScissor(area.x(), y, area.width(), area.height()); glEnable(GL_SCISSOR_TEST); - if (shaderManager->isValid() && m_reflectionShader->isValid()) { + if (shaderManager->isValid() && m_reflectionShader && m_reflectionShader->isValid()) { shaderManager->pushShader(m_reflectionShader); QMatrix4x4 windowTransformation; windowTransformation.translate(area.x() + area.width() * 0.5f, 0.0, 0.0); diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index ace1428769..ce6587c6a5 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -108,10 +108,15 @@ CubeEffect::CubeEffect() if (GLPlatform::instance()->glslVersion() >= coreVersionNumber) m_shadersDir = "kwin/shaders/1.40/"; - const QString fragmentshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-reflection.glsl"); - m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); - const QString capshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-cap.glsl"); - m_capShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, capshader); + if (effects->compositingType() == OpenGL2Compositing) { + const QString fragmentshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-reflection.glsl"); + m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); + const QString capshader = KGlobal::dirs()->findResource("data", m_shadersDir + "cube-cap.glsl"); + m_capShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, capshader); + } else { + m_reflectionShader = NULL; + m_capShader = NULL; + } m_textureMirrorMatrix.scale(1.0, -1.0, 1.0); m_textureMirrorMatrix.translate(0.0, -1.0, 0.0); connect(effects, SIGNAL(tabBoxAdded(int)), this, SLOT(slotTabBoxAdded(int))); @@ -219,7 +224,7 @@ void CubeEffect::reconfigure(ReconfigureFlags) } // set the cap color on the shader - if (m_capShader->isValid()) { + if (m_capShader && m_capShader->isValid()) { ShaderBinder binder(m_capShader); m_capShader->setUniform("u_capColor", capColor); } @@ -485,7 +490,7 @@ void CubeEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ShaderManager *shaderManager = ShaderManager::instance(); - if (shaderManager->isValid() && m_reflectionShader->isValid()) { + if (shaderManager->isValid() && m_reflectionShader && m_reflectionShader->isValid()) { // ensure blending is enabled - no attribute stack ShaderBinder binder(m_reflectionShader); QMatrix4x4 windowTransformation; @@ -771,7 +776,7 @@ void CubeEffect::paintCap(bool frontFirst, float zOffset) } bool capShader = false; - if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) { + if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) { capShader = true; ShaderManager::instance()->pushShader(m_capShader); float opacity = cubeOpacity; @@ -1544,7 +1549,7 @@ void CubeEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPa } } bool capShader = false; - if (effects->compositingType() == OpenGL2Compositing && m_capShader->isValid()) { + if (effects->compositingType() == OpenGL2Compositing && m_capShader && m_capShader->isValid()) { capShader = true; ShaderManager::instance()->pushShader(m_capShader); m_capShader->setUniform("u_mirror", 0);