PDA

View Full Version : How do I do 2D graphics in OpenGL?



05-30-2005, 09:54 AM
like i can draw stuff in 3d but what if i want to draw like a life bar on the screen? how do i do that?

powerpad
05-30-2005, 11:30 AM
ommit the z values in your vertices and you end up in the 2D plane

glVertex2f(x,y) is short for glVertex3f(x,y,0.0f)

a lifebar is some sort of rectangle or circle ...

Ehsan Kamrani
05-30-2005, 12:18 PM
Also use from the gluOrtho2D() rather than the glOrtho(), gluPerspective() or glFrustum().Although you can get a correct result with the functions glOrtho(), gluPerspective() or glFrustum(), but gluOrtho2D() is specific for 2D drawing.
Use from the glVertex2*()rather than the glVertex3*(). As an example, glVertex2f(x,y) is short for glVertex3f(x,y,0.0f).
-Ehsan-