Refactoring the GUI

Published July 17, 2006
Advertisement
I have been noticing that rendering my GUI elements is really a performance hog. After running some tests with PIX, I was able to figure out that each of my textured buttons was setting the same texture right before it was rendered. This amounted to about 45 set texture calls on a scene that only had non-textured geometry and a GUI in it!!!

Needless to say, I spent my development time today refactoring my GUI components. They used to be a sort of special case object similar to the DXUT library. Now I have changed them to be integrated as objects in the scene graph, so that they can be sorted and culled just like any other object in my normal 3D scene graph.

At first thought it doesn't make sense to put 2D components and 3D objects together, but after considering that the scene graph just holds objects that may need to be rendered this frame it started to clear up. In fact, by implementing these objects as scene graph objects it will make it extremely easy to switch to a fully 3D GUI and at the same time retain the functionality of the 2D version.

All that, plus I get the performance improvements from grouping things together. GUI refactoring is not the most exciting, but it really seems to have helped out quite a bit.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement