PDA

View Full Version : fun colored line ?



frog
01-16-2001, 03:05 AM
Hi,

I would like to create a line with a degrade effect: for exemple, I want the first point in blue and the second in red and between a degrade of colors between red and blue...Somebody can show me how make ? thanks.

billy
01-16-2001, 03:13 AM
Try assigning a color to each vertex of the line. OpenGL should produce automatically a gradient.

glBegin(GL_LINES);

glColor(1,0,0);

glvertex3f(x1,y1,z1);

glColor(0,0,1);

glvertex3f(x2,y2,z2);

glEnd();

gazzell
01-16-2001, 05:55 AM
Originally posted by frog:
Hi,


I would like to create a line with a degrade effect: for exemple, I want the first point in blue and the second in red and between a degrade of colors between red and blue...Somebody can show me how make ? thanks.

Its very simple:
glBegin (GL_LINES);
glColor3f(0.0f,0.0f,1.0f); //blue
glVertex3f(1.0f,1.0f,0.0f); //1 point
glColor3f(1.0f,0.0f,0.0f); //red
glVertex3f(1.0f,0.0f,0.0f); //2 point
glEnd();

You MUST activate:
glEnable(GL_SMOOTH);
before drawing

gazzell
01-16-2001, 06:12 AM
Originally posted by frog:
Hi,


I would like to create a line with a degrade effect: for exemple, I want the first point in blue and the second in red and between a degrade of colors between red and blue...Somebody can show me how make ? thanks.

Its very simple:
glBegin (GL_LINES);
glColor3f(0.0f,0.0f,1.0f); //blue
glVertex3f(1.0f,1.0f,0.0f); //1 point
glColor3f(1.0f,0.0f,0.0f); //red
glVertex3f(1.0f,0.0f,0.0f); //2 point
glEnd();

You MUST activate:
glEnable(GL_SMOOTH);
before drawing