I have a 4x4 matrix class that holds the values as 2d float array : float mat[4][4]; and I overloaded the [] operator
inline float *Matrix4::operator[](int row)
{
return mat[row];
}
and I have an uniform mat4 in my shader (uniform mat4 Bones[64];) which i will upload my data onto. And I hold the bones as a Matrix4 pointer (Matrix4 *finalBones) which is a matrix array, containing numJoints elements. and this is what i use to upload the data :
glUniformMatrix4fv(shader.getLocation("Bones"),numJoints,false,finalBones[0][0]);
I am totally unsure about what is going to happen, so i need to ask that if this will work or i need to extract everything into 16*numJoints sized float arrays which seems to be expensive for each tick.
edit this is what i have done which seems really expensive for each draw operation
void MD5Loader::uploadToGPU()
{
float* finalmat=new float[16*numJoints];
for (int i=0; i < numJoints; i++)
for (int j=0; j < 4; j++)
for(int k=0; k < 4; k++)
finalmat[16*i + j*4 + k] = finalBones[i][j][k];
glUniformMatrix4fv(shader.getLocation("Bones"),numJoints,false,finalmat);
delete[] finalmat;
}