Let's say that I have an array of vertices and a VBO pointer:
std::vector<Vertex> vertices;
GLuint vbo;
glBindBuffer(GL_ARRAY_BUFFER, vbo);
Now I buffer the data:
glBufferData(
GL_ARRAY_BUFFER,
vertices.size()*sizeof(Vertex),
&vertices[0],
GL_STATIC_DRAW
);
If I understand this correctly I still need to keep vertices array due to GL_STATIC_DRAW
. However if I change it to GL_STATIC_COPY
then all of the data will be copied to GPU's memory so I can free memory used by vertices
. Is that correct? If that's the case why do we need *_DRAW
? Is that useful because of the GPU's memory limit? Plus how does GL_STATIC_READ
really work?
All of this is explained in the glBufferData()
man pages.
https://www.opengl.org/sdk/docs/man/html/glBufferData.xhtml
You don't need to keep an extra copy in your program's memory. The whole purpose of glBufferData()
is to copy data from your program to an OpenGL buffer, once the copy is complete, you can do whatever you want with your program memory.
If data is not NULL, the data store is initialized with data from this pointer.
Do not use GL_STATIC_COPY
, that is incorrect. The documentation reads:
COPY
The data store contents are modified by reading data from the GL, and used as the source for GL drawing and image specification commands.
So GL_STATIC_COPY
is only for internal copies between different OpenGL buffers, not for copies from your application to OpenGL. Use DRAW
.