//declare vertex
glm::vec2 vertex[1000]; //a very large size
//load the vertex
...
//send vertex to buffer
glBufferSubData( GL_ARRAY_BUFFER, 0 ,sizeof(vertex[0])*vertexSize,vertex );
but if I use a pointer to array
1 2 3 4 5 6 7 8 9 10 11 12
//declare vertex
glm::vec2 * vertex;
//allocate vertex
vertex = new glm::vec2[vertexSize];
//load the vertex
...
//send vertex to buffer
glBufferSubData( GL_ARRAY_BUFFER, 0 ,sizeof(vertex[0])*vertexSize,vertex );
the code does not work as intended.
What I'm doing wrong?
From the openGL reference, the signature of the method is:
void glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
vertexSize, once set, remains constant during the whole program, but it is unknown at compile time
When I use a pointer to array, the screen is blank as if no data was copied to the opengl array buffer.
I have printed vertex in both examples before calling glBufferSubData to check if they contain the same data, and they do. That's why I was thinking that there is something wrong between glBufferSubData and glm::vec2 * vertex.