Fabian Orue
Fabian Orue

Reputation: 193

how manage and organize dynamic and static geometry

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

Upvotes: 2

Views: 1110

Answers (1)

Sam
Sam

Reputation: 7858

  • 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

Upvotes: 1

Related Questions