//Draw a 3-sided pyramid
glBegin(GL_TRIANGLES);
//DAC (points must be listed in counterclockwise order)
glColor3f(1.0f, 0.0f,0.0f); //RED
glVertex3f(1.0f, -1.0f,-0.798f); //D
glColor3f(0.0f, 1.0f,0.0f); //GREEN
glVertex3f(0.0f, -0.333f,0.798f); //A
glColor3f(0.0f, 0.0f,1.0f); //BLUE
glVertex3f(-1.0f, -1.0f,-0.798f); //C
//DCB
glColor3f(1.0f, 0.0f,0.0f); //RED
glVertex3f(1.0f, -1.0f,-0.798f); //D
glColor3f(0.0f, 0.0f,1.0f); //BLUE
glVertex3f(-1.0f, -1.0f,-0.798f); //C
glColor3f(1.0f, 0.0f,1.0f); //Violet
glVertex3f(0.0f,1.0f,-0.798f); //B
//CAB
glColor3f(0.0f, 0.0f,1.0f); //BLUE
glVertex3f(-1.0f, -1.0f,-0.798f); //C
glColor3f(0.0f, 1.0f,0.0f); //GREEN
glVertex3f(0.0f, -0.333f,0.798f); //A
glColor3f(1.0f, 0.0f,1.0f); //Violet
glVertex3f(0.0f,1.0f,-0.798f); //B
//BAD
glColor3f(1.0f, 0.0f,1.0f); //Violet
glVertex3f(0.0f,1.0f,-0.798f); //B
glColor3f(0.0f, 1.0f,0.0f); //GREEN
glVertex3f(0.0f, -0.333f,0.798f); //A
glColor3f(1.0f, 0.0f,0.0f); //RED
glVertex3f(1.0f, -1.0f,-0.798f); //D
glEnd();
No comments:
Post a Comment