Commit 0379afb7 authored by Martin Flöser's avatar Martin Flöser
Browse files

Add high-level functions for <push|pop|mult>Matrix.

All methods are no-ops for GLES which allows to use them from
effects without checks for GLES.
parent bbb80051
......@@ -318,6 +318,46 @@ void addQuadVertices(QVector<float>& verts, float x1, float y1, float x2, float
verts << x2 << y1;
}
void pushMatrix()
{
#ifndef KWIN_HAVE_OPENGLES
glPushMatrix();
#endif
}
void pushMatrix(const QMatrix4x4 &matrix)
{
#ifdef KWIN_HAVE_OPENGLES
Q_UNUSED(matrix)
#else
glPushMatrix();
multiplyMatrix(matrix);
#endif
}
void multiplyMatrix(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];
}
}
glMultMatrixf(m);
#endif
}
void popMatrix()
{
#ifndef KWIN_HAVE_OPENGLES
glPopMatrix();
#endif
}
//****************************************
// GLTexture
//****************************************
......
......@@ -125,6 +125,40 @@ KWIN_EXPORT void renderGLGeometryImmediate( int count,
**/
KWIN_EXPORT void addQuadVertices( QVector<float>& verts, float x1, float y1, float x2, float y2 );
/**
* Push a new matrix on the GL matrix stack.
* In GLES this method is a noop. This method should be preferred over glPushMatrix
* as it also handles GLES.
* @since 4.7
**/
KWIN_EXPORT void pushMatrix();
/**
* Multiplies current matrix on GL stack with @p matrix and pushes the result on the matrix stack.
* This method is the same as pushMatrix followed by multiplyMatrix.
* In GLES this method is a noop. This method should be preferred over glPushMatrix
* as it also handles GLES.
* @param matrix The matrix the current matrix on the stack should be multiplied with.
* @see pushMatrix
* @see multiplyMatrix
* @since 4.7
**/
KWIN_EXPORT void pushMatrix(const QMatrix4x4 &matrix);
/**
* Multiplies the current matrix on GL stack with @p matrix.
* In GLES this method is a noop. This method should be preferred over glMultMatrix
* as it also handles GLES.
* @param matrix The matrix the current matrix on the stack should be multiplied with.
* @since 4.7
**/
KWIN_EXPORT void multiplyMatrix(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
* as it also handles GLES.
* @since 4.7
**/
KWIN_EXPORT void popMatrix();
class KWIN_EXPORT GLTexture
: public QSharedData
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment