Hi there,
Im having some problems with creating textures.
Im trying to load the textures with this procedure
void setTextureToObject(char* textureFilename, int obj)
{
Mesh::Texture texture;
// this one works fine
Mesh::loadTexture(textureFilename, texture);
// glGenTextures returns the same IDs on different calls
glGenTextures(1, &(Objects[obj].gTextureAccessor));
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, Objects[obj].gTextureAccessor);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture.width, texture.height, GL_RGB, GL_UNSIGNED_BYTE, texture.pTextureData);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture.width, texture.height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture.pTextureData);
Mesh::unloadTexture(texture);
}
(Objects is a Vector of a struct with the object data; Mesh::texture is a struct to hold the temporary texture on loading)
the funny thing is I call this procedure twice in my initialization and it works just fine there, but as soon as Im in the main loop glGenTextures start setting gTextureAccessor to 1 again.
I tried replacing this line with a global counter but although the texture-ids are correct now its not working.
Sometimes this results in the correct texture, sometimes the objects have no texture and sometimes they disapear completely