Opengl layers?
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
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.
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();
?
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement