/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Avril 2001 */
/* Les primitives graphiques OpenGL */
#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleCouleurs.h"
#include "ModuleManipulateur.h"
#include "ModuleMenus.h"
#include "ModuleReshape.h"
static int obj = 0 ;
void display(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor4fv(couleurNoir());
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
switch ( obj ) {
case 0 : glBegin(GL_POINTS) ;
glVertex3f(-7.0F,4.0F,1.0F) ;
glVertex3f(8.0F,-1.0F,-2.0F) ;
glVertex3f(-3.0F,7.0F,3.0F) ;
glVertex3f(-1.0F,-8.0F,0.0F) ;
glVertex3f(2.0F,-4.0F,5.0F) ;
glVertex3f(5.0F,8.0F,1.0F) ;
glEnd() ;
break ;
case 1 : glBegin(GL_LINES) ;
glVertex3f(-7.0F,4.0F,-1.0F) ;
glVertex3f(8.0F,-1.0F,2.0F) ;
glVertex3f(-3.0F,7.0F,0.0F) ;
glVertex3f(-1.0F,-8.0F,4.0F) ;
glVertex3f(2.0F,-4.0F,-2.0F) ;
glVertex3f(5.0F,8.0F,3.0F) ;
glEnd() ;
break ;
case 2 : glBegin(GL_LINE_STRIP) ;
glVertex3f(-7.0F,4.0F,-1.0F) ;
glVertex3f(8.0F,-1.0F,2.0F) ;
glVertex3f(-3.0F,7.0F,0.0F) ;
glVertex3f(-1.0F,-8.0F,4.0F) ;
glVertex3f(2.0F,-4.0F,-2.0F) ;
glVertex3f(5.0F,8.0F,3.0F) ;
glEnd() ;
break ;
case 3 : glBegin(GL_LINE_LOOP) ;
glVertex3f(-7.0F,4.0F,-1.0F) ;
glVertex3f(8.0F,-1.0F,2.0F) ;
glVertex3f(-3.0F,7.0F,0.0F) ;
glVertex3f(-1.0F,-8.0F,4.0F) ;
glVertex3f(2.0F,-4.0F,-2.0F) ;
glVertex3f(5.0F,8.0F,3.0F) ;
glEnd() ;
break ;
case 4 : glBegin(GL_POLYGON) ;
glColor4fv(couleurBleu()) ;
glVertex3f(-7.0F,4.0F,0.0F) ;
glVertex3f(-3.0F,7.0F,0.0F) ;
glVertex3f(5.0F,8.0F,0.0F) ;
glVertex3f(8.0F,-1.0F,0.0F) ;
glVertex3f(2.0F,-4.0F,0.0F) ;
glVertex3f(-1.0F,-8.0F,0.0F) ;
glEnd() ;
break ;
case 5 : glBegin(GL_QUADS) ;
glColor4fv(couleurBleu()) ;
glVertex3f(-7.0F,2.0F,1.0F) ;
glVertex3f(-1.0F,7.0F,1.0F) ;
glVertex3f(2.0F,6.0F,1.0F) ;
glVertex3f(-6.0F,-3.0F,1.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(3.0F,-8.0F,-2.0F) ;
glVertex3f(7.0F,-5.0F,-2.0F) ;
glVertex3f(9.0F,2.0F,-2.0F) ;
glVertex3f(1.0F,-3.0F,-2.0F) ;
glEnd() ;
break ;
case 6 : glBegin(GL_QUAD_STRIP) ;
glColor4fv(couleurBleu()) ;
glVertex3f(-7.0F,5.0F,0.0F) ;
glVertex3f(-3.0F,8.0F,0.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(-4.0F,-2.0F,0.0F) ;
glVertex3f(0.0F,3.0F,0.0F) ;
glColor4fv(couleurVert()) ;
glVertex3f(2.0F,-2.5F,0.0F) ;
glVertex3f(3.0F,5.0F,0.0F) ;
glColor4fv(couleurCyan()) ;
glVertex3f(8.5F,0.0F,0.0F) ;
glVertex3f(8.0F,2.0F,0.0F) ;
glEnd() ;
break ;
case 7 : glBegin(GL_TRIANGLES) ;
glColor4fv(couleurBleu()) ;
glVertex3f(-7.0F,-6.0F,2.0F) ;
glVertex3f(-5.0F,7.0F,-4.0F) ;
glVertex3f(2.0F,-5.0F,-1.0F) ;
glColor4fv(couleurVert()) ;
glVertex3f(-3.0F,8.0F,-5.0F) ;
glVertex3f(7.0F,-5.0F,3.0F) ;
glVertex3f(9.0F,7.0F,2.0F) ;
glEnd() ;
break ;
case 8 : glBegin(GL_TRIANGLE_STRIP) ;
glColor4fv(couleurBleu()) ;
glVertex3f(-7.0F,5.0F,3.0F) ;
glVertex3f(-3.0F,8.0F,2.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(-4.0F,-2.0F,-1.0F) ;
glVertex3f(0.0F,3.0F,0.0F) ;
glColor4fv(couleurVert()) ;
glVertex3f(2.0F,-2.5F,5.0F) ;
glVertex3f(3.0F,5.0F,3.0F) ;
glColor4fv(couleurCyan()) ;
glVertex3f(8.5F,0.0F,-1.0F) ;
glVertex3f(8.0F,2.0F,-2.0F) ;
glEnd() ;
break ;
case 9 : glBegin(GL_TRIANGLE_FAN) ;
glColor4fv(couleurBleu()) ;
glVertex3f(0.0F,7.0F,3.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(-7.0F,-2.0F,2.0F) ;
glColor4fv(couleurVert()) ;
glVertex3f(-4.0F,-6.0F,-1.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(-1.0F,-8.0F,0.0F) ;
glColor4fv(couleurVert()) ;
glVertex3f(1.0F,-1.0F,5.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(3.0F,-4.0F,3.0F) ;
glColor4fv(couleurVert()) ;
glVertex3f(6.0F,1.0F,-1.0F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(8.0F,5.0F,-2.0F) ;
glEnd() ; }
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void myinit (void) {
glClearColor(1.0,1.0,1.0,1.0);
glEnable(GL_DEPTH_TEST) ;
}
void key(unsigned char key,int x,int y) {
if ( keyManipulateur(key,x,y) )
glutPostRedisplay();
else
switch ( key ) {
case 32 : obj++ ;
if ( obj == 10 )
obj = 0 ;
glutPostRedisplay();
break; }
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(200,200);
glutInitWindowPosition(50,50);
glutCreateWindow("Primitives graphiques");
myinit();
creationMenuBasique();
setParametresOrthoBasique(-10.0,10.0,-10.0,10.0,-500.0,500.0);
setManipulateurDistance(1.0F);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(key);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutDisplayFunc(display);
glutMainLoop();
return(0);
}