VBO based GUI : controls & text.

Started by
1 comment, last by Lleran 12 years ago
I need advice about user interface implementation. Let's suppose that group of controls represented as single VBO buffer. For exaple (in rendering order): background - border - some icon.
[sharedmedia=gallery:images:2018]

Now I desire to add vbo based text (it represented as single VBO buffer too, therefore I have 2 VBO buffers). How can I implement rendering order like this: 'background - border - text - some icon' using 2 VBO buffers?
Advertisement
That doesn't sound like a very flexible solution. Normally you would disable Z-testing, and then just draw the individual components in the order as you mentioned. It's possible to put everything in one (or more) VBO's, and render subparts though. By using offsets, or indices. For example, if you go for indices, you could:
- Create 1 VBO containing ALL geometry
- For each thing, create a buffer with the indices (usually 4 ints referring to the corner vertices)
- Activate the VBO
- apply border material, render border , using the indices that refer to the border quad


glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, myIndicesBufferObject ); // bind indices, also stored on the GPU
glDrawElements( GL_TRIANGLES, count, GL_UNSIGNED_SHORT, 0 ); // render
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0);

- apply background material, render background, using the indices that refer to the background quad
- ...and so on...
- Disable the VBO

This also allows to hide or move around subparts. Before drawing a subpart, you can apply other materials, and call glTranslate/glScale or whatever transformation. I wonder if it's worth the trouble though, since a GUI usually only contains a relative small amount of simple quads.

Rick
Thanks for reply and ideas. I thought for a moment...
GUI may be represented as:

[xml]<Background>
<Border>
<TextButton/>
<TextButton/>
<TextButton/>
</Border>
<Some_other_batched_GUI/>
</Background>[/xml]

Also it may be represented as (in rendering order): 'Background - Border - TextButton - TextButton - TextButton - Some_other_batched_GUI. So, it's necessary to have some VBO buffers: (Background + Border) - (Button) - (Text) - (Button) - (Text) - (Button) - (Text) - (Some_other_batched_GUI). Yes, this isn't ideally, but this case isn't ordinary\frequent too (Creating text processor isn't in my planssmile.png). Well, now I should to try implement this ideas.
Neverwinter Nights 2 GUI - this is my idealsmile.png

This topic is closed to new replies.

Advertisement