void display()
{
glClearColor(0,0,1,3);// The background color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Using Double Buffer and Depth Buffer
glColor3f(1,0,1); // Have three float argument, to change the thing's color
glBegin(GL_LINE_LOOP);// Begin to draw a polygon,
//or using GL_POLYGON to draw a polygon
glVertex3f(0.5,0,0); // To draw the point, the argument means x,y,z axis
glVertex3f(0,1,0);
glVertex3f(1,0,0);
glVertex3f(3,0,0);
glVertex3f(3,5,0);
glEnd(); // End Drawing
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT");
glutDisplayFunc(display); // Register display function.
glutMainLoop();
}
沒有留言:
張貼留言