LongJumper
2003.10.19, 02:25 AM
having a little trouble with texture binding.
Right now my code stands as loading in a window texture(the background of a window), binding that to what is most likely the name 1. Then it goes and loads another texture for a button inside that window, which I know for a fact gets 2, and is done like this:
glGenTextures(1, &texture.texID);
glBindTexture(GL_TEXTURE_2D, texture.texID);
if (UseMipMaps)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture.width, texture.height,
type, GL_UNSIGNED_BYTE, (GLvoid *)imageData);
}
Then after that, it loads the terrain texture which is a 128x128 tiled image. Which does some work with gluScaleImage and later calls glTexImage2D a whole lot of times while building the display list, but no binding or generating of textures.
Now the control(the one loaded second) appears as the terrain texture, I assume because the call to glTexImage2D is associated with the last glBindTexture and therefore changes the control's texture to whatever the last glTexImage2D was.
So I played around with it just putting glGenTextures and glBindTextures in various spots.. when I put it before the display list is built(LoadTile is called mapZ*mapX times, each time a glTexImage2D is called) and it makes it so the button flashes the texture its supposed to, then goes permanently to the terrain texture. T
hen I made it so it generated and binded a texture each time it called LoadTile, it turned it completly white(no texture?) then I did it so if no texture was generated in the terrain texture slot, it would generated and bind it, otherwise it would call glTexImage2D by itself. This made a pretty cool effect where everything worked 99% correct, except it left weird tile lines around each tile and one stripe from one side of a tile would be displayed on the opposite side of each tile.
I'm pretty stumped, since I've only been playing with OpenGl for awhile now and don't have time to read my book thoroughly on it, so any help is appreciated.
Right now my code stands as loading in a window texture(the background of a window), binding that to what is most likely the name 1. Then it goes and loads another texture for a button inside that window, which I know for a fact gets 2, and is done like this:
glGenTextures(1, &texture.texID);
glBindTexture(GL_TEXTURE_2D, texture.texID);
if (UseMipMaps)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, texture.width, texture.height,
type, GL_UNSIGNED_BYTE, (GLvoid *)imageData);
}
Then after that, it loads the terrain texture which is a 128x128 tiled image. Which does some work with gluScaleImage and later calls glTexImage2D a whole lot of times while building the display list, but no binding or generating of textures.
Now the control(the one loaded second) appears as the terrain texture, I assume because the call to glTexImage2D is associated with the last glBindTexture and therefore changes the control's texture to whatever the last glTexImage2D was.
So I played around with it just putting glGenTextures and glBindTextures in various spots.. when I put it before the display list is built(LoadTile is called mapZ*mapX times, each time a glTexImage2D is called) and it makes it so the button flashes the texture its supposed to, then goes permanently to the terrain texture. T
hen I made it so it generated and binded a texture each time it called LoadTile, it turned it completly white(no texture?) then I did it so if no texture was generated in the terrain texture slot, it would generated and bind it, otherwise it would call glTexImage2D by itself. This made a pretty cool effect where everything worked 99% correct, except it left weird tile lines around each tile and one stripe from one side of a tile would be displayed on the opposite side of each tile.
I'm pretty stumped, since I've only been playing with OpenGl for awhile now and don't have time to read my book thoroughly on it, so any help is appreciated.