Sign in to follow this  
aaron_ds

GUI rendering path

Recommended Posts

aaron_ds    486
I'll make this as short as possible. I'm making a GUI from scratch for fun. I have my rendering (OGL) code completely seperated from all objects in the scene, so that I can plug in renderers at will. Loading a mesh normally goes like this: -Create Triangles, load into Mesh, -Copy mesh triangles to root of Octree, divde octree(distribute triangles) During renderer startup: -Translate triangle octree into vertex array octree During rendering: -Render vertex arrays in vertex array octrees My first thought is that this is all too much work for displaying GUI elements. My question to everyone is: Do you have a seperate rendering path for 2d or GUI elements? Or do you just put it in the scenegraph and let the renderer render everything using one algorithm?

Share this post


Link to post
Share on other sites
Programmer16    2321
Though I've never thought about it, but I don't use a scenegraph to render my GUI (or any other 2D) elements. If you do an ortho-projection for them, then it might be a good idea, but I don't think it would be for a 2D elements (but I'm no expert.)

Edit: I thought that I might explain my advice better. For a scenegraph you have to sort everything, correct? Whats the point of sorting all those extra quads when you know that they'll always be on top of the 3D scene?

Again, I'm not an expert and I might be thinking of something different.

Share this post


Link to post
Share on other sites
aaron_ds    486
Programmer16:
In this case the scenegraph is used to show logical relations between objects.
Eg: Each node's transformation matrix is applied on its children.

I plan on creating a rich environmant combining traditional 2d GUI elements with 3d models.

A quick example would be a player's username hovering above their model. The text and model show a logical relationship, but one is 2d and one is 3d.

I'd like to know if most people render their 2d and 3d elements in one go, or if they render their 3d elements and then their 2d elements using different[simpler] rendering code.

Share this post


Link to post
Share on other sites
Koshmaar    989
I'm not programming 3D so what I say probably won't be very useful for you...

I'm keeping my GUI controls in separate child-parent relationship, independant from all other game elements. That's very easy (and logical), since in my code, GUI is kept in separate library, which can be used by certain game elements - but not the other way around ;-)


IMHO, connecting GUI with full-featured scene graph might be overkill, one reason being that in 99,999% cases you render GUI controls in orthographic projection, and in 99,999% cases your GUI control have to be rendered on top of all objects.


For your quick example: maybe you could take player position P(x,y,z), add to P.y player height H and add to result of (P.y + H) some small value, maybe 0.2 * H?. Then, unproject that point that you got from 3D space to 2D point on the screen - and finally, render at the center of that point player's name. That could be slightly easier and faster to do than using scene graph.

And one last thing - I'm rendering GUI using good old glBegin/glEnd as the last part of rendering my scenes, so that GUI overdraws what was before. But remember that my games are 2D. But also remember, that I haven't heard of anyone using scene graph for GUI.

In conclusion, I wouldn't use scenegraph - but it's your decision :-)

Share this post


Link to post
Share on other sites
HellRiZZer    308
It's pointless to use scenegraph or other enhancing tool for such simple job as GUI. Since you are going to have them in a list, simply render them from start to end, and don't bother with integrating it with the advanced stuff.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this