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. Matrix to double??
Forum Update on Monday, May 27th 2025

Matrix to double??

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.1k Views
  • 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.
  • M Offline
    M Offline
    Mue22
    wrote on last edited by Mue22
    #1

    I want to get Matrix data to double pointer.

    in opengl, glLoadMatrix(GLdouble*m); <<< i want to use this, m is matrix info.

    i use QMatrix4x4.

    i can make my matrix, but, i can't understand matrix to double*.....

    why not double*[16]??? so i cant use glLoadMatrix()...:(

    i can&#x27;t use english well...

    1 Reply Last reply
    0
    • jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      As explained here https://www.opengl.org/sdk/docs/man2/xhtml/glLoadMatrix.xml
      the pointer should point to 16 doubles (m[0]..m[15]), not one double.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by Chris Kawa
        #3

        QMatrix4x4 uses floats to store the data, so you can use it with raw OpenGL like this:

        QMatrix4x4 someMatrix;
        glLoadMatrixf(someMatrix.constData());
        
        1 Reply Last reply
        0
        • jsulmJ jsulm

          As explained here https://www.opengl.org/sdk/docs/man2/xhtml/glLoadMatrix.xml
          the pointer should point to 16 doubles (m[0]..m[15]), not one double.

          M Offline
          M Offline
          Mue22
          wrote on last edited by
          #4

          @jsulm thanks!!!!!

          but i try to double [16], it's doesnt work...:(

          i can&#x27;t use english well...

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            As I said QMatrix4x4 uses 16 floats. You want 16 doubles. So just cast them:

            QMatrix4x4 someMatrix;
            double otherMatrix[16];
            
            for(int i=0; i<16; ++i)
               otherMatrix[i] = someMatrix.constData()[i]; 
            

            But are you sure you need the extra precision of doubles? If you do transformations in floats (QMatrix4x4) and convert only the result to doubles then you're wasting time and bandwidth.

            M 1 Reply Last reply
            0
            • Chris KawaC Chris Kawa

              As I said QMatrix4x4 uses 16 floats. You want 16 doubles. So just cast them:

              QMatrix4x4 someMatrix;
              double otherMatrix[16];
              
              for(int i=0; i<16; ++i)
                 otherMatrix[i] = someMatrix.constData()[i]; 
              

              But are you sure you need the extra precision of doubles? If you do transformations in floats (QMatrix4x4) and convert only the result to doubles then you're wasting time and bandwidth.

              M Offline
              M Offline
              Mue22
              wrote on last edited by Mue22
              #6

              @Chris-Kawa

              Thanks!!!

              i dont know but it maybe just error, this post didn't regist...:(

              so i use glLoadMatrixf()!!

              i apply glLoadMatrixf(m.ConstData()); about lookat matrix..

              QMatrix4x4 m;
              m.LookAt(eyeV,targetV,upV);
              glLoadMatrixf(m.ConstData());

              it's dont occur error! build seccess!

              but there is no change(like camera move), just like before :(

              i can&#x27;t use english well...

              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