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

I have a VBO, which I initialise like this (just an example):

- (void)setupVBOs {

    GLuint vertexBuffer;
    glGenBuffers(1, &vertexBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);

    GLuint indexBuffer;
    glGenBuffers(1, &indexBuffer);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);


As you can see, I'm using GL_STATIC_DRAW, which is good for visually unchanging objects (not including translations and such).

How do I draw animated objects though? I mean things that might be changed by user interaction. This video is a good example. It is obvious OpenGL is being used, as the vertices are manipulated by gestures.

How is it done? by changing the x y z coordinates on every touch? Are they using GL_DYNAMIC_DRAW? Is this hard?

share|improve this question
up vote 3 down vote accepted

Create a VBO with a GL_DYNAMIC_DRAW or GL_STREAM_DRAW flag. This is used to give the OpenGL implemetation a hint of where to allocate the memory and enable certain optimizations, for example the data could be cached or not, stored in system memory or graphics memory.

Dynamic means the data will be changed frequently (specified and used repeatedly)

Stream means the data will be changed every frame (specified once and used once).

Regarding the video, since you are going to update the buffer frequently, once you create your buffer, you can use glMapBuffer which will give you the ability to map the buffer in the GPU to the client address and directly read and/or write on it relative to the returned pointer, depending on the specified access policy. This way you can update the vertices frequently without copying the entire buffer every time.

share|improve this answer
Thanks! are there any online tutorials or examples you know of? – Itzik984 Feb 2 '14 at 23:18
@Itzik984 tutorials regarding which topic exactly ? – concept3d Feb 2 '14 at 23:23
about how to use glMapBuffer and get/set the needed data. just to prevent myself for wondering in the dark regarding these issues. – Itzik984 Feb 2 '14 at 23:29
@Itzik984 This one I used previously it has clear src code for dynamic VBOs – concept3d Feb 2 '14 at 23:39
great. thanks a lot! will look into it. – Itzik984 Feb 2 '14 at 23:40

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.