danijar
danijar

Reputation: 34215

Modify Buffer in OpenGL

I have a modifiable terrain which is stored in a vertex buffer. Because of its large number of vertices, I do not want to upload all vertices again every time the terrain is modified. What I do by now is to split the terrain into smaller chunks so that I only have to recreate the buffer of the area containing the modification of the terrain.

But how can I just add or remove some vertices of an existing buffer?

Upvotes: 1

Views: 201

Answers (2)

Andreas Goulas
Andreas Goulas

Reputation: 163

You can either use glBufferSubData as datenwolf said, or if you are planning on making a lot of modifications and accessing randomly the data, you may want to map the buffer into client memory using glMapBuffer and later unmap it with glUnmapBuffer. (Then, based on the access specifiers you chose, you can edit the data as a C array)

Upvotes: 2

datenwolf
datenwolf

Reputation: 162317

You can change data in an existing buffer using glBufferSubData

Upvotes: 0

Related Questions