 
    
Fichier source : PlacageMultiTextures.cppp
#include "PNG\ChargePngFile.h"
    
    /* Fonction de chargement d'une texture         */
    /* a partir d'un fichier image au format png    */
    /* filename : le nom du fichier                 */
    /* @retour : le handle de la texture            */
    
    unsigned int chargementTexturePNG(char *filename) {
      unsigned int textureID = 0;
      glGenTextures(1,&textureID);
      int rx;
      int ry;
      unsigned char *img = chargeImagePng(filename,&rx,&ry);
      if ( img && textureID ) {
        glBindTexture(GL_TEXTURE_2D,textureID);
        glPixelStorei(GL_UNPACK_ALIGNMENT,1);
        glTexImage2D(GL_TEXTURE_2D,0,3,rx,ry,0,GL_RGB,GL_UNSIGNED_BYTE,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);
        free(img); }
        else {
        if ( img ) {
          free(img); }
        if ( textureID ) {
          glDeleteTextures(1,&textureID);
          textureID = 0; } }
      return textureID;
    }
    
    /* Modelisation geometrique d'un cube           */
    /* avec placage de textures sur chacune         */
    /* de ses faces                                 */
    /* ct : la taille du cube                       */
    /* filenames : le tableau des noms              */
    /*             des 6 fichiers png a utiliser    */
    /*             pour le placage de texture       */
    
    static void mySolidCube(double ct,char **filenames) {
      float c =(float) ct/2.0F;
      unsigned int textureID;
      /* Chargement premiere texture                */
      textureID = chargementTexturePNG(filenames[0]);
      glBegin(GL_QUADS);
      glNormal3f(0.0F,0.0F,-1.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex3f( c, c,-c);
      glTexCoord2f(0.0F,1.0F);
      glVertex3f( c,-c,-c);
      glTexCoord2f(1.0F,1.0F);
      glVertex3f(-c,-c,-c);
      glTexCoord2f(1.0F,0.0F);
      glVertex3f(-c, c,-c);
      glEnd();
      /* Dechargement premiere texture              */
      glDeleteTextures(1,&textureID);
      /* Chargement deuxieme texture                */
      textureID = chargementTexturePNG(filenames[1]);
      glBegin(GL_QUADS);
      glNormal3f(0.0F,0.0F,1.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex3f(-c,-c, c);
      glTexCoord2f(1.0F,0.0F);
      glVertex3f( c,-c, c);
      glTexCoord2f(1.0F,1.0F);
      glVertex3f( c, c, c);
      glTexCoord2f(0.0F,1.0F);
      glVertex3f(-c, c, c);
      glEnd();
      /* Dechargement deuxieme texture              */
      glDeleteTextures(1,&textureID);
      /* Chargement troisieme texture               */
      textureID = chargementTexturePNG(filenames[2]);
      glBegin(GL_QUADS);
      glNormal3f(-1.0F,0.0F,0.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex3f(-c, c,-c);
      glTexCoord2f(0.0F,1.0F);
      glVertex3f(-c,-c,-c);
      glTexCoord2f(1.0F,1.0F);
      glVertex3f(-c,-c, c);
      glTexCoord2f(1.0F,0.0F);
      glVertex3f(-c, c, c);
      glEnd();
      /* Dechargement troisieme texture             */
      glDeleteTextures(1,&textureID);
      /* Chargement quatrieme texture               */
      textureID = chargementTexturePNG(filenames[3]);
      glBegin(GL_QUADS);
      glNormal3f(1.0F,0.0F,0.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex3f( c, c, c);
      glTexCoord2f(0.0F,1.0F);
      glVertex3f( c,-c, c);
      glTexCoord2f(1.0F,1.0F);
      glVertex3f( c,-c,-c);
      glTexCoord2f(1.0F,0.0F);
      glVertex3f( c, c,-c);
      glEnd();
      /* Dechargement quatrieme texture             */
      glDeleteTextures(1,&textureID);
      /* Chargement cinquieme texture               */
      textureID = chargementTexturePNG(filenames[4]);
      glBegin(GL_QUADS);
      glNormal3f(0.0F,-1.0F,0.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex3f(-c,-c, c);
      glTexCoord2f(0.0F,1.0F);
      glVertex3f(-c,-c,-c);
      glTexCoord2f(1.0F,1.0F);
      glVertex3f( c,-c,-c);
      glTexCoord2f(1.0F,0.0F);
      glVertex3f( c,-c, c);
      glEnd();
      /* Dechargement cinquieme texture             */
      glDeleteTextures(1,&textureID);
      /* Chargement sixieme texture                 */
      textureID = chargementTexturePNG(filenames[5]);
      glBegin(GL_QUADS);
      glNormal3f(0.0F,1.0F,0.0F);
      glTexCoord2f(0.0F,0.0F);
      glVertex3f( c, c, c);
      glTexCoord2f(0.0F,1.0F);
      glVertex3f( c, c,-c);
      glTexCoord2f(1.0F,1.0F);
      glVertex3f(-c, c,-c);
      glTexCoord2f(1.0F,0.0F);
      glVertex3f(-c, c, c);
      glEnd();
      /* Dechargement sixieme texture               */
      glDeleteTextures(1,&textureID);
    }
    
    /* Scene dessinee                               */
    
    static void scene(void) {
      glPushMatrix();
      char *filenames[6] = { "Emoji1.png","Emoji2.png","Emoji3.png",
                             "Emoji4.png","Emoji5.png","Emoji6.png" };
      mySolidCube(5.0,filenames);
      glPopMatrix();
    }