GlEnable GL_LINE_SMOOTH
BlitzMax Forums/BlitzMax Beginners Area/GlEnable GL_LINE_SMOOTH
| ||
Is this implemented? I am using the Windows Beta. This is some code SetColor(255,255,255) SetLineWidth(1) GlEnable GL_LINE_SMOOTH DrawLine(1,1,200,20) GlEnable GL_LINE_SMOOTH glBegin GL_LINES glVertex2f 0,0 glVertex2f 100,400 glEnd Niether line is antialiased. |
| ||
You need to make sure you've got blending switched on, but sometimes graphics card drivers switch line anti-aliasing off anyway. This is what they do in the OpenGL Red Book: glEnable (GL_LINE_SMOOTH); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glLineWidth (1.5); But I'd also change "GL_DONT_CARE" to "GL_NICEST". Sometimes line anti-aliasing just doesn't work, and it's not particularly fast. I've seen a clever hack that uses a thin alpha-blended texture instead on a line, which is often faster, believe it or not. |
| ||
Thanks TeaMonkey, Just found that myself in the Redbook. I am already using textures and quads to do this but I thought I might see if this way was faster. |
| ||
So the code teamonkeky posted will run unmodified? Because I'd like to use it. I don't understand OpenGL (see other posts by me). |
| ||
Diornda, Here is the code I use to get The antialiased line. Great thing about MAX is that you can "mix-and-match" Global Width:Int=800 Global Height:Int=600 Global Depth:Int=32 Graphics 800,600,32,0 HideMouse While Not KeyHit( KEY_ESCAPE ) glColor3f(1.0,1.0,1.0) glLineWidth 1 GlEnable GL_LINE_SMOOTH GlEnable GL_BLEND glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA glHint GL_LINE_SMOOTH_HINT, GL_NICEST DrawLine(0,0,200,500) Framecounter_counter=Framecounter_counter+1 If Framecounter_time=0 Then Framecounter_time=MilliSecs() If Framecounter_time+1001 <MilliSecs() Then Framecounter_framerate=Framecounter_counter Framecounter_counter=0 Framecounter_time=MilliSecs() EndIf glColor3f(1.0,1.0,1.0) bglDrawText("FPS : "+Framecounter_framerate,800-(8*12),600-16-8) FlushMem Flip() Cls() Wend End |
| ||
In answer to my own question, yes, it does. Function enableLineSmoothing(size:Double) 'size is the size of the line glEnable (GL_LINE_SMOOTH); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); glLineWidth (size); End Function What do you have against using SetColor? Is it just that you prefer using the 1.0 method instead of the 255? As far as I know, the 1.0 just gets converted into the 255, resulting in an extra, albeit tiny, step. Thanks for your help. After I finish my current project, I'm going to make an all-vector game based on Gravitar. |
| ||
What do you have against using SetColor? Is it just that you prefer using the 1.0 method instead of the 255? As far as I know, the 1.0 just gets converted into the 255, resulting in an extra, albeit tiny, step. OpenGL can take both. SetColor's just a wrapper for glSetColor4ubv (unsigned byte vector). Your driver will convert the values to integers or floats, depending what the graphics card uses internally. |