Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMatrix4x4 and OpenGL
Qt 6.11 is out! See what's new in the release blog

QMatrix4x4 and OpenGL

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 7.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NorskQt
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • I Offline
      I Offline
      Immii
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NorskQt
        wrote on last edited by
        #3

        Immii,

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

        Any qualified answer, please?

        Thanks.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          [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).

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

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NorskQt
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bbuerger
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved