[effects] Use shader traits for CoverSwitch reflection shader

icc-effect-5.14.5
Martin Gräßlin 2015-11-30 15:48:14 +01:00
parent 9fcedcc2f8
commit a5e86c66bf
3 changed files with 11 additions and 7 deletions

View File

@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "coverswitchconfig.h"
#include <kwinconfig.h>
#include <QFile>
#include <QFont>
#include <QIcon>
#include <QMatrix4x4>
@ -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

View File

@ -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;
}

View File

@ -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;
}