PDA

View Full Version : Thik lines



devdept
01-04-2008, 11:56 AM
Hi All,


Is there a way to avoid this ugly effect of thick lines?

http://www.devdept.com/thickness.jpg

The red arrow points to an arc drawn with: glLineWidth(8);

I have also tryed activating line antialiasing but nothing changes.


Thanks in advance,

Alberto

-NiCo-
01-04-2008, 01:19 PM
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glLineWidth(8);
//draw lines


Cheers,
N.

zed
01-05-2008, 03:41 AM
LineWidth prolly aint gonna give the best results but it certainly shouldnt be that bad, it looks like youre missing parts try GL_LINE_LOOP or GL_LINE_STRIP (i think thats the syntax) instead of GL_LINES

if that doesnt work for better lines u need to do the AA yourself eg in a fragment program or use textured quads for the lines

devdept
01-05-2008, 09:13 AM
Hi Guys,


We don't wanted to activate antialiasing, because it would reduce overall performances.

BTW we are already using GL_LINE_STRIP.

Looks like the only solution is activating antialiasing.


Thanks,

Alberto

-NiCo-
01-05-2008, 10:08 AM
What's wrong with the solution I provided:


glClearColor(1.0,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

unsigned int subdiv = 256;
float radius = 0.5f;

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

glColor3f(0.0f,0.0f,0.0f);
glLineWidth(8.0f);
glBegin(GL_LINE_LOOP);
for (unsigned int i=0;i<subdiv;++i)
glVertex2f(radius*cos(2*M_PI*i/subdiv),radius*sin(2*M_PI*i/subdiv));
glEnd();

glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);


This works like a charm without a multisample buffer.

Cheers,
N.