Original Post
Hi, I'm having trouble with textures in opengl... I'm loading some texture files (.bmp) but the last file is used to all objects in the scene = (( here's my loadtexture code any suggestion? Thanx...
void POpenGLDriver::LoadTexture(std::string AFileName, unsigned int &ATextureBuffer, int ATextureType)
{
AUX_RGBImageRec *TextureImage = null;
if (TextureImage = LoadBMPRec(AFileName))
{
glGenTextures(1, &ATextureBuffer);
glBindTexture(GL_TEXTURE_2D, ATextureBuffer);
switch (ATextureType)
{
case TT_TEXT:
{
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX, TextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
}break;
case TT_RECT:
{
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}break;
}
}
if (TextureImage)
if (TextureImage->data)
free(TextureImage->data);
free(TextureImage);
}