PDA

View Full Version : Is setting line smoothing retrospective?



Qu0ll
05-09-2011, 08:06 AM
I am drawing a line without enabling line smoothing, then I enable line smoothing with:


glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

and to my surprise the first line is smoothed as well (which is not what I want).

So why is this seemingly retrospective and how can I draw one line not smoothed and then another one with smoothing applied? I have tried glFlush() between drawing the lines but it didn't help.

ZbuffeR
05-09-2011, 08:12 AM
Do you disable GL_LINE_SMOOTH before drawing the first line ?
Nothing to do at all with glFlush()

Qu0ll
05-09-2011, 08:29 AM
OK, I do now and it is working, but why do I need to disable line smoothing BEFORE I draw the first line? Does that mean it is enabled by default?

mhagain
05-09-2011, 09:31 AM
State carries over from frame to frame. So what you're doing is effectively this:

frame 1:
- clear screen
- draw line 1 // line smoothing is disabled
- enable line smoothing
- draw line 2 // line smoothing is enabled

frame 2 and above:
- clear screen
- draw line 1 // line smoothing is still enabled!!!
- enable line smoothing
- draw line 2 // line smoothing is enabled

Qu0ll
05-09-2011, 10:08 AM
Yes, that is correct indeed! Thanks to you both :-)