diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-05-01 01:41:12 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-05-01 01:41:53 (GMT) |
commit | 79bc8f778f0b7b935ce3d808d8c91c3730f886bb (patch) | |
tree | ffe8356a7c1038af0c104fee1516ce4d84defcef /demos/boxes/glbuffers.cpp | |
parent | 1092ef425b9ed5835e4863c5ec32f9fc21af8d4d (diff) | |
download | Qt-79bc8f778f0b7b935ce3d808d8c91c3730f886bb.zip Qt-79bc8f778f0b7b935ce3d808d8c91c3730f886bb.tar.gz Qt-79bc8f778f0b7b935ce3d808d8c91c3730f886bb.tar.bz2 |
Port boxes demo to use math3d throughout
Patch originally by Ian Walters.
Diffstat (limited to 'demos/boxes/glbuffers.cpp')
-rw-r--r-- | demos/boxes/glbuffers.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/demos/boxes/glbuffers.cpp b/demos/boxes/glbuffers.cpp index b2a594e..a25a425 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); } |