Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's start with a basic OpenGL ES 2.0 setup (like the Xcode OpenGL game template), If I want to add parts (vertices I should say?) to my model over time, what should I do!

To clarify, let's say I want to add a "step" to a ladder every 5 seconds or every time user taps the view, I initialize with one "step" like an elongated cube and then as things are being rendered on the screen I want to "add" vertices to my data buffer (?),

can I just call:

glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW);

with a brand new gCubeVertexData array of floats on the fly each time?
What is the best approach to this?

share|improve this question
I think you may be over-thinking your problem. You don't need to do anything super advanced, just generate the vertex data each time and buffer it. – Byte56 Jul 15 '12 at 15:15
up vote 1 down vote accepted

Note that that way you would need a buffer for every ladder in your game. And even if you have only one ladder you will have to reset the mesh whenever it you want to display it with less steps. Based on that I think in this case the best wouldn't be to modify the mesh but rather to draw the parts the ladder is consisting of each on their own.


ladderBase.drawScaled(1, ladderLength);
for(int i=0; i++; i<ladderLength)
   ladderStep.drawAtPosition(0, i);

However if for any reason you really want to modify the mesh on run time note that you can use glBufferSubData to update only a part of the buffer, as opposed to replace the whole old data with the whole new data.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.