Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: converting glm::mat4 to XMFLOAT4X4

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011

    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\type_vec4.inl(251): error C2440: '<function-style-cast>' : cannot convert from 'const glm::vec3' to 'float'

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

    Last edited by freefallr; 07-20-2013 at 04:51 AM. Reason: code layout

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts