-1

I have a VBO, which i init in the following manner:

- (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, and that is good for static objects which do not change (not including translations and such).

The thing is, i have no idea about where to start when it comes to drawing dynamic objects, which could be changed in a tap gesture or something of that sort.

A good example is this video: example.

It is obvious openGL is being used here, and for every different type of gesture, they manipulate the vertices location.

How is it done? by changing the x y z coordinates on every touch? and is it GL_DYNAMIC_DRAW they are using?

Hopefully i'm not entering to a world of pain by trying to achieve a similar behaviour.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Itzik984
  • 15,968
  • 28
  • 69
  • 107

1 Answers1

0

GL_STATIC_DRAW and GL_DYNAMIC_DRAW are just hints for the openGL driver to use the right optimization.

In your case, I suggest to just use one of the hints, let's say the dynamic one and after you have the right behavior of your application you can check which hint gives you the best performance (static or dynamic).

The app from the movie, sometimes does not update the buffers for lots of consecutive frames (when there is no input) and that would be suitable for GL_STATIC_DRAW, and sometimes it updates every frame (when the user is changing something) and that would be suitable for GL_DYNAMIC_DRAW.

Sulea Cosmin
  • 598
  • 1
  • 11
  • 24