PDA

View Full Version : 3D scne and 2D primitives



calixte
04-14-2005, 04:53 AM
Hi, I render a 3D opengl scene using gluPerspective. I want to draw some 2D rectangles on the screen as well. How can I do that?
Thanx

c.

Relic
04-14-2005, 05:10 AM
It's in the FAQ's, so not an advanced question.
http://www.opengl.org/resources/faq/technical/index.html
http://www.opengl.org/resources/faq/technical/transformations.htm#tran0030

From a yesterday's post:

glMatrixMode(GL_MODELVIEW);
glPushMatrix(); // modelview!
glLoadIdentity();
glMatrixMode(GL.GL_PROJECTION);
glPushMatrix(); // projection
glLoadIdentity();
glOrtho2D(0, windowWidth, 0, windowHeight);
// Your 2D stuff here. Clear or disable depth buffering!
glPopMatrix(); // projection
glMatrixMode(GL.GL_MODELVIEW);
glPopMatrix(); // modelview
// Previous matrix state fully restored.