1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
int CCube::LoadTextures(char *Filename,GLuint TexturePos)
{
SDL_Surface *texture;
// Création d'un objet de texture.
glGenTextures (10, &TextureID[TexturePos]);
// selectionne la texture
glBindTexture (GL_TEXTURE_2D, TextureID[TexturePos]);
// Chargement du fichier.
texture = IMG_Load(Filename);
// Jonction entre OpenGL et SDL.
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, texture->w, texture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture->pixels);
// Parametre de la texture
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
// Correction de la perspective des textures
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
return 0;
} |
Partager