Support screen transformations in ES.

paintGenericScreen should be merged back to scene_opengl
This commit is contained in:
Martin Gräßlin 2010-12-04 12:54:05 +01:00 committed by Martin Gräßlin
parent ae81f23fbc
commit 9b37fc580d
2 changed files with 36 additions and 5 deletions

View file

@ -3,6 +3,7 @@ precision highp float;
#endif
uniform mat4 projection;
uniform mat4 modelview;
uniform mat4 screenTransformation;
uniform mat4 windowTransformation;
// passed in vertex - only x and y are used
@ -15,5 +16,5 @@ varying vec2 varyingTexCoords;
void main() {
varyingTexCoords = texCoord;
gl_Position = vertex*(windowTransformation*modelview)*projection;
gl_Position = vertex*(windowTransformation*screenTransformation*modelview)*projection;
}

View file

@ -208,11 +208,41 @@ void SceneOpenGL::flushBuffer( int mask, QRegion damage )
XFlush( display());
}
void SceneOpenGL::paintGenericScreen( int mask, ScreenPaintData data )
{
// TODO: setup shader for transformed geometry
Scene::paintGenericScreen( mask, data );
void SceneOpenGL::paintGenericScreen(int mask, ScreenPaintData data)
{
if (mask & PAINT_SCREEN_TRANSFORMED) {
// apply screen transformations
QMatrix4x4 screenTransformation;
screenTransformation.translate(data.xTranslate, data.yTranslate, data.zTranslate);
if (data.rotation) {
screenTransformation.translate(data.rotation->xRotationPoint, data.rotation->yRotationPoint, data.rotation->zRotationPoint);
// translate to rotation point, rotate, translate back
qreal xAxis = 0.0;
qreal yAxis = 0.0;
qreal zAxis = 0.0;
switch (data.rotation->axis) {
case RotationData::XAxis:
xAxis = 1.0;
break;
case RotationData::YAxis:
yAxis = 1.0;
break;
case RotationData::ZAxis:
zAxis = 1.0;
break;
}
screenTransformation.rotate(data.rotation->angle, xAxis, yAxis, zAxis);
screenTransformation.translate(-data.rotation->xRotationPoint, -data.rotation->yRotationPoint, -data.rotation->zRotationPoint);
}
screenTransformation.scale(data.xScale, data.yScale, data.zScale);
m_genericSceneShader->bind();
m_genericSceneShader->setUniform("screenTransformation", screenTransformation);
} else if ((mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS) || (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS)) {
m_genericSceneShader->bind();
m_genericSceneShader->setUniform("screenTransformation", QMatrix4x4());
}
Scene::paintGenericScreen(mask, data);
}
void SceneOpenGL::paintBackground( QRegion region )
{