/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Fevrier 2002 */
/* Orientation du repere lie a l'observateur */
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleCouleurs.h"
#include "ModuleFleche.h"
#include "ModuleFont.h"
#include "ModuleManipulateur.h"
#include "ModuleMenus.h"
#include "ModuleReshape.h"
static int f1;
void axes(float lx1,float lx2,float ly1,float ly2,float lz1,float lz2,char *x,char *y,char *z) {
glPushAttrib(GL_LIGHTING);
glEnable(GL_LIGHTING);
setFont(GLUT_BITMAP_8_BY_13,CENTER);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurRouge());
flecheEnVolume(1.0F,0.0F,0.0F,0.1F,0.3F,0.02F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurVert());
flecheEnVolume(0.0F,1.0F,0.0F,0.1F,0.3F,0.02F);
glMaterialfv(GL_FRONT,GL_DIFFUSE,couleurBleu());
flecheEnVolume(0.0F,0.0F,1.0F,0.1F,0.3F,0.02F);
glDisable(GL_LIGHTING);
glColor4fv(couleurRougeFonce());
bitmapStringOutput(1.1F,-0.2F,0.0F,x);
glColor4fv(couleurRougeFonce(0.5F));
glBegin(GL_LINES);
glVertex3f(lx1,0.0F,0.0F);
glVertex3f(-lx2,0.0F,0.0F);
glEnd();
glColor4fv(couleurVertFonce());
bitmapStringOutput(0.0F,1.2F,0.0F,y);
glColor4fv(couleurVertFonce(0.5F));
glBegin(GL_LINES);
glVertex3f(0.0F,ly1,0.0F);
glVertex3f(0.0F,-ly2,0.0F);
glEnd();
glColor4fv(couleurBleuFonce());
bitmapStringOutput(0.0F,-0.2F,1.1F,z);
glColor4fv(couleurBleuFonce(0.5F));
glBegin(GL_LINES);
glVertex3f(0.0F,0.0F,lz1);
glVertex3f(0.0F,0.0F,-lz2);
glEnd();
setFont(GLUT_BITMAP_8_BY_13,LEFT);
glPopAttrib();
}
void myinit(void) {
GLfloat light_position0[] = { 1.0F,0.0F,1.0F,0.0F };
GLfloat light_position1[] = { -1.0F,0.0F,1.0F,0.0F };
glLightfv(GL_LIGHT0,GL_AMBIENT,couleurNoir());
glLightfv(GL_LIGHT0,GL_DIFFUSE,couleurBlanc());
glLightfv(GL_LIGHT1,GL_DIFFUSE,couleurBlanc());
glLightfv(GL_LIGHT0,GL_SPECULAR,couleurNoir());
glLightfv(GL_LIGHT0,GL_POSITION,light_position0);
glLightfv(GL_LIGHT1,GL_POSITION,light_position1);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glDepthFunc(GL_LESS);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
}
void display(void) {
glClearColor(0.85F,0.85F,0.65F,1.0F);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glPushMatrix() ;
manipulateurSouris();
manipulateurClavier();
axes(100.0F,100.0F,100.0F,100.0F,100.0F,100.0F,"x","y","z");
glColor4fv(couleurNoir());
bitmapStringOutput(0.2F,-0.2F,0.2F,"O");
glPopMatrix() ;
glFlush();
glutSwapBuffers() ;
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowPosition(10,50);
glutInitWindowSize(200,200);
f1 = glutCreateWindow("Repere observateur");
myinit();
creationMenuBasique();
setParametresOrthoBasique(-2.0,2.0,-2.0,2.0,-100.0,100.0);
setManipulateurDistance(1.0F);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(keyBasique);
glutSpecialFunc(specialBasique);
glutDisplayFunc(display);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutMainLoop();
return(0);
}