2

I need a little guide on how to handling different geometries (static, dynamic) in opengl .

I Trying to develop a graphics engine (as a learning), I have some idea of opengl (I've done some things) , I need to ask some questions that google not response :

1 - what is the correct way to store all geometry data in vbo's, to draw it later. How i organize this data into vbo's ? I think this:

separate all in

-> static and dynamic data

2 - keep in mind that in the world there are different types of 3d geometries static , dynamic , etc. , which would be the most optimal way to handle them ? Dynamic elements should each have their own vbo and ibo as they are updated every frame but the static as they should be treated?

imagine that the gameworld is made up of 3 static cubes (with same texture), five static cones (with different texture each one), five dynamic characters (3d models all differents, and that change in each frame) and 8 3d models static (all models are differents ). How you organize this geometries using vbo??

I do not reffer to the use of the vertex buffer object (I know it) , I enjoy how you group each element using vbo:

Ie: 3 cubes put in the same vbo, five cones in other separated vbo, etc etc

Fabian Orue
  • 193
  • 2
  • 14

1 Answers1

1
  • Separate dynamic and statically drawable arrays as mentioned (GL_STATIC_DRAW and GL_DYNAMIC_DRAW data hints, per buffer)
  • Use GL_TRIANGLE_STRIP for best vertex throughput
  • One may use an element array buffer for geometry with a high amount of shared vertexes, e.g. GL_TRIANGLE_STRIP_ADJACENCY used for geometry shaders. This can save memory bandwidth and/or GPU time (the vertex shader stage may process shared vertexes just once)
  • VBOs may exist per model, as a later optimization, one could allocate VBOs on a per data lifetime & world partition basis.
  • To get started, you could implement two simple cases:
    • static drawable model
    • dynamic drawable model
  • However, just make sure, that your data handling is abstracted enough to be changed & extended without pain.
  • A recently asked question regarding performance, for further info: Does interleaving in VBOs speed up performance when using VAOs
Community
  • 1
  • 1
Sam
  • 7,778
  • 1
  • 23
  • 49
  • Thanks Sam, all I was a great help! I just need to take off a question:would you do to organize this in vbo's?3 static cubes (with same texture), five static cones (with different texture each one), five dynamic characters (3d models all differents, and that change in each frame) and 8 3d models static (all models are differents)I want to know if what I think is right. thanks! – Fabian Orue Nov 19 '13 at 15:16
  • You're wlecome! This decision would fall into the category 'data lifetime & world partition'. If those objects aren't really huge and are created, drawn and destroyed at once, just scram them into a single buffer. However, the savings for midsized objects is rather negligible, as opposed to the rather complex data management. I'd basically start with one VBO per object. Then, I'd implement object assembly classes, which may be optimized with shared buffers later on. – Sam Nov 19 '13 at 15:27