PDA

View Full Version : glLineStipple



MeadowDreamer
06-23-2002, 10:36 PM
Hello together. I have one problem. I want draw a cube and i want only see the lines. I want that the lines in the front are normal and the lines in the background are stipple. How can I draw two different kind of lines where the lines in the front without stipple and the lines in the background are with stipple ?

mikael_aronsson
06-23-2002, 11:40 PM
Hi !

You can change the stipple type any time you want like:

change stipple type
glBegin( GL_blabla)
glVertex...
glEnd()
change stipple type
glBegin( GL_blabla)
glVertex...
glEnd()

And so on.

What you don't get is any help with what lines are in "front" and which are "back", you have to calculate that yourself.

Mikael

MeadowDreamer
06-24-2002, 12:07 AM
Yes i can do this, but this isn't my problem. Maybe i haven't found the right words. For example you have a cube and you want that the cube exist only with lines. You can take
glPolygonMode(..., GL_LINE);
glBegin(GL_POLYGON)
glVertex(..);
..
glEnd();
The result is that i see all lines from the cube. But if you have seen a technical drawing once you can see the lines in the backgrounds only in stipple or in a another kind of line (3D). I have written a code where i can turn the cube and my normal vectors from the polygons show away from the center. My idea was that the side who show to the center is with stipple and the other one should be draw with fill lines.
//draw the front line
glPolygonMode(GL_FRONT, GL_LINE);
glBegin(GL_POLYGON);
glVertex(...);
...
glEnd();
// new kind of line
glLineStipple(.....);
glBegin(GL_LINE_STRIP);
// draw the back line
glPolygonMode(GL_BACK, GL_LINE);
glBegin(GL_POLYGON);
glVertex(...);
...
glEnd();
glLineStipple(.....);


But i see the lines only in one kind of way, that means both sides have the same kind of line. How can i change it ?

06-24-2002, 10:12 AM
Draw it in two passes as such:

-disable line stipple, cull back faces, draw front faces as lines
-draw cube
-enable line stipple, cull front faces, draw
back faces as lines
-draw cube

MeadowDreamer
06-25-2002, 03:27 AM
Thanks for your help. :-)
Your idea with the glCullFace(..) was right. Only one small thing was wrong. First of all you should draw the stipple lines (lines from the back faces) and then you should draw
the normal lines (lines from the front faces)

-enable line stipple, cull front faces, draw
back faces as lines
-draw cube
-disable line stipple, cull back faces, draw
front faces as lines
-draw cube