kag101
07-07-2004, 07:48 AM
Does anyone know how to display the x,y,& z axes in open GL?
you can draw three lines representing the different axis in different colors.
example:
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(axisCenterPointX, axisCenterPointY, axisCenterPointZ);
// x axis
glColor3f(1,0,0);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(axisLength,0,0);
glEnd();
// y axis
glColor3f(0,1,0);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,axisLength,0);
glEnd();
// z axis
glColor3f(0,0,1);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,0,axisLength);
glEnd();
glPopMatrix();
instead of using the modelview matrix you can add a centerpoint inside the glVertex commands.
jan
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.