View Full Version : axis display

06-04-2005, 12:10 PM
Is there a function that displays the 3 axis in a perspective or orthogonal view?


Ehsan Kamrani
06-04-2005, 12:30 PM
No. You should use from the lines to draw the axes. glLoadIdentity defines a coordinate system with these axes: x( right vector ), y( up vector )and z( toward the viewer ).
So as an example, use from the following function to draw the axes:
void DrawAxes()
//positive x axis
glColor3f(1.0f, 0.0f, 0.0f ); //red is x axis
glBegin( GL_LINES );
glVertex3f( 0.0f, 0.0f,0.0f );
glVertex3f( 1.0f, 0.0f,0.0f );
//y axis
glColor3f(0.0f, 1.0f, 0.0f ); //green is y axis
glVertex3f( 0.0f, 0.0f,0.0f );
glVertex3f( 0.0f, 1.0f,0.0f );
//z axis
glColor3f(0.0f, 0.0f, 1.0f ); //blue is z axis
glVertex3f( 0.0f, 0.0f,0.0f );
glVertex3f( 0.0f, 0.0f,1.0f );
Now if you transform your coordinate system *BEFORE* this code, these axes will be rotated, translated and scaled as well:


06-04-2005, 04:16 PM
Thank you :)