diff --git a/effects/coverswitch/coverswitch.cpp b/effects/coverswitch/coverswitch.cpp index 74799e60f3..12c6e793c5 100644 --- a/effects/coverswitch/coverswitch.cpp +++ b/effects/coverswitch/coverswitch.cpp @@ -22,6 +22,7 @@ along with this program. If not, see . #include "coverswitchconfig.h" #include +#include #include #include #include @@ -65,7 +66,10 @@ CoverSwitchEffect::CoverSwitchEffect() if (GLPlatform::instance()->glslVersion() >= coreVersionNumber) shadersDir = QStringLiteral("kwin/shaders/1.40/"); const QString fragmentshader = QStandardPaths::locate(QStandardPaths::GenericDataLocation, shadersDir + QStringLiteral("coverswitch-reflection.glsl")); - m_reflectionShader = ShaderManager::instance()->loadFragmentShader(ShaderManager::GenericShader, fragmentshader); + QFile ff(fragmentshader); + if (ff.open(QIODevice::ReadOnly)) { + m_reflectionShader = ShaderManager::instance()->generateCustomShader(ShaderTrait::MapTexture, QByteArray(), ff.readAll()); + } } else { m_reflectionShader = NULL; } @@ -238,9 +242,9 @@ void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& d if (m_reflectionShader && m_reflectionShader->isValid()) { ShaderManager::instance()->pushShader(m_reflectionShader); - QMatrix4x4 windowTransformation; + QMatrix4x4 windowTransformation = data.projectionMatrix(); windowTransformation.translate(area.x() + area.width() * 0.5f, 0.0, 0.0); - m_reflectionShader->setUniform("windowTransformation", windowTransformation); + m_reflectionShader->setUniform(GLShader::ModelViewProjectionMatrix, windowTransformation); m_reflectionShader->setUniform("u_frontColor", QVector4D(mirrorColor[0][0], mirrorColor[0][1], mirrorColor[0][2], mirrorColor[0][3])); m_reflectionShader->setUniform("u_backColor", QVector4D(mirrorColor[1][0], mirrorColor[1][1], mirrorColor[1][2], mirrorColor[1][3])); // TODO: make this one properly diff --git a/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl b/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl index bce5b7557d..2d67397b6c 100644 --- a/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl +++ b/effects/coverswitch/shaders/1.10/coverswitch-reflection.glsl @@ -1,9 +1,9 @@ uniform vec4 u_frontColor; uniform vec4 u_backColor; -varying vec2 varyingTexCoords; +varying vec2 texcoord0; void main() { - gl_FragColor = u_frontColor*(1.0-varyingTexCoords.s) + u_backColor*varyingTexCoords.s; + gl_FragColor = u_frontColor*(1.0-texcoord0.s) + u_backColor*texcoord0.s; } diff --git a/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl b/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl index 7b45a4fac8..720d24a110 100644 --- a/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl +++ b/effects/coverswitch/shaders/1.40/coverswitch-reflection.glsl @@ -2,11 +2,11 @@ uniform vec4 u_frontColor; uniform vec4 u_backColor; -in vec2 varyingTexCoords; +in vec2 texcoord0; out vec4 fragColor; void main() { - fragColor = u_frontColor*(1.0-varyingTexCoords.s) + u_backColor*varyingTexCoords.s; + fragColor = u_frontColor*(1.0-texcoord0.s) + u_backColor*texcoord0.s; }