#include <windows.h>
#include <stdio.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
Il n'a que ca comme include.
Oui tu prends ce deux fonctions:
AUX_RGBImageRec *LoadBMP(char *Filename);
int LoadGLTextures();
Mais c'est vrai que moi meme j'ai eu du mal a utiliser ces fonctions,
car elle ne sont prévu que pour une texture.
Si tu veux un exemple, j'utilise ca dans la source opengl que j'avais poster il y a longtemps:
http://www.cppfrance.com/code.aspx?ID=27055
GLuint texture[3]; // en variable globale
AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle
if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}
File=fopen(Filename,"r"); // Check To See If The File Exists
if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}
return NULL; // If Load Failed Return NULL
}
int LoadGLTextures()
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage[3];
memset (TextureImage, 0, sizeof(void*)*1);
glGenTextures(3, texture);
if (TextureImage[0]=LoadBMP("textures/briques2.bmp"))
{
Status=TRUE;
}
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (TextureImage[1]=LoadBMP("textures/parquet1.bmp"))
{
Status=TRUE;
}
//glGenTextures(2, &texture[1]);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (TextureImage[2]=LoadBMP("textures/rocher.bmp"))
{
Status=TRUE;
}
//glGenTextures(3, &texture[2]);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[2]->sizeX, TextureImage[2]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[2]->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (TextureImage[0])
{
if (TextureImage[0]->data)
{
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
if (TextureImage[1])
{
if (TextureImage[1]->data)
{
free(TextureImage[1]->data);
}
free(TextureImage[1]);
}
if (TextureImage[2])
{
if (TextureImage[2]->data)
{
free(TextureImage[2]->data);
}
free(TextureImage[2]);
}
return Status;
}
Et après dans ta fonction d'affichage, tu appels les textures:
glBindTexture(GL_TEXTURE_2D, texture[2]);
glBegin(GL_QUADS);
{
glTexCoord2f(-t,-t); glVertex3f(cub_x - cub_c,cub_z + cub_c,cub_y - cub_c);
glTexCoord2f(t,-t); glVertex3f(cub_x + cub_c,cub_z + cub_c,cub_y - cub_c);
glTexCoord2f(t,t); glVertex3f(cub_x + cub_c,cub_z + cub_c,cub_y + cub_c);
glTexCoord2f(-t,t); glVertex3f(cub_x - cub_c,cub_z + cub_c,cub_y + cub_c);
}
glEnd();
Enfin tu vois le genre. C'est pas jolie comme mémorisation, car tu vois bien je code en hard le chargement de 3 textures, mais tu peux généraliser ca facilement après.
Aller ++