Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
1  
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
add comment

1 Answer

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.

Example:

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
add comment

Your Answer

 
discard

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.