From efb82daf30324a91ec638e4e8358b6e2abbe6430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 1 Jan 2011 18:55:51 +0100 Subject: [PATCH] Adding high-level method for glLoadMatrix --- lib/kwinglutils.cpp | 16 ++++++++++++++++ lib/kwinglutils.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/kwinglutils.cpp b/lib/kwinglutils.cpp index fc82b2c54a..3338919a9e 100644 --- a/lib/kwinglutils.cpp +++ b/lib/kwinglutils.cpp @@ -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 diff --git a/lib/kwinglutils.h b/lib/kwinglutils.h index e50deab132..4897a9f42a 100644 --- a/lib/kwinglutils.h +++ b/lib/kwinglutils.h @@ -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