Author
Topic: Texture resizing (Read 755 times)

So I have a small question...Let's say I have an Android bitmap with the following resolution 1024x2048 (height x width) and I want to make it a 2048x2048 squared texture (to provide support for devices that don't support non-squared textures).How can I scale the height in the most efficient way?Bitmap.createScaledBitmap isn't that memory efficient I suppose... (There will be a moment when the original bitmap and the scaled bitmap are loaded in the memory, right? I would like to avoid this,because it could rise an OutOfMemoryError for some devices I guess)

So then, is it possible to do it with a Texture instance instead?Basically pass the original 1024x2048 bitmap instance to a new texture instance and do Texture.scaleHeight(2);(Texture.scaleWidth(0.5f); would be possible too of course...)And when the texture is uploaded to the TextureManager, then the texture will be uploaded as a 2048x2048 texture to the GPU.I don't know if this can be done... but I guess it would be quite memory efficient if this was possible.

No, that won't help. You would still have two copies of the pixels in memory at a time. The actual question is: Why are your textures that large anyway? A 1024*2048 texture alone will consume up 20mb of ram (GPU and main memory combined). That's quite a lot even on today's devices.And do you actually have a problem with these non-square textures? I know that jPCT-AE prints out a warning if you are using them and that's because these dimensions are a grey area in the OpenGL ES 2.0 specs and they do have issues on some, especially older, devices. But on recent ones, it should actually work.

In that case, I simply wouldn't bother with it. IIRC, the specs are missing information about POT but non-square textures, so every implementation is correct. That's why on older devices/drivers, this was a problem. But there isn't even a way to query for the support. Personally, I'm ignoring the warning and never got any complaints about missing textures.