#include "glut.h"
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
glColor3f(1, 0, 0);
glBegin(GL_TRIANGLES);
glVertex3f(1,0,0);
glVertex3f(0.5,0.5,0);
glVertex3f(0.5,0,0);
glEnd( );
glColor3f(0, 1, 0);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,0);
glVertex3f(0.3,0.5,0);
glVertex3f(0.3,0,0);
glEnd( );
glColor3f(1, 1, 0);
glBegin(GL_TRIANGLES);
glVertex3f(-1,-1,0);
glVertex3f(-0.3,-0.4,0);
glVertex3f(-0.3,0,0);
glEnd( );
glColor3f(0, 1, 1);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,0);
glVertex3f(-0.3,-0.5,0);
glVertex3f(-0.3,0,0);
glEnd( );
glColor3f(0, 0, 1);
glBegin(GL_QUADS);
glVertex3f(0,0,0);
glVertex3f(0.3,0,0);
glVertex3f(0.3,0.3,0);
glVertex3f(0,0.3,0);
glEnd( );
glColor3f(0, 1, 1);
glBegin(GL_QUADS);
glVertex3f(-0.3,-0.6,0);
glVertex3f(-0.1,-0.6,0);
glVertex3f(-0.1,-0.9,0);
glVertex3f(-0.3,-0.9,0);
glEnd( );
glColor3f(1, 0, 1);
glBegin(GL_QUADS);
glVertex3f(-0.9,0.9,0);
glVertex3f(-0.6,0.9,0);
glVertex3f(-0.6,0.4,0);
glVertex3f(-0.9,0.4,0);
glEnd( );
glColor3f(1, 1, 1);
glBegin(GL_QUADS);
glVertex3f(0.3,-0.3,0);
glVertex3f(0.6,-0.3,0);
glVertex3f(0.6,-0.6,0);
glVertex3f(0.3,-0.6,0);
glEnd( );
glutSwapBuffers();
glBegin(GL_POINTS);
glVertex3f(10.0f, 0.0f, 0.0f);
glEnd();
}
void main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE GLUT_RGB GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(100, 100);
glutCreateWindow("Squares and Triangles");
glutDisplayFunc(myDisplay);
glutMainLoop();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment