I’m making a UI using OpenGL (buttons, sliders, menus etc all made with colored lines and polygons) There is a large number of these gadgets to draw. As I see it the two options for drawing this UI is to turn off ztest and draw back to front, or turn on ztest and draw front to back with depth values (a layer value basically) for each gadget. I’m wondering if you guys think the performance increase I’ll get from using the ztest and front to back rendering will be worth the extra costs associated with the ztesting and z writting?
You won’t get much of a performance boost unless you are drawing zillions of things. (That is, if your scene complexity is less than that of Doom 3.)
However, drawing in back-to-front order will be a big help when you inevitably decide to use alpha blending.
Unless it is really hard for some reason, I’d go for the depth sort. (If you have a known number of layers, you could even do a bucket sort.)
Bear in mind that front-to-back-depth-tested won’t work if you have any alpha-blending in your UI.
I’m by no means in favour of the current “theme” stampede to make every window translucent and thereby near-impossible to read, but there are lots of subtle little effects that you might not want to rule out. Antialiased edges on circular radio buttons. Drop-shadows to help identify the focus window. Stuff like that.