QMatrix4x4 and OpenGL
-
Hi,
I have two simple questions related to QMatrix4x4 :
- Is this matrix OpenGL compliant? If not, is there an easy way converting it to OpenGL matrix (float array of dimesion 16)?
- How is this matrix indexed, usual C/C++ notation starting from zero, eg Qmatrix4x4 m(0,0) = refers to the first element in the matrix row : 0 and column : 0)?
Thanks!
-
[quote author="NorskQt" date="1293299650"]Hi,
I have two simple questions related to QMatrix4x4 :
- Is this matrix OpenGL compliant? If not, is there an easy way converting it to OpenGL matrix (float array of dimesion 16)?
- How is this matrix indexed, usual C/C++ notation starting from zero, eg Qmatrix4x4 m(0,0) = refers to the first element in the matrix row : 0 and column : 0)?
Thanks![/quote]
Unfortunately, QMatrix4x4 is a matrix of 16 qreals, which may or may not be GL_FLOAT -- and usually they are not, since qreal is double everywhere except on ARM, and GL_FLOAT is float everywhere. Qt uses some internal macros to do the job: see for instance
http://qt.gitorious.com/qt/qt/blobs/master/src/opengl/qglshaderprogram.cpp#line2188Apart from this, internally QMatrix4x4 is a qreal[ 4 ][ 4 ] packed in column-major order (i.e. operator()(x, y) will assign to data[y][x], matching OpenGL), so the first element is indeed (0, 0).
-
Hi Peppe,
Thank you very much for providing information about QMatrix4x4. It's a kind of strange though because Qt works with OpenGL and Qt's 3D-graphics matrix is not OpenGL compliant. This is something that the Qt developers should consider.
Thank you very much again.