voila je developement en ce moment mon moteur3d pour 1 jeux.
Le probleme c'est la fonction d'ouverture de fichier.BMP. Elle fonctionne trés bien sur la texture que j'avais trouver avec la texture mais quand je fait mes propre texture sous gimp, bas ça merdouille (je precise que j'ai essayer plus de texture, même taille, même poid...) rien à faire.
int LoadBMP(char *File)
{
unsigned char *Data;
FILE *fichier;
unsigned char Header[0x36];
GLuint DataPos,DataSize;
GLint Components;
GLsizei Width,Height;
GLenum Format,Type;
GLuint Name[1];
fichier = fopen(File,"rb");if (!fichier) return -1;
if (fread(Header,1,0x36,fichier)!=0x36) EXIT;
if (Header[0]!='B' || Header[1]!='M') EXIT;
if (CTOI(Header[0x1E])!=0) EXIT;
if (CTOI(Header[0x1C])!=24) EXIT;
DataPos = CTOI(Header[0x0A]);
DataSize = CTOI(Header[0x22]);
Width = CTOI(Header[0x12]);
Height = CTOI(Header[0x16]);
Type = GL_UNSIGNED_BYTE;
Format = GL_RGB;
Components = 3;
if (DataSize==0) DataSize=Width*Height*Components;
if (DataPos==0) DataPos=0x36;
fseek(fichier,DataPos,0);
Data = new unsigned char[DataSize];
if (!Data) EXIT;
if (fread(Data,1,DataSize,fichier)!=DataSize)
{
delete Data;
fclose(fichier);
return -1;
}
fclose(fichier);
unsigned char t;
for (int x=0;x<Width*Height;x++)
{
t=Data[x*3];
Data[x*3]=Data[x*3+2];
Data[x*3+2]=t;
}
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glGenTextures(1, Name);
glBindTexture(GL_TEXTURE_2D, Name[0]);
glTexImage2D
(
GL_TEXTURE_2D,
0,
Components,
Width,
Height,
0,
Format,
Type,
Data
);
return Name[0];
}
quelqu'un peut-il m'aider?