Other libraries have a simple method to get this data, for example M$oft's Math library uses the 'StoreFloat4x4' functions for passing the float values. Based on that implementation I've started doing this:
Code: Select all
static float rotY = 0.0f;
rotY += .0005f;
Vectormath::Aos::Matrix4 modelMatrix = Vectormath::Aos::Matrix4::rotationY(rotY); //Rotating Model Matrix for example
float tmpMtx[16];
_mm_store_ps( &tmpMtx[0] , modelMatrix .getCol(0).get128() );
_mm_store_ps( &tmpMtx[4] , modelMatrix .getCol(1).get128() );
_mm_store_ps( &tmpMtx[8] , modelMatrix .getCol(2).get128() );
_mm_store_ps( &tmpMtx[12] , modelMatrix .getCol(3).get128() );
unsigned int locModelMat = glGetUniformLocation(m_programID, "modelMat"); //Model Matrix Location
glUniformMatrix4fv(locModelMat, 1, GL_FALSE, &tmpMtx[0]); //Copy Float[16] model matrix to OpenGL Shader