Better support custom shaders.
This commit is contained in:
parent
6cd6883d8c
commit
f78d838fc7
2 changed files with 26 additions and 18 deletions
|
@ -592,21 +592,23 @@ void GLTexture::render( QRegion region, const QRect& rect )
|
|||
};
|
||||
m_vbo->setData( 4, 2, verts, texcoords );
|
||||
}
|
||||
QMatrix4x4 translation;
|
||||
translation.translate(rect.x(), rect.y());
|
||||
if (ShaderManager::instance()->isShaderBound()) {
|
||||
GLShader *shader = ShaderManager::instance()->getBoundShader();
|
||||
shader->setUniform("offset", QVector2D(rect.x(), rect.y()));
|
||||
shader->setUniform("windowTransformation", translation);
|
||||
shader->setUniform("textureWidth", 1.0f);
|
||||
shader->setUniform("textureHeight", 1.0f);
|
||||
} else {
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
glTranslatef( rect.x(), rect.y(), 0.0f );
|
||||
#endif
|
||||
pushMatrix(translation);
|
||||
}
|
||||
m_vbo->render( region, GL_TRIANGLE_STRIP );
|
||||
if (!ShaderManager::instance()->isShaderBound()) {
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
glTranslatef( -rect.x(), -rect.y(), 0.0f );
|
||||
#endif
|
||||
if (ShaderManager::instance()->isShaderBound()) {
|
||||
GLShader *shader = ShaderManager::instance()->getBoundShader();
|
||||
shader->setUniform("windowTransformation", QMatrix4x4());
|
||||
} else {
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -574,7 +574,7 @@ void SceneOpenGL::Window::performPaint( int mask, QRegion region, WindowPaintDat
|
|||
windowTransformation.rotate(data.rotation->angle, xAxis, yAxis, zAxis);
|
||||
windowTransformation.translate(-data.rotation->xRotationPoint, -data.rotation->yRotationPoint, -data.rotation->zRotationPoint);
|
||||
}
|
||||
if (sceneShader) {
|
||||
if (data.shader) {
|
||||
data.shader->setUniform("windowTransformation", windowTransformation);
|
||||
}
|
||||
}
|
||||
|
@ -1202,12 +1202,12 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
|
|||
{
|
||||
shader = ShaderManager::instance()->pushShader(ShaderManager::SimpleShader);
|
||||
sceneShader = true;
|
||||
}
|
||||
if( shader )
|
||||
{
|
||||
if (shader != ShaderManager::instance()->getBoundShader()) {
|
||||
} else if (shader) {
|
||||
ShaderManager::instance()->pushShader(shader);
|
||||
}
|
||||
|
||||
if( shader )
|
||||
{
|
||||
if( sceneShader )
|
||||
shader->setUniform("offset", QVector2D(0, 0));
|
||||
shader->setUniform("saturation", 1.0f);
|
||||
|
@ -1353,16 +1353,22 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
|
|||
if (sceneShader) {
|
||||
shader->setUniform("offset", QVector2D(pt.x(), pt.y()));
|
||||
} else {
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
glTranslatef( pt.x(), pt.y(), 0.0f );
|
||||
#endif
|
||||
QMatrix4x4 translation;
|
||||
translation.translate(pt.x(), pt.y());
|
||||
if (shader) {
|
||||
shader->setUniform("windowTransformation", translation);
|
||||
} else {
|
||||
pushMatrix(translation);
|
||||
}
|
||||
}
|
||||
m_unstyledVBO->render( region, GL_TRIANGLES );
|
||||
#ifndef KWIN_HAVE_OPENGLES
|
||||
if (!sceneShader) {
|
||||
glTranslatef( -pt.x(), -pt.y(), 0.0f );
|
||||
if (shader) {
|
||||
shader->setUniform("windowTranslation", QMatrix4x4());
|
||||
} else {
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
m_unstyledTexture->unbind();
|
||||
}
|
||||
else if( m_effectFrame->style() == EffectFrameStyled )
|
||||
|
|
Loading…
Reference in a new issue