Sign in to follow this  
gadekar_k

OpenGL smooth line drawing using opengl

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this