Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMatrix4x4 and OpenGL



  • Hi,

    I have two simple questions related to QMatrix4x4 :

    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 Qmatrix4x4 m(0,0) = refers to the first element in the matrix row : 0 and column : 0)?

    Thanks!



  • QMatrix4x4 is transformation matrix in 3D space so you can use it where ever you want.



  • Immii,

    You sound like you have not been working with 3D graphics.

    Any qualified answer, please?

    Thanks.



  • [quote author="NorskQt" date="1293299650"]Hi,

    I have two simple questions related to QMatrix4x4 :

    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 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#line2188

    Apart 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.



  • Hi there,

    correct my if I'm wrong but opengl can be used with floats.
    Just use gl...d instead of the gl...f in these case glLoadMatrixd

    Greetings,
    bbuerger


Log in to reply