glUniform: Matrix representation

Hello,

I’m using OpenGL with C++ through glew. Two simple questions:

  1. What format does the matrix (as GLfloat[]) for the function glUniformMatrix__ has to have? I couldn’t find any information in the doc nor google.
  2. Is the following safe to do:
GLfloat* vertexBuffer = new GLfloat[dynamicSize];
glBufferData(GL_ARRAY_BUFFER, dynamicSize * 4, vertexBuffer, GL_STATIC_DRAW);
delete[] vertexBuffer;

I ask, because I read somewhere, that OpenGL calls aren’t necessarily issued instantly and the pointer might be invalid if the “upload into vram” happens to late.

Thanks!

[QUOTE=GreenOwl;1253885]1) What format does the matrix (as GLfloat[]) for the function glUniformMatrix__ has to have?
[/QUOTE]
It’s just MxN floats, e.g. 16 floats for glUniformMatrix4fv(), 6 floats for glUniformMatrix2x3fv(), etc. The elements are in column-major order if the “transpose” argument is false or row-major order if it’s true. The interpretation of the matrix is up to the shader.

Yes.

[QUOTE=GreenOwl;1253885]
I ask, because I read somewhere, that OpenGL calls aren’t necessarily issued instantly and the pointer might be invalid if the “upload into vram” happens to late.[/QUOTE]
Apart from the glPointer functions (glVertexPointer etc), any data referenced by a pointer will be copied before the function returns. In the case of the glPointer functions, the data will be copied before the corresponding draw call (glDrawArrays etc) returns.