 
 
Fichier source : TextureBitmap.cpp
/* Fonction d'initialisation des parametres     */
    /* OpenGL ne changeant pas au cours de la vie   */
    /* du programme                                 */
    /* Contient en particulier l'initialisation     */
    /* d'une texture 2D                             */
    
    static void init(void) {
      const GLfloat mat_shininess[] = { 50.0 };
      glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
      glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
      glLightfv(GL_LIGHT0,GL_DIFFUSE,gris);
      glLightfv(GL_LIGHT1,GL_DIFFUSE,gris);
      glLightfv(GL_LIGHT2,GL_DIFFUSE,gris);
      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      glEnable(GL_LIGHT1);
      glEnable(GL_LIGHT2);
      glDepthFunc(GL_LESS);
      glEnable(GL_DEPTH_TEST);
      glEnable(GL_NORMALIZE);
      glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1);
      glEnable(GL_TEXTURE_2D);
      glPixelStorei(GL_UNPACK_ALIGNMENT,1); 
      { int rx;
        int ry;
        unsigned char *img = chargeImagePng("Test.png",&rx,&ry);
        if ( img ) {
          glTexImage2D(GL_TEXTURE_2D,0,3,rx,ry,0,GL_RGB,GL_UNSIGNED_BYTE,img);
          free(img); } }
      glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); 
      glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
      glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); 
      glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); 
    }
    
    /* Scene dessinee :                             */
    /* Un carre texture                             */
    
    static void scene(void) {
      glPushMatrix();
      glBegin(GL_QUADS);
      glNormal3f(0.0F,0.0F,1.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex2f(-3.0,-3.0);
      glTexCoord2f(1.0F,0.0F);
      glVertex2f( 3.0,-3.0);
      glTexCoord2f(1.0F,1.0F);
      glVertex2f( 3.0, 3.0);
      glTexCoord2f(0.0F,1.0F);
      glVertex2f(-3.0, 3.0);
      glEnd();
      glPopMatrix();
    }