Can i blend a line?

Started by
4 comments, last by leiavoia 19 years, 10 months ago
All i want to do is this (mockup): The trick is, i want to do it with a GL_LINE, not a quad. Lines don''t seem to blend like a quad does however. With quads and triangles and such, if i specify colors of the vertexes, the colors spread into each other across the polygon. What i would *like* to do is specify a line made of two points and two colors and get a gradient. Can this be done or does it just not work this way? If it cannot be done is there a decent way to fake it? The only thing i can think of is to A) use a quad instead, or B) use a line strip with many segments to make it look like a gradient.
Advertisement
well... You can,

glBegin(GL_LINES);
glColor3f(1,0,0);glVertex3f(-1,0,0);
glColor3f(0,1,0);glVertex3f(1,0,0);
glEnd();

that will draw a line with a smooth gradient.

"I seek knowledge and to help those who also seek it"
"I seek knowledge and to help those who also seek it"
That does not work (at least not on my system). I have blending enabled and a function for blending, i even have the line smoothing and smoothing hint turned on. Still won''t work. I just get a solid green bar with your code.
Try glShadeMode(GL_SMOOTH), disable blending as you don''t need it, the colors are interpolated anyway.
glShadeMode(GL_SMOOTH) was it. thank! can''t believe i overlooked that. I still need blending for everything else, but you solved the problem.
glShadeMode(GL_SMOOTH) i want to know what using for else the color?

This topic is closed to new replies.

Advertisement