如何从glm :: mat4中读取值

Edv*_*vin 7 c++ arrays matrix glm-math

我有一个glm :: mat4矩阵,我需要将值转换为double [16]数组.关于如何解决这个问题的任何想法?

Rog*_*and 19

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];
Run Code Online (Sandbox Code Playgroud)

  • 请记住包含"#include <glm/gtc/type_ptr.hpp>" (8认同)