smooth line drawing using opengl

Started by
4 comments, last by Stani R 18 years, 4 months ago
Hi All, I am doing some graph drawing using opengl on windows 2k. I am facing problem releated to the drawing of the lines of the polygon. The drawing of the object is not smooth when i try to rotate the objects. The lines get distracted (becomes slight zigzag). I just wondering is there any API avaliable in opengl just to make these lines smooth? can any buddy has any clue about the same? Thanks in advance. -Kiran
Advertisement
There's some things you can try to enable antialiasing without much hassle. From memory:

glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

There's some other ways too, but this should get you started. Google "OpenGL Antialiasing" or something like that for more info.
Google for GL_LINE_SMOOTH

EDIT: Like ^he^ said...
Hi ,
Actually i have tried following code to draw smooth lines.
glEnable (GL_POLYGON_SMOOTH);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glLineWidth (1.5f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
but it did't worked.
so any other idea or clue for this.anyway thanks a lot for reply.
kiran.
Quote:Original post by gadekar_k
Hi ,
Actually i have tried following code to draw smooth lines.
glEnable (GL_POLYGON_SMOOTH);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glLineWidth (1.5f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
but it did't worked.
so any other idea or clue for this.anyway thanks a lot for reply.
kiran.


Replace GL_POLYGON_SMOOTH with GL_LINE_SMOOTH :)
And GL_POLYGON_SMOOTH_HINT with GL_LINE_SMOOTH_HINT :)
Also, I'm not sure how a 1.5 line width affects the algorithms, it would seem that thicker lines might appear blockier (but this is just a wild guess way out there).

Other than that, there's always multisampling and such.

Check this page to get a higher-level overview of various antialiasing techniques available to you.

This topic is closed to new replies.

Advertisement