Antialiasing DrawLine()

BlitzMax Forums/BlitzMax Beginners Area/Antialiasing DrawLine()

Will(Posted 2005) [#1]
How do I antialias my lines / polys?


ImaginaryHuman(Posted 2005) [#2]
Add:

glEnable(GL_LINE_SMOOTH)

Anything drawn after that will draw antialiased lines so long as it is supported by the OpenGL implementation, and it doesn't necessarily work on all systems.

glDisable(GL_LINE_SMOOTH) switches it off.

also glEnable(GL_POLYGON_SMOOTH) enables smoothing for polygon edges, but you are supposed to also set up glEnable(GL_BLEND) and glBlendFunc() with the appropriate blend mode, and supposed to draw the polygons in order I think.

You could perhaps draw a regular polygon and then draw the outline using antialised lines over the top, or underneath.


fredborg(Posted 2005) [#3]
You should also increase the line width to get it looking better, something like this works well:
glLineWidth(1.7)
glEnable(GL_LINE_SMOOTH)


Will(Posted 2005) [#4]
i tried putting

"glLineWidth(1.7)
glEnable(GL_LINE_SMOOTH)"

in my main while loop, but i cant see any difference, zooming in on my app shows jaggies are just as jagged as before. Is there anything else i need to do to enable it, or are there commands i might be using that disable it?


fredborg(Posted 2005) [#5]
You only need it at the start of your program. If you do not see any difference your graphics card probably doesn't support it.


skidracer(Posted 2005) [#6]
I would try enabling alpha blending also, this works for me:
Graphics 640,480
SetBlend ALPHABLEND
glEnable(GL_LINE_SMOOTH)
DrawLine 0,0,640,300
Flip
WaitMouse



ImaginaryHuman(Posted 2005) [#7]
You shouldn't need an alpha blend for line antialiasing. It may be that it is not supported by your hardware.


Will(Posted 2005) [#8]
I am using a radeon 9600 - its not too old, probably supports it.


Barnabius(Posted 2005) [#9]
I am using ATI X800XT PT and it still needs ALPHABLEND in order to get GL_LINE_SMOOTH working properly.

Barney


Will(Posted 2005) [#10]
Thanks, it works for me now.