Upload vertex data once with GL_STATIC_DRAW
Upload vertex data once with glBufferData and the GL_STATIC_DRAW usage hint, and know when GL_DYNAMIC_DRAW fits better in OpenGL 3.3 core.
Mesh data that never changes should be uploaded one time with the GL_STATIC_DRAW hint. The hint is a promise about use, not a restriction, so the driver can place the buffer where the GPU reads fastest.
const float quad[] = {
-1.f, -1.f, 1.f, -1.f, 1.f, 1.f, -1.f, 1.f,
};
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof quad, quad, GL_STATIC_DRAW);
GLint size = 0;
glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
printf("buffer holds %d bytes\n", size);buffer holds 32 bytesThe usage values are listed on the glBufferData page: STATIC is written once and drawn many times, DYNAMIC is rewritten often and drawn often, STREAM is rewritten almost every draw. The spec calls them hints, so a wrong one still renders correctly; it only risks a slower memory placement.
Calling glBufferData again reallocates the store. For small in-place edits use glBufferSubData instead, and for per-frame data prefer one of the dynamic hints.