PDA

View Full Version : How can i just draw a basic line in 3d



dawidjoubert
01-27-2004, 10:57 AM
u see i have a cube rotating but the axis rotate with - the way it should be but i want to draw a basic line from the quad to indicate the X,Y,Z axis - i dont need detailed stuff just the command i need to draw lines and or pixels EG
GL_Line(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f)

01-27-2004, 12:13 PM
How to draw a single line:



glBegin(GL_LINES);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
glEnd();

In a GL_LINES, a line will be drawn between each sucessive pair of vertices. If you use GL_LINE_STRIP a line will be drawn going through *all* vertices, and a GL_LINE_LOOP will do the same but connect the last vertex to the first.

zeckensack
01-27-2004, 12:14 PM
glBegin(GL_LINES];
glVertex3f(0.0f,0.0f,0.0f);
glVertex3f(1.0f,1.0f,1.0f);
glEnd();

I didn't fully understand what you were saying here:
u see i have a cube rotating but the axis rotate with
<...>
i want to draw a basic line from the quad to indicate the X,Y,Z axis
If you are trying to plot axes and don't want them to rotate with the cube, you'll have to reset the transformation matrix - every vertex passed to gl will be transformed.



glLoadIdentity();
//whatever you need for your cube
glRotate(...);
glTranslate(...);
//render the cube
...

//reset the modelview matrix
glLoadIdentity();
//render the axes
...
You can change transformation matrices whenever and as many times as you want while rendering a frame.

HTH http://www.opengl.org/discussion_boards/ubb/smile.gif