I've been using OpenGL for a short time now- and I'd like some clarification on VBOs. As I understand it, a VBO is an object stored on VRAM. In immediate mode, to apply a texture we simply bind it and specify the texture coordinates before the vertex coordinates, however it doesn't seem that way with VBOs.

Question 1: Can I specify texture data in a VBO? What portion of the data?

Normally when I make a game in 2d I'd store all of my objects in instances of different classes, then when my drawing routine comes up- just draw the objects that are on screen. With a 3D environment it would be a bit more difficult to just draw the objects on the screen but with some math I'm sure it's doable.

Question 2: Once we figure out which objects need to be rendered, would it be acceptably fast to send those corresponding objects an "apply" request, and have them apply themselves? Or is there a better way?

Question 3: If I have a completely dynamic map, but with objects that won't change very often, are there any guidelines as to the performance differences between GL_STATIC_DRAW and GL_DYNAMIC_DRAW?

Final Question: Should I even consider using vertex lists? Or are VBOs just a better option?

  • On the subject of question 2... I'm not sure if you specifically mean having the high-level render objects draw themselves, or are still specifically talking about lower-level VBO machinery. But in the case of the former, you may want to see this question. – Josh Petrie Oct 19 '11 at 14:29
  • Would I want to call glDrawElements in each object- or should I store everything as triangles and just have one glDrawElements? Is either way viable? – ultifinitus Oct 19 '11 at 16:32
up vote 6 down vote accepted

Answer 1:

Of course you can, without texturing capabilities vertex buffers would be next to useless. A VBO is just a chunk of binary data with the format you specify (position channel, normal channel, texcoord channel, etc.) that gets interpreted by a shader. When drawing an object, you are telling the GPU to fetch that batch of data and apply the operations specified in the shader (vertex transform, light calculation, texture fetches, etc.).

So, take for example you have a VBO with a quad stored in it. The VBO stores the position and texture coordinate info of the four vertices. Now the only thing you have to do is bind the VBO, bind an IBO to specify the triangles that compose your quad, tell your shader to use a texture of your choice and draw the whole thing. And now that you have the VBO and IBO active, you only need to modify the texture parameter of the shader and call again the draw function to reuse your quad into a different object.

Answer 2:

As specified in answer 1, when you have your VBO created and stored in VRAM, you only have to update your shader variables and call glDrawElements again to redraw the object.

Answer 3:

Well, you can apply GL_DYNAMIC_DRAW to the entire map, if that's what you want. The difference between these two options is that the driver chooses to store dynamic buffers in the fastest portion of VRAM it can find, so if you use it for objects that won't have their geometry repeatedly changed, you are wasting it. The OpenGL reference for glBufferData gives you a hint on what is the best usage for your buffer.

Final answer:

glDrawArrays is just a primitive version of VBOs, where the data is divided in channels but re-uploaded to the GPU on every call. Just stick with VBOs if you want the best performance.

Even though i'm completely satisfied with r2d2rigo's answer, I would like to explain how i will visualize about VBO's :D

First, Even-though VBO means Vertex Buffer Object, It doesn't mean that it holds only vextex coordinates.

    A Vertex will have attributes such as coordinates,texture 
    coordinates,normals,color.The whole thing makes a well defined vertex. 

So here you need to understand a VBO like - "It can be able to store the whole vertex attributes". Basically a VBO is a "buffer" that you can bind to any of the vertex info.

Answer 1 : Yes (Check the above description)

Answer 2: VBO's are usually "faster" than usual vertex lists, as there is no need of pushing the vertex info every frame(if the data is static). Even If the underlying architecture is unified memory architecture, it will have benefits as there is no "overwrite" of data unnecessarily.

Answer3 : STATIC_DRAW/DYNAMIC_DRAW are just flags to tell the underlying GPU where to keep the buffers.The underlying GPU will decide where to keep the buffers based on the flags you give.So this should be in mind for better throughput.But, in Unified Memory Architecture(where GPU will be sharing Main RAM),I think it will not make any significant difference.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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