/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Avril 2001 */
/* Une animation par survol */
/* d'un tapis de spheres */
#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 float z = 0.0F ;
static float dz = 1.0F ;
void myinit(void) {
GLfloat shinines[] = { 50.0F };
GLfloat l_pos[] = { 1.0F,1.0F,1.0F,0.0F };
glClearColor(0.5F,0.5F,1.0F,1.0F) ;
glMaterialfv(GL_FRONT,GL_SPECULAR,couleurBlanc());
glMaterialfv(GL_FRONT,GL_SHININESS,shinines);
glLightfv(GL_LIGHT0,GL_POSITION,l_pos);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
}
void ligne(void) {
glPushMatrix() ;
glutSolidSphere(1.0,12,12) ;
for ( int x = 0 ; x < 4 ; x++ ) {
glTranslatef(5.0F,0.0F,0.0F) ;
glutSolidSphere(1.0,12,12) ; }
glPopMatrix() ;
}
void display(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0F,-5.0F,0) ;
manipulateurSouris();
manipulateurClavier();
glTranslatef(0.0F,0.0F,z) ;
for ( int z = 0 ; z < 20 ; z++ ) {
glPushMatrix();
glTranslatef(-10.0F,0.0F,-5.0F*z) ;
ligne() ;
glPopMatrix(); }
glPopMatrix();
glFlush();
glutSwapBuffers();
}
void idle(void) {
z+= dz ;
if ( ( z == 100 ) || ( z == -15 ) )
dz = -dz ;
glutPostRedisplay() ;
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(250,250);
glutInitWindowPosition(50,50);
glutCreateWindow("Sphères blanches en survol");
myinit();
creationMenuBasique();
setParametresFrustumBasique(-2.5F,2.5F,-2.5,2.5F,3.0F,1000.0F,0.0F,0.0F,0.0F);
setManipulateurDistance(20.0F);
glutReshapeFunc(reshapeFrustumBasique);
glutKeyboardFunc(keyBasique);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutIdleFunc(idle);
glutDisplayFunc(display);
glutMainLoop();
return(0);
}