Skip to main content
GameDev.net gamedev.net
🔒 Locked

Displaying something Flat

Started by TempHolder Oct 24, 2005 at 6:11 PM 3 replies 700+ views
Original Post
TempHolder
TempHolder
Hey Iam having a little problem, I want to display Flat on the screen, basicaly a GUI, I want these objects to appear infront of all the 3D Objects that are drawn, and always facing the camera. I tried to do it with Ortho and it went a little something like this. void Init2D(int wid, int hei) { glViewport(0, 0, wid, hei); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glPushMatrix(); gluOrtho2D( 0, wid, 0, hei ); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); } void End2D() { glPopMatrix(); glMatrixMode( GL_PROJECTION ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); } I used those too to create a 2D View and then I would try to draw the GUI elements after I drew all the 3D objects, But when I did that I could not see my 3D Objects anymore. Iam guessing they lost their position or something. Anyhow I want to know how I can use OpenGL to set up some kind of flat surface display thats always infront of the camera and never moves, and that is drawn ontop of the 3D Objects without losing them. This help will be greatly appreciated thank you!.
LilBudyWizer
LilBudyWizer
Everything disappearing sounds like you're clearing the color buffer. Either than or you drew overtop of the image and thus replaced it.
Keys to success: Ability, ambition and opportunity.
TempHolder
TempHolder
so any ideas on how I can display 2D Controls over my 3D Objects?
Kalidor
Kalidor
Push the projection matrix before you set it to identity (instead of after like you're doing now).
TempHolder
TempHolder
Hey Thanks that fixed it all, your my hero Kaildor

Topic Locked

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

Sign in to reply to this topic.