Jump to content
  • Advertisement
Sign in to follow this  
ThaGonzo

OpenGL Opengl layers?

This topic is 3990 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to make different layers in openGL? because i have an 3d-scene, and i want to create an 2d-layer in front of it, so i can make things like buttons and text fields in front of the scene. Is there anyone who knows how to do this? Greetz, Leon

Share this post


Link to post
Share on other sites
Advertisement

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, windowwidth, 0.0, windowheight, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);

glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);



You can tweak the values for glOrtho to your liking.

Share this post


Link to post
Share on other sites
You mean something like:


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)1920/(GLfloat)1200, 0.1f, 2000.0f);
glMatrixMode(GL_MODELVIEW);

glBegin(GL_QUADS);
(3d gl objects)
glEnd();

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, windowwidth, 0.0, windowheight, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);

glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);

glBegin(GL_QUADS);
(2d gl objects)
glEnd();


?

Share this post


Link to post
Share on other sites
That's the usual way of doing it (although you don't have to draw all your objects in a glBegin/End call). Also remember you need to reenable the depth test and depth writing at the start of the next frame otherwise the state will carry over.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!