Matrix to double??
-
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()...:(
-
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. -
QMatrix4x4 uses floats to store the data, so you can use it with raw OpenGL like this:
QMatrix4x4 someMatrix; glLoadMatrixf(someMatrix.constData());
-
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. -
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.
-
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.
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 :(