Adding high-level method for glLoadMatrix

This commit is contained in:
Martin Gräßlin 2011-01-01 18:55:51 +01:00
parent e49345872c
commit efb82daf30
2 changed files with 24 additions and 0 deletions

View file

@ -351,6 +351,22 @@ void multiplyMatrix(const QMatrix4x4 &matrix)
#endif
}
void loadMatrix(const QMatrix4x4 &matrix)
{
#ifdef KWIN_HAVE_OPENGLES
Q_UNUSED(matrix)
#else
GLfloat m[16];
const qreal *data = matrix.constData();
for (int i = 0; i < 4; ++i) {
for (int j=0; j < 4; ++j) {
m[i*4+j] = data[i*4+j];
}
}
glLoadMatrixf(m);
#endif
}
void popMatrix()
{
#ifndef KWIN_HAVE_OPENGLES

View file

@ -151,6 +151,14 @@ KWIN_EXPORT void pushMatrix(const QMatrix4x4 &matrix);
* @since 4.7
**/
KWIN_EXPORT void multiplyMatrix(const QMatrix4x4 &matrix);
/**
* Replaces the current matrix on GL stack with @p matrix.
* In GLES this method is a no-op. This method should be preferred over glLoadMatrix
* as it also handles GLES.
* @param matrix The new matrix to replace the existing one on the GL stack.
* @since 4.7
**/
KWIN_EXPORT void loadMatrix(const QMatrix4x4 &matrix);
/**
* Pops the current matrix from the GL matrix stack.
* In GLES this method is a noop. This method should be preferred over glPopMatrix