
faucheuse
|
#include <iostream> #include <stdlib.h>
#include <gl\glut.h>
using namespace std ;
void Clavier(unsigned char KeyPress, int x, int y) { switch (KeyPress) { case 27 : exit(0) ; } }
void InitRendering(void) { glEnable(GL_DEPTH_TEST) ; glEnable(GL_COLOR_MATERIAL) ; glEnable(GL_LIGHTING) ; glEnable(GL_LIGHT0) ; glEnable(GL_LIGHT1) ; glEnable(GL_NORMALIZE) ; }
void Resize(int w, int h) { glViewport(0,0,w,h) ;
glMatrixMode(GL_PROJECTION) ; glLoadIdentity() ; gluPerspective(45.0, (double)w/(double)h, 1.0, 200.0) ; }
float _angle = 10.0 ; void Affichage() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ; glMatrixMode(GL_MODELVIEW) ; glLoadIdentity() ;
glTranslatef(0.0f, 0.0f, -10.0f) ; // Ajoute une lumière ambiante GLfloat AmbientColor[] = {0.2f, 0.2f, 0.2f, 1.0f} ; // couleur (2.0, 2.0, 2.0) glLightModelfv(GL_LIGHT_MODEL_AMBIENT, AmbientColor) ; //Positonne un spot
glPushMatrix() ; glRotatef(_angle, 0.0f, 1.0f, 0.0f) ;
glBegin(GL_QUADS) ;
//devant glColor3f(0.0f, 1.0f, 0.0f) ; glVertex3f(1.0f, 1.0f, 0.0f) ; glVertex3f(1.0f, -1.0f, 0.0f) ; glVertex3f(-1.0f, -1.0f, 0.0f) ; glVertex3f(-1.0f, 1.0f, 0.0f) ; //derrière glColor3f(1.0f, 0.0f, 0.0f) ; glVertex3f(1.0f, 1.0f, -2.0f) ; glVertex3f(1.0f, -1.0f, -2.0f) ; glVertex3f(-1.0f, -1.0f, -2.0f) ; glVertex3f(-1.0f, 1.0f, -2.0f) ; //droite glColor3f(0.0f, 0.0f, 1.0f) ; glVertex3f(1.0f, 1.0f, -2.0f) ; glVertex3f(1.0f, -1.0f, -2.0f) ; glVertex3f(1.0f, -1.0f, 0.0f) ; glVertex3f(1.0f, 1.0f, 0.0f) ;
//gauche glColor3f(1.0f, 1.0f,1.0f) ; glVertex3f(-1.0f, -1.0f, -2.0f) ; glVertex3f(-1.0f, 1.0f, -2.0f) ; glVertex3f(-1.0f, 1.0f, 0.0f) ; glVertex3f(-1.0f, -1.0f, 0.0f) ;
glEnd() ; glPopMatrix() ;
glutSwapBuffers() ; }
void update(int valeur) { _angle += 1 ; if (_angle > 360) { _angle -= 360 ; }
glutPostRedisplay() ; glutTimerFunc(25, update, 0); }
int main(int charc, char** charv) { glutInit(&charc, charv) ; glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ; glutInitWindowSize(700, 700) ; glutCreateWindow("Essayons de comprendre l'éclairage avec Faucheuse ^^") ;
InitRendering() ; glutKeyboardFunc(Clavier) ; glutReshapeFunc(Resize) ; glutDisplayFunc(Affichage) ; glutTimerFunc(25, update, 0);
glutMainLoop() ; return 0 ; }
voila voila, pourrioez vous m'expliquer pourquoi l'eclairage baisse svp?
merci d'avance
|