#include <GL/glut.h>
#include <stdlib.h>
void display (void)
{
static GLint vertices [] = {1,1,0, 10,1,0, 1,10,0, 10,10,0, 1,1,10, 10,1,10, 1,10,10,
10,10,10};
static GLfloat colors_RGB [] = {1.0,0.2,0.2, 0.2,0.2,1.0, 0.8,1.0,0.2, 0.75,0.75,0.75,
0.35,0.35,0.35, 0.5,0.5,0.5};
glEnableClientState (GL_COLOR_ARRAY);
glEnableClientState (GL_VERTEX_ARRAY);
glColorPointer (3, GL_FLOAT, 0, colors_RGB);
glVertexPointer (3, GL_INT, 0, vertices);
static GLubyte toutLesSommets [] = { 1,2,3,4, 1,5,7,3, 1,5,6,2, 2,6,8,4, 3,7,8,4, 7,8,6,5};
glPolygonMode (GL_FRONT , GL_LINE) ;
glFrontFace (GL_CW) ;
glEnable (GL_CULL_FACE) ;
glCullFace (GL_BACK) ;
glDrawElements (GL_QUADS, 24, GL_UNSIGNED_BYTE, toutLesSommets) ;
glutSwapBuffers() ;
glFlush () ;
}
void main (int argc, char** argv)
{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;
glClearColor (1.0, 1.0, 1.0, 1.0) ;
glClear (GL_COLOR_BUFFER_BIT) ;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (-5.0, 16.0, -5.0, 16.0, -1.0, 16.0) ;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutDisplayFunc (display) ;
glutMainLoop () ;
}
Message édité par airseb le 25-06-2002 à 11:59:43