QMatrix4x4 and OpenGL
Hi,
I have two simple questions related to QMatrix4×4 :
1. Is this matrix OpenGL compliant? If not, is there an easy way converting it to OpenGL matrix (float array of dimesion 16)?
2. How is this matrix indexed, usual C/C++ notation starting from zero, eg Qmatrix4×4 m(0,0) = refers to the first element in the matrix row : 0 and column : 0)?
Thanks!
5 replies
Hi,I have two simple questions related to QMatrix4×4 :
1. Is this matrix OpenGL compliant? If not, is there an easy way converting it to OpenGL matrix (float array of dimesion 16)?
2. How is this matrix indexed, usual C/C++ notation starting from zero, eg Qmatrix4×4 m(0,0) = refers to the first element in the matrix row : 0 and column : 0)?Thanks!
Unfortunately, QMatrix4×4 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#line2188
Apart from this, internally QMatrix4×4 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).
You must log in to post a reply. Not a member yet? Register here!


