Le source : EliminationPartiesCachees.cpp
/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Avril 2001 */
/* Illustration de l'emploi ou non */
/* de l'elimination des parties cachees */
/* lors du dessin de triangles */
#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 mode = 0 ;
void display(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
if ( mode )
glEnable(GL_DEPTH_TEST) ;
glBegin(GL_TRIANGLES) ;
glColor4fv(couleurBleu()) ;
glVertex3f(1.0F,-1.5F,-0.5F) ;
glVertex3f(1.5F,1.5F,0.5F) ;
glVertex3f(-1.1F,-0.2F,0.2F) ;
glColor4fv(couleurVert()) ;
glVertex3f(-1.0F,-1.5F,-0.5F) ;
glVertex3f(-1.5F,1.5F,0.5F) ;
glVertex3f(0.5F,-0.5F,0.2F) ;
glColor4fv(couleurRouge()) ;
glVertex3f(-1.2F,1.3F,-0.5F) ;
glVertex3f(1.2F,1.1F,0.5F) ;
glVertex3f(0.1F,-0.5F,0.3F) ;
glEnd() ;
glDisable(GL_DEPTH_TEST) ;
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void myinit (void) {
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glShadeModel(GL_SMOOTH);
glClearColor(0.0,0.0,0.0,0.0);
}
void key(unsigned char key,int x,int y) {
if ( keyManipulateur(key,x,y) )
glutPostRedisplay();
else
switch ( key ) {
case 32 : mode = 1 - mode ;
glutPostRedisplay();
break; }
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(280,280);
glutInitWindowPosition(50,50);
glutCreateWindow("Elimination des parties cachées");
myinit();
creationMenuBasique();
setParametresOrthoBasique(-2.0,2.0,-2.0,2.0,-100.0,100.0);
setManipulateurDistance(1.0F);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(key);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutDisplayFunc(display);
glutMainLoop();
return(0);
}