PDA

View Full Version : How to draw lines on a window?



helenw
12-28-2003, 09:53 PM
Hi,

I want to draw lines on a object like a window. But sometime the lines are always sparkling, and they can't be see clear.

I try codes below, however ther are still some errors.
How to do it!

glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);

glClear(GL_STENCIL_BUFFER_BIT);
glPushMatrix();

glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 3, 0xff);
glStencilOp(GL_KEEP, GL_REPLACE, GL_ZERO);
DrawWindow();

glDisable(GL_DEPTH_TEST);
glDepthMask(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_GREATER, 1, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
DrawLines();

glDisable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
glDepthMask(1);

glPopMatrix();

Thanks!

SirKnight
12-28-2003, 10:34 PM
Anti-Aliasing would probably help I think.


-SirKnight

JustHanging
12-29-2003, 01:53 AM
...or polygon offset, search for tutorials.

-Ilkka

helenw
12-30-2003, 02:35 AM
Originally posted by JustHanging:
...or polygon offset, search for tutorials.

-Ilkka

I try it, but it can't resolve the problem

JustHanging
12-30-2003, 12:28 PM
Perhaps you dind't use it properly, check this thread http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/011688.html for an example.

If polygon offset or antialiasing don't solve it, you'll have to describe the problem in more detail, preferably with a screenshot.

-Ilkka