/* Auteur: Nicolas JANEY */
/* nicolas.janey@univ-fcomte.fr */
/* Avril 2002 */
/* Texturage d'un quadrilatere */
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ModuleManipulateur.h"
#include "ModuleMenus.h"
#include "ModuleReshape.h"
#define LI 16
#define LH 16
GLubyte image[LI][LH][3];
void makeImage(void) {
int i,j,c;
for( i = 0 ; i < LI ; i++ ) {
for( j = 0 ; j < LH ; j++ ) {
c =(j%2)+(i%2)*2;
switch (c) {
case 0 : image[i][j][0] =(GLubyte) 255;
image[i][j][1] =(GLubyte) 255;
image[i][j][2] =(GLubyte) 255;
break;
case 1 : image[i][j][0] =(GLubyte) 255;
image[i][j][1] =(GLubyte) 0;
image[i][j][2] =(GLubyte) 0;
break;
case 2 : image[i][j][0] =(GLubyte) 0;
image[i][j][1] =(GLubyte) 255;
image[i][j][2] =(GLubyte) 0;
break;
case 3 : image[i][j][0] =(GLubyte) 0;
image[i][j][1] =(GLubyte) 0;
image[i][j][2] =(GLubyte) 255;
break; } } }
}
void myinit(void) {
glClearColor(0.0,0.0,0.0,0.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
makeImage();
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexImage2D(GL_TEXTURE_2D,0,3,LI,LH,0,GL_RGB,GL_UNSIGNED_BYTE,&image[0][0][0]);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_FLAT);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
}
void display(void) {
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
manipulateurSouris();
manipulateurClavier();
glBegin(GL_QUADS);
glTexCoord2f(0.0F,4.0F);
glVertex3f(-0.5F,-0.5F,0.0F);
glTexCoord2f(0.0F,0.0F);
glVertex3f(-0.5F,0.5F,0.0F);
glTexCoord2f(4.0F,0.0F);
glVertex3f(0.5F,0.5F,0.0F);
glTexCoord2f(4.0F,4.0F);
glVertex3f(0.5F,-0.5F,0.0F);
glEnd();
glPopMatrix();
glFlush();
glutSwapBuffers();
}
int main(int argc,char **argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(200,200);
glutInitWindowPosition(50,50);
glutCreateWindow("Un damier");
myinit();
creationMenuBasique();
setParametresOrthoBasique(-0.75,0.75,-0.75,0.75,-5.0,5.0);
setManipulateurDistance(1.0F);
glutReshapeFunc(reshapeOrthoBasique);
glutKeyboardFunc(keyBasique);
glutSpecialFunc(specialBasique);
glutMotionFunc(motionBasique);
glutMouseFunc(sourisBasique);
glutDisplayFunc(display);
glutMainLoop();
return(0);
}