Jump to content
  • Advertisement
Sign in to follow this  
Triad_prague

OpenGL rendering gui and font without too much texture switch

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm facing an (not an issue, but I'm quite annoyed with it). I'm drawing gui in my opengl application, using my own custom gui renderer. each gui object (window, button, everything) has a title (altho not all gui titles are rendered, like scroll bar). now here's how I render all gui object

for each gui object
bind_gui_texture()
render()
if(draw_title)
bind_font_texture()
draw_title at x, y location of the gui

it works nice and ok, but there's too much texture switching here. I wonder if it will slowdown the application if it use many gui? I'm thinking a way to reduce the texture switch but that only doable if I merge the font texture with the gui texture. right now all gui uses similar texture (I pack each component's texture into one large texture), so there's 2n texture switch. do you think I'd better avoid thinking about such issue?

Share this post


Link to post
Share on other sites
Advertisement
I would probably use the notion of a theme, where a theme is simply one large texture atlas that stores all the themes imagery, and then a reference to a separate font bitmap. This should really only require you to bind 2 textures before you draw the GUI. In other words, pull out the texture binding from your loop somehow.

Share this post


Link to post
Share on other sites
do you mean I should merge all gui texture (which I already did) or do I have to merge it too with the font texture? hmm the "theme" idea is good I will consider it in next optimization, thanks for the response btw :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!