Vous êtes sur la page 1sur 2

/*OPENGL PROJECT*/

#include <windows.h> // for MS Windows


#include <GL/glut.h> // GLUT, include glu.h and gl.h

void display() {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f); // Red
glVertex2f(0.5,1.0);
glVertex2f( 0.5,0.8 );
glVertex2f( 0.3,0.7 );
glVertex2f(0.3,0.9 );
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0,1.0,0.0);
glVertex2f(0.1,0.9);
glVertex2f(0.8,0.1);
glVertex2f(0.8,0.3);
glEnd();

glBegin(GL_LINES);
glColor3f(0.0,0.0,1.0);
glVertex2f(0.3,0.7);
glVertex2f(0.1,0.7);
glEnd();

glBegin(GL_LINE_STRIP);
glColor3f(0.0,1.0,0.0);
glVertex2f(0.3,0.3);
glVertex2f(0.2,0.4);
glVertex2f(0.4,0.5);
glVertex2f(0.2,0.6);
glEnd();

glBegin(GL_LINE_LOOP);
glColor3f(0.0,1.0,1.0);
glVertex2f(0.8,0.5);
glVertex2f(1.0,0.4);
glVertex2f(1.0,0.2);
glVertex2f(0.9,0.2);
glVertex2f(0.85,0.3);
glEnd();

glBegin(GL_TRIANGLE_STRIP);
glColor3f(1.0,1.0,0.0);
glVertex2f(0.8,0.9);
glVertex2f(0.7,1.0);
glVertex2f(0.7,0.7);
glVertex2f(0.7,0.5);
glVertex2f(0.8,0.7);
glVertex2f(0.7,0.7);
glEnd();
glBegin(GL_QUAD_STRIP);
glColor3f(0.0, 1.0, 0.0);
glVertex2f(0.1,0.2);
glVertex2f( 0.1,0.4 );
glVertex2f( 0.2,0.3 );
glVertex2f( 0.2,0.2);
glEnd();

glBegin(GL_TRIANGLE_FAN);
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.1,-0.6);
glVertex2f(-0.1,-0.9);
glVertex2f(-0.2,-0.75);
glColor3f(0.0,1.0,0.0);
glVertex2f(-0.3,-0.6);
glColor3f(0.0,0.0,1.0);
glVertex2f(-0.3,-0.9);
glColor3f(1.0,1.0,0.0);
glVertex2f(-0.1,-0.9);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1.0,0.0,0.0);
glVertex2f(-0.3,-0.1);
glVertex2f(-0.5,-0.3);
glVertex2f(-0.5,-0.5);
glVertex2f(-0.5,-0.3);
glVertex2f(-0.1,-0.3);

glEnd();

glFlush();
}

int main(int argc, char** argv) {


glutInit(&argc, argv);
glutCreateWindow("OpenGL Setup Test");
glutInitWindowSize(400, 400);
glutInitWindowPosition(50, 50);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

Vous aimerez peut-être aussi