summaryrefslogtreecommitdiffstats
path: root/demos/boxes/glbuffers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'demos/boxes/glbuffers.cpp')
-rw-r--r--demos/boxes/glbuffers.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/demos/boxes/glbuffers.cpp b/demos/boxes/glbuffers.cpp
index 69d7ad8..a3d26f6 100644
--- a/demos/boxes/glbuffers.cpp
+++ b/demos/boxes/glbuffers.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "glbuffers.h"
+#include <QtGui/qmatrix4x4.h>
//============================================================================//
// GLTexture //
@@ -346,7 +347,7 @@ void GLRenderTargetCube::end()
m_fbo.setAsRenderTarget(false);
}
-void GLRenderTargetCube::getViewMatrix(gfx::Matrix4x4f& mat, int face)
+void GLRenderTargetCube::getViewMatrix(QMatrix4x4& mat, int face)
{
if (face < 0 || face >= 6) {
qWarning("GLRenderTargetCube::getViewMatrix: 'face' must be in the range [0, 6). (face == %d)", face);
@@ -371,20 +372,21 @@ void GLRenderTargetCube::getViewMatrix(gfx::Matrix4x4f& mat, int face)
{-1.0f, -1.0f, +1.0f},
};
- memset(mat.bits(), 0, sizeof(float) * 16);
+ memset(mat.data(), 0, sizeof(float) * 16);
for (int i = 0; i < 3; ++i)
- mat(perm[face][i], i) = signs[face][i];
+ mat(i, perm[face][i]) = signs[face][i];
mat(3, 3) = 1.0f;
}
-void GLRenderTargetCube::getProjectionMatrix(gfx::Matrix4x4f& mat, float nearZ, float farZ)
+void GLRenderTargetCube::getProjectionMatrix(QMatrix4x4& mat, float nearZ, float farZ)
{
- float proj[] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, (nearZ+farZ)/(nearZ-farZ), -1.0f,
- 0.0f, 0.0f, 2.0f*nearZ*farZ/(nearZ-farZ), 0.0f,
- };
-
- memcpy(mat.bits(), proj, sizeof(float) * 16);
+ static const QMatrix4x4 reference(
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, -1.0f, 0.0f);
+
+ mat = reference;
+ mat(2, 2) = (nearZ+farZ)/(nearZ-farZ);
+ mat(2, 3) = 2.0f*nearZ*farZ/(nearZ-farZ);
}