Texture resizing

Started by AeroShark333, May 27, 2016, 08:20:19 AM

Previous topic - Next topic

AeroShark333

Hello,

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.

Cheers,
Abiram

EgonOlsen

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.

AeroShark333

Well the textures are big for the best quality.
I don't have any issues with the non-square textures, but since I read that warning, I do wanted to add support for devices that don't support it

EgonOlsen

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.