I have 2 1024x1024 sprite sheets, one containing several 480x320 background images and another containing a variety of smaller elements as entities and interface. My framerate drops like a rock whenever I enter a scene in which I have to display sprites from both textures (forcing me to re-bind twice per frame, interface texture->bg texture->interface texture).
- (void)setCurrentTexture:(int)texID{
if(currentTex == texID)
return;
else
currentTex = texID;
// Bind the texture name.
glBindTexture(GL_TEXTURE_2D, [Graphics getTexture:texID]);
// Speidfy a 2D texture image, provideing the a pointer to the image data in memory
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, [Graphics getTexWidth:texID], [Graphics getTexHeight:texID], 0, GL_RGBA, GL_UNSIGNED_BYTE, [Graphics getTexData:texID]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
Is there something wrong with the way I'm swapping my textures?
Edit: I've removed half of the state changes I've been making. Removing any of the above 3 results in my polygons being textured with nothing (i.e. the show up white). The biggest hitter is glTexImage2D... but trying to set it elsewhere once (at init, for example) ends up with my models/quads not being textured at all.