OpenGL doesn't like non power of two textures, you all now that.
So I want to resize unsuitable textures while loading them.
Here my code:
IL.ilGenImages(tmp);
IL.ilBindImage(tmp.get(0));
// Load the image
IL.ilLoadImage(filename)
// Convert the image to RGBA
IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE);
// Image attributes
this.width = IL.ilGetInteger(IL.IL_IMAGE_WIDTH);
this.height = IL.ilGetInteger(IL.IL_IMAGE_HEIGHT);
int desiredWidth = getNextPowerOfTwo(this.width);
int desiredHeight = getNextPowerOfTwo(this.height);
// Resize image
if (desiredWidth != width || desiredHeight != height) {
System.out.println("Resize...");
ILU.iluImageParameter(ILU.ILU_FILTER, ILU.ILU_BILINEAR);
ILU.iluScale(desiredWidth, desiredHeight, IL.ilGetInteger(IL.IL_IMAGE_DEPTH));
}
// Get Image data
imageData = IL.ilGetData();
/* create the texture in opengl */ ...
After rescaling, IL.ilGetInteger(IL.IL_IMAGE_WIDTH) and (...HEIGHT) really return a new size (2^n). But in the end OpenGL doenst get a new suitable texture; it still uses the screwed original, which makes OpenGL starve to death. I guess about 1-2FPS.
What's the problem? I don't really understand what's going on.
Thanks very much