Question

I understand why there is no pixel size (resolution) qualifier for resources like drawable, but I consequently have a problem I do not know how to solve for a game using Open GL:
I do not change the width of what you horizontally see depending on the screen size, to avoid big resolution or density screens to see "farther" than small screens. This means that a sprite that covers half the screen on a small size and density phone will also cover half the screen on a high end big tablet. But I would like to have different PNG files for both cases, because for example the sprite will be 200 pixels on a small phone and 600 pixels on the tablet. Meaning that if I use a small resolution png (like 256*256), the sprite quality will be bad on the big screen, and if I use a big resolution pgn (like 512*512 or 1024*1024) it will be overkill and consume tons of memory (for nothing) on the small phone. I know about mip mapping, but it does not actually solve the problem here (it only trades GPU waste for memory waste in the case of the small phone).

The perfect solution for that would be to have resource qualifiers for pixel size (and not inch size) but they do not exist. How are we supposed to handle that? Do we have to assume that high DPI (or high size?) device commonly have high résolutions? Do we have to create "combination" qualifiers (like drawable-hdpi-large)?

Additional question : It is commonly a good practice to assume that Open GL does always support texture size up to 512*512, but nowadays can we assume that big resolution devices (the ones I would like big png files for) always support up to 1024*1024 textures?

Was it helpful?

Solution

Android does not provide a good solution for this. Either creating combination qualifiers and duplicating images, or rolling something yourself (programmatically getting the appropriate resource using Resources.getDrawableForDensity or similar) is your best bet.

It would be really great if there was a system where you could provide many images at arbitrary pixel sizes, and Android would just pick the closest one based on the desired size. But it seems the resource loading system as it is is only designed for the drawables themselves to dictate the size.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top