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.
This commit is contained in:
parent
db7a072c2b
commit
e49345872c
2 changed files with 74 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue