PDA

View Full Version : drawing lines



Dogcow
09-27-2002, 10:17 AM
For a class assignment I have to construct a wireframe cube (using lines, not faces or cube's...) and can't seem to find the syntax for defining lines. For a triangle I would simply use



glBegin(GL_TRIANGLES);
glVertex3f(
....

Is there some sort of glBegin(GL_LINES) command that lets you specify the x,y,z coordinate of the starting coordinate and ending coordinate?

Thanks in advance!
-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

[This message has been edited by Dogcow (edited 09-27-2002).]

Bob
09-27-2002, 10:27 AM
glBegin(GL_LINES) as you mentioned.

nexusone
09-27-2002, 10:51 AM
You just about had it....

glBegin(GL_LINES);

glVertex3f( x1, y1, z1); // start of line.
glVertex3f( x2, y2, z2); // end of line.

glEnd();

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


Originally posted by Dogcow:
For a class assignment I have to construct a wireframe cube (using lines, not faces or cube's...) and can't seem to find the syntax for defining lines. For a triangle I would simply use



glBegin(GL_TRIANGLES);
glVertex3f(
....

Is there some sort of glBegin(GL_LINES) command that lets you specify the x,y,z coordinate of the starting coordinate and ending coordinate?

Thanks in advance!
-Dogcow "moof!"
Visit The Underground (http://theunderground.eon.com.au)

[This message has been edited by Dogcow (edited 09-27-2002).]

Mreal
09-30-2002, 09:29 AM
I've notice that when you draw line and start move away, the length of the line is getting shorter, but the width remains unchanged!!!How can i avvoid this, and draw line that gets tighter when i move the camera away?

nexusone
09-30-2002, 09:37 AM
Sounds like you are using perspective view, it renders things like a real life view.
Say you take a yard(meter) stick, as the stick moves away from you it will appear to get smaller. But the size of the stick has not change, only the distance.

What do you mean by tigher?

If you don't want to line to change size as you move away, change to ortho view.
Object size does not change as it moves away from the camera.



Originally posted by Mreal:
I've notice that when you draw line and start move away, the length of the line is getting shorter, but the width remains unchanged!!!How can i avvoid this, and draw line that gets tighter when i move the camera away?

*Aaron*
09-30-2002, 10:52 AM
I think what he means is he wants the line to get thinner as it get farther away. OpenGL doesn't change the thickness of lines or points based on distance. There is an extension that does this for points, but it doesn't seem to be widely supported. I guess you could make "lines" get thinner as they get farther away by drawing them as thin rectangular prisms instead.