# VBO based GUI : controls & text.

This topic is 2308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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

##### Share on other sites
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 plans). Well, now I should to try implement this ideas.
Neverwinter Nights 2 GUI - this is my ideal

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631782
• Total Posts
3002324
×