
Managing VBOs
Posted Monday, 29 August, 2011 - 15:27 by Stupid_2D inHellly everyone,
Its hard for me to find a way to write this down (language wise and logical) but i give it a try.
I have problems finding a good "architecture" which lets me have the desired freedom of manipulating things.
At the moment I have a static Class for my VBOs where I store every VBO in a List
This kinda works but now i notice that its a pain to do things like rotate a single VBO and Mouseselection. The rendering usually is a foreach which goes through the list and basically draws every VBO then.
Which makes me start questioning if this is the right approach.
Lets say I have gameobjects (like a simple cube which has some values like 2D Coordinates and stuff a game needs), how to I properly add a "rendering object" ?
I mean how does the connection between the game and the rendering logic look like ?
I know this is kind of general, but I cant find a way to make it more specific.


Comments
Re: Managing VBOs
My current approach:
- Model has Frame transformation in 3D, and Batch (or list of Batches)
- Batch has Mesh and Material
- Mesh has 2 BufferRanges, one for index buffer and one for vertex buffer
- BufferRange specifies a range in one Buffer object
- Buffer is wrapper for GL buffer object
- Material has Program and values for uniforms (using uniform buffer)
To render a Model, set the current transform and render all batches in it. To render a Batch, apply it's Material and index and vertex buffers from the mesh. I have buffer ranges, as you can put multiple meshes per vertex (or index) buffer, reducing need to setup attribute pointers / vertex array objects.
To optimize things, sort objects, by material/program at least, so you don't have to bind material uniform buffer unless material changes, and you don't have to use program unless it changes.
Re: Managing VBOs
Well thanks for your reply.
But to be honest, i dont know what batches or Meshes are. In general i dont know at all what you try to tell me. Guess i need to do more studies -.-
Damn I am still at the surface -.-
Re: Managing VBOs
Ok,
I ask this question again,
is there any better way instead of translate and rotate to change positions of VBOs without using Push and PopMatrix for every single vbo ?
I just thought i introduce a stack, where the game pushes all elements which should be drawen and the render does everything else.
First renders with unique color + manipulations like translate and rotate for picking and in the second render does the same but with normal colors.
So obviusly, since every vbo has a different position and some are moving i need lots of GL.PushMatrix and Gl.PopMatrix
Re: Managing VBOs
Do you currently use GL.Translate, Rotate and Scale?
It would be better to manage all transformations yourself (using a Matrix4 class/struct). Then all you need is GL.LoadMatrix(), or use uniforms or uniform buffers.
Re: Managing VBOs
Can you point me to a simple example. I kinda know what you talk about but I have no clue how to do it :)
And thank you for your patience so far.
Re: Managing VBOs
Arcsynthesis tutorial around Chapter 6. But it might be all worth reading.
Re: Managing VBOs
Woah thats alot material right there. Thanks!
Re: Managing VBOs
I cant bring uniformbuffers to work, can you give me a simple example how to do it ?
I think this is the correct tutorial for it, but im to dumb to understand
http://www.arcsynthesis.org/gltut/Positioning/Tut07%20Shared%20Uniforms....
What I tried doing was adding the uniform stuff to my VBO. So i do something like:
This is my current state: