PDA

View Full Version : Help me improve my opengl user interface!



fuxifuxi
10-29-2003, 11:43 AM
Hello!

I am writing an opengl user interface for windows platforms. I need to create buttons, textboxes, scroolbars, etc. The problem is that I want each control to be 3D and independent from the contents of the window I render into.

One example should be the warcraft III user interface (with a shield, a flag and a sword redered as a backgroud and with buttons over those objects). I want a way to render the controls on top of what was previously rendered into the window.

Here is my solution:

-each control has a texture (or an area in a texture) associated with it. I render the object to the framebuffer and then glCopyTexSubImage it to its texture.

I render each object and copy it to its texture, then render the entire window and apply the controls as textured quads (with transparency).

I want to make the user interface work with mostly all the 3D cards so I don't want to use extensions unless they are widely supported.

My solution is VERY fillrate limited because, for every object I do the following opperations:

1) set all states as the object wants (not a fillrate limiter),
2) I do a glScissor and a glClear to clear the framebuffer in order to draw the object
3) I draw the object
4) I glCopyTexSubImage the object to its texture
5) I glBindTexture and apply a quad textured with the object

As you can see, besides drawing the object I also do the equivalent (more or less) of 3 glClear (glClear, glCopyTexSubImage and drawing the textured quad)

This implementation works as I want it to work, meaning that the controls have the same aspect no matter what projection matrix I have for the background and what I draw there.

However, I want to make it faster.

Do you have any ideas ?

fuxifuxi
10-29-2003, 11:53 PM
I have found a solution... http://www.opengl.org/discussion_boards/ubb/smile.gif

10-30-2003, 12:05 AM
What was your solution?

I'd recommend drawing your scene, clearing the depth buffer, then drawing the controls.

fuxifuxi
10-30-2003, 12:56 AM
That was my solution. But given that the controls may use stencil and alpha, i'll clear those also