Support screen transformations in ES.
paintGenericScreen should be merged back to scene_opengl
This commit is contained in:
parent
ae81f23fbc
commit
9b37fc580d
2 changed files with 36 additions and 5 deletions
|
@ -3,6 +3,7 @@ precision highp float;
|
||||||
#endif
|
#endif
|
||||||
uniform mat4 projection;
|
uniform mat4 projection;
|
||||||
uniform mat4 modelview;
|
uniform mat4 modelview;
|
||||||
|
uniform mat4 screenTransformation;
|
||||||
uniform mat4 windowTransformation;
|
uniform mat4 windowTransformation;
|
||||||
|
|
||||||
// passed in vertex - only x and y are used
|
// passed in vertex - only x and y are used
|
||||||
|
@ -15,5 +16,5 @@ varying vec2 varyingTexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
varyingTexCoords = texCoord;
|
varyingTexCoords = texCoord;
|
||||||
gl_Position = vertex*(windowTransformation*modelview)*projection;
|
gl_Position = vertex*(windowTransformation*screenTransformation*modelview)*projection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,11 +208,41 @@ void SceneOpenGL::flushBuffer( int mask, QRegion damage )
|
||||||
XFlush( display());
|
XFlush( display());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneOpenGL::paintGenericScreen( int mask, ScreenPaintData data )
|
void SceneOpenGL::paintGenericScreen(int mask, ScreenPaintData data)
|
||||||
{
|
{
|
||||||
// TODO: setup shader for transformed geometry
|
if (mask & PAINT_SCREEN_TRANSFORMED) {
|
||||||
Scene::paintGenericScreen( mask, data );
|
// 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 )
|
void SceneOpenGL::paintBackground( QRegion region )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue