PDA

View Full Version : Texture Loading Difficulties



Lithic
03-19-2004, 02:30 AM
In an application of mine I use a global rendering context to handle multiple openGL frames. This works great, however, when loading textures they overwrite each other. Every texture loaded overwrites the texture loaded before it, and everything that I bind to displays the same texture. I make sure to bind to the global context once before I load textures, I load textures using the following code where texture is a nonstatic member variable of TexMap.

GLuint TGALoader::LoadTGA(char *filename) {
GLuint texture;
/*
load texture into tex.imagedata -- code omitted
*/
glGenTextures(1, &texture);
// Fill the textures with stuff glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, pic.Width, pic.Height, 0, tex.type, GL_UNSIGNED_BYTE, tex.imageData);
delete [] tex.imageData;
fclose(fTGA); return texture;}

TexMap::TexMap(TexMap *Prev, TexMap *Next, float amt, char FileName[300], float u, float v, float uT, float vT, TexMapType Type) {
/*
code omitted
*/
for (int x = 0; x < 300; x++)
fileName[x] = FileName[x]; texture = TGALoader::LoadTGA(fileName);
/*
code omitted
*/
}

[This message has been edited by Lithic (edited 03-19-2004).]

Aeluned
03-19-2004, 06:53 AM
In the post your glBindTexture is commented out, I'm hoping this isn't the case in your real code.

Lithic
03-19-2004, 08:01 AM
Nope, thats just a typo.