December 25, 2010

NorskQt NorskQt
Lab Rat
6 posts

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

December 25, 2010

Immii Immii
Ant Farmer
233 posts

QMatrix4×4 is transformation matrix in 3D space so you can use it where ever you want.

December 25, 2010

NorskQt NorskQt
Lab Rat
6 posts

Immii,

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

Any qualified answer, please?

Thanks.

December 25, 2010

peppe peppe
Ant Farmer
1025 posts

NorskQt wrote:
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).

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

December 26, 2010

NorskQt NorskQt
Lab Rat
6 posts

Hi Peppe,

Thank you very much for providing information about QMatrix4×4. 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.

March 30, 2011

bbuerger bbuerger
Lab Rat
1 posts

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

 
  ‹‹ [Solved] invalid conversion from ’char’ to ’char*’      qt custom widgets propertis are not getting updated properly in Qt designer ››

You must log in to post a reply. Not a member yet? Register here!