glBegin(GL_POLYGON)
glVertex3f(0.0,0.0,0.0); glVertex3f(0.0,0.1,0.0); glVertex3f(1.0,0.0,0.0); glVertex3f(1.0,0.1,0.0); glEnd() |
glBegin(GL_QUADS)
...a list of 24 glVertices here... glEnd() |
typedef point GLFloat[3];
point node[8]={{0.0, 0.0, 0.0},{0.0,0.0,1.0},{0.0,1.0,0.0},{0.0,1.0,1.0}, {1.0, 0.0, 0.0},{1.0,0.0,1.0},{1.0,1.0,0.0},{1.0,1.0,1.0}}; |
---|
Glfloat color[][3]={{0.0, 0.0, 0.0},{0.0,0.0,1.0},{0.0,1.0,0.0},{0.0,1.0,1.0},
{1.0, 0.0, 0.0},{1.0,0.0,1.0},{1.0,1.0,0.0},{1.0,1.0,1.0}}; |
void quad(int a, int b, int c, int d)
{ glBegin{GL_POLYGON}; glColor3fv(color[a]); glVertex3fv(node[a]); glColor3fv(color[b]); glVertex3fv(node[b]); glColor3fv(color[c]); glVertex3fv(node[c]); glColor3fv(color[d]); glVertex3fv(node[d]);   glEnd(); } |
void colorcube()
{  : quad(0,3,2,1);  : quad(2,3,7,6);  : quad(0,4,7,3);  : quad(1,2,6,5);  : quad(4,5,6,7);  : quad(0,1,5,4); } |