The title says it all.
For some reason this code is working:
float m[3][3] = {
{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 1.0f}
};
glUniformMatrix3fv(basicShader->uniformAt(5), 1, GL_TRUE, &m[0][0]);
But this one isn't:
float **m = new float*[3];
for(int i = 0; i < 3; i++) {
m[i] = new float[3];
for(int j = 0; j < 3; j++) m[i][j] = 0;
}
m[0][0] = 1.0f;
m[1][1] = 1.0f;
m[2][2] = 1.0f;
glUniformMatrix3fv(basicShader->uniformAt(5), 1, GL_TRUE, &m[0][0]);
float[3][3]is a 2 dimensional array, in a coherent memory block.float **is an array of pointers and each pointer points to a new 1 dimensional array.float **tofloat[3][3]in order to send it to opengl?