Skip to main content
gamedev.net
🔒 Locked

User Interface...

Started by FreJa Mar 1, 2003 at 9:49 AM 3 replies 250+ views
Original Post
FreJa
FreJa
Hi, How can I create a user interface to my game that works only in 2D but can have 3D objects behind?... pretty much like every game out there.... Thanks
"Through me the road to the city of desolation,Through me the road to sorrows diuturnal,Through me the road among the lost creation."
Yohumbus
Yohumbus
well the most obvious way would be to billboard all of your interface with depth testing turned off. What I would do though is render your scene then set up your gui by pushing the projection and modelview matrix and switching to orthographic mode so that no biboarding will be required and the positions wont change. Once the interface is drawn then you just pop the matrices.
ASCII stupid question, get a stupid ANSI
JuNC
JuNC
The basic idea is:

1) Draw all 3D stuff

2) Set the projection to Ortho mode and draw all your 2D stuff without using the depth buffer (or you can do if you know what ur doing). A typical setup would look like this:


    

void Do2D(void)
{
glDisable(GL_DEPTH_TEST);
glColour3f(1,1,1);


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(1,-1,-1,1,-9999,9999);


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();



// bind the texture I want to show on the first quad




glBindTexture(GL_TEXTURE_2D,my_quad_texture);



glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex3f(0.25,0.25,0);
glTexCoord2f(1,0); glVertex3f(0.25,0.5,0);
glTexCoord2f(1,1); glVertex3f(0.5,0.5,0);
glTexCoord2f(0,1); glVertex3f(0.5,0.25,0);
glEnd();



}



[edited by - JuNC on March 1, 2003 11:31:19 AM]
Ready4Dis
Ready4Dis
Or... look into glOrtho, for 2D in opengl, you can over-lay it over your 3d stuff without issue. I have an alright GUI done in OpenGL that uses this, and it can be thrown over-top of anything (or given it's own background). It supports multiple windows, and objects. The objects can be owned by a window, or by the GUI itself (then it just gets drawn over the background, and not on a window). Windows can be moveable or not, etc. If you're interested in the sources, let me know.

Billy

Ready4Dis@aol.com
aol im = CrazyGuy4Eva
msn messenger = Ready4Dis_1@hotmail.com

Some screen shots of my GUI in action...
http://ready4dis.8m.com/Images/Screeny.jpg
http://ready4dis.8m.com/Images/Screeny2.jpg
http://ready4dis.8m.com/Images/Screeny3.jpg
http://ready4dis.8m.com/Images/Screeny4.jpg
http://ready4dis.8m.com/Images/Screeny5.jpg
http://ready4dis.8m.com/Images/Screeny6.jpg
http://ready4dis.8m.com/Images/Screeny7.jpg


[edited by - Ready4Dis on March 1, 2003 11:35:19 AM]
FreJa
FreJa
Wow! looks very nice... please send me the source... just to get the idea....

pedrosl@netcabo.pt


Thanks really a lot
"Through me the road to the city of desolation,Through me the road to sorrows diuturnal,Through me the road among the lost creation."

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.