converting glm::mat4 to XMFLOAT4X4

I want to create an initial transform matrix from an orientation quaternion and a position vector.
My initial matrix is in glm format, but I want toconvert the glm matrix to an XMFLOAT4X4 matrix.

glm::mat4 glm_mWorld= glm::toMat4(_qOrientation);
glm_mWorld[3]       = glm::vec4(_vPosition);
glm_mWorld = glm::transpose(glm_mWorld);

So how can I load the content of glm_mWorld into an XMFLOAT4X4?

XMFLOAT4X4 is a simple union containing 16 floats.

XMFLOAT4X4  mTransform;
XMFLOAT4    qOrient;
glm::mat4 glm_mWorld    = glm::toMat4(_descriptor._qOrientation);
glm_mWorld[3]           = glm::vec4(_descriptor._vPosition);

glm_mWorld = glm::transpose(glm_mWorld);

memcpy(&mTransform.m[0][0], &glm_mWorld[0][0], sizeof(glm::mat4));

This results in an error:

glm-\glm\core ype_vec4.inl(251): error C2440: ‘<function-style-cast>’ : cannot convert from ‘const glm::vec3’ to ‘float’

The actual code in glm\core ype_vec4.inl is heavily templated and way over my head. Can anyone suggest a solution to this?


I don’t know where you actually invoke template code that tries to do this conversion, but I can’t locate anything in the code you posted above. Neither do I see any glm::vec3 anywhere, nor is there any copy, initialization or argument passing involving a glm::vec3 and a float. Also, please read the forum guidelines if you’re going to continue to participate here. Put your code in ‘[‘code’]’ tags.

I guess you may be looking for glm::value_ptr() from glm/gtc/type_ptr.hpp. It returns a pointer to the data stored in a glm vector or matrix.