1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| /*On commence simple un carre blanc sur fond noir*/
#include <GL/GLUT.h> // ligne 2 !
#include <stdlib.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);// blanc
glBegin(GL_POLYGON);/* faire un polygone felier chaque point qui sont definie en bas il y a que 4 point donc on aurait pu utiliser QUADS*/
glVertex3f(0.25, 0.25, 0.0);/*point 1 (X,Y,Z) Z n'est pas en definie car pour l'instant on travail en 2D*/
glVertex3f(0.75, 0.25, 0.0);//point 2 (X,Y,Z)
glVertex3f(0.75, 0.75, 0.0);//point 2 (X,Y,Z)
glVertex3f(0.25, 0.75, 0.0);//point 2 (X,Y,Z)
glEnd();
glFlush();
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);//fond noir
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);/*posistion de la camera bien que l'on travaille en 2D l'environement est en 3D*/
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);//taille de la fenetre
glutInitWindowPosition(100, 100);//posistion de la fenetre
glutCreateWindow("SKone");//non de la fenetre
init();
glutDisplayFunc(display);
glutMainLoop();//routine
return 0;
} |
Partager