Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Matrix to double??

    General and Desktop
    3
    6
    1698
    Loading More Posts
    • 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
      Mue22 last edited by Mue22

      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 Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • Chris Kawa
          Chris Kawa Moderators last edited by Chris Kawa

          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 Reply Quote 0
          • M
            Mue22 @jsulm last edited by

            @jsulm thanks!!!!!

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

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

            1 Reply Last reply Reply Quote 0
            • Chris Kawa
              Chris Kawa Moderators last edited by

              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 Reply Quote 0
              • M
                Mue22 @Chris Kawa last edited by Mue22

                @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 Reply Quote 0
                • First post
                  Last post