PDA

View Full Version : In Screen Menu Bar



08-20-2002, 09:23 PM
I am trying to add a Menu bar with in the OpenGL rendering are. The "look at" and the "look from" variables are constantly chainging due to user input but I want this menu to be stationary in relation to the screen. Is there any easy way of doing this? So far I am planning on calculating four points and putting up a texture mapped polygon of the menu every time the viewing coordinates chainge. However if there is a way that is less taxing on my brain and processor I'd like to know it. BTW I am using perspecitve view.
PS. I already know I can't spell

Morglum
08-21-2002, 02:50 AM
Yes there's an easy way. You can first draw your 3D objects with any perspective you want, and then switch to what's called an 'orthographic projection' to draw the menubar. Sample code :

void draw_everything ()
{ set_up_perspective ();
draw_3D_objects ();

//and now what you have to add:
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0, witdh_of_window, height_of_window, 0, -1, 1);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();

//and now you're ready to draw in 2D.
//example : we'll draw a red point at location (10, 30)
glColor3f (1, 0, 0);
glBegin (GL_POINTS);
glVertex2i (10, 30);
glEnd ();
}