glm::mat4 pMat4; // your matrix
double dArray[16] = {0.0};
const float *pSource = (const float*)glm::value_ptr(pMat4);
for (int i = 0; i < 16; ++i)
dArray[i] = pSource[i];
How to read the values from a glm::mat4
题
I have a glm::mat4 matrix and I need to get the values into a double[16] array. Any ideas on how to solve this problem??
解决方案
其他提示
&mat[0][0]
also will work. From the OpenGL Interoperability section in glm documentation:
glm::vec4 v(0.0f);
glm::mat4 m(1.0f);
...
glUniform3fv(uniVec, 1, glm::value_ptr(&v[0]));
glUniformMatrix4fv(uniMat, 1, GL_FALSE, &m[0][0]);
不隶属于 StackOverflow