PDA

View Full Version : Filling polygons with colors



Ramesh
11-29-2000, 04:56 AM
Hi
I am generating polygons in 3D space. I want to fill them with colors. How can I do it. How to generate polygons in this case, like connection of vertices between glBegin( GL_LINE_LOOP) and glEnd, or in different form
thanks

mcbastian
11-29-2000, 05:13 AM
try

glBegin(GL_TRIANGLES);

glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);

glEnd();

...

best for you is nehe.gamedev.org look at the opengl-turorials there, so you can learn lots of things and effects.

sebastian.

Ramesh
11-29-2000, 05:29 AM
Hi
it works with following modification
glBegin(GL_POLYGON);

glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);
glColor3f(red,green,blue);glvertex3f(x,y,z);


glEnd();