Damons
Damons

Reputation: 173

how can I update vbo data larger than current vbo buffer size?

I generated a vbo buffer (vertex buffer) object called object_A, let's assume that object_A contains 10 vertices (30 floats). Now I want to update object_A using glMapBuffer with 20 vertices (60 floats), can I use glMapBuffer?

Upvotes: 0

Views: 721

Answers (1)

vallentin
vallentin

Reputation: 26235

You can't use glMapBuffer(), that's just for mapping the buffer's data into client address space.

If you want to resize a buffer then you have to use glBufferData().

glBufferData(GL_ARRAY_BUFFER, 60 * sizeof(GLfloat), NULL, GL_DYNAMIC_DRAW);

If it's because you want something similar to realloc() (reallocating the buffer, keeping the old contents). Then you could utilize glCopyBufferSubData() and copy the data between buffers.

Upvotes: 2

Related Questions