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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include <GL/glut.h>
#include <stdlib.h>
static void init (void)
{
/*
* Couleur de vidage.
*/
glClearColor (0.0, 0.0, 0.0, 0.0);
/*
* Initialise les valeurs de point de vue.
*/
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
static void display (void)
{
/*
* Vidage de la fenetre.
*/
glClear (GL_COLOR_BUFFER_BIT);
/*
* Dessins de la scene.
*/
glColor3f (1.0, 1.0, 1.0);
glBegin (GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd ();
/*
* Traitement des routines OpenGL du tampon.
*/
glFlush ();
}
int main (int argc, char ** argv)
{
/*
* Creation d'une fenetre OpenGL.
*/
glutInit (& argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (250, 250);
glutInitWindowPosition (100, 100);
glutCreateWindow ("C OpenGL Application");
/*
* Initialisation de la scene.
*/
init ();
/*
* Affichage et lancement de la boucle OpenGL.
*/
glutDisplayFunc (display);
glutMainLoop ();
return EXIT_SUCCESS;
} |
Partager