Reputation: 5495
When dealing with different screen sizes I use like 3 packs of assets for SD, MD and HD phones / tablets. But doing this is kinda annoying, and makes the APK bigger. I want to use just the biggest pack that I want to use, like HD. But if someone got a 3.2" phone I don't want to render a 1280x768 background on 320x480 phone..
So i'm just wondering..is possible with libGDX to resize a Texture ? I don't mean resizing like, drawing with a specific size..I mean, in Texture Packer GUI I can add the biggest assets pack and choose to export also HD or MD pack.. Is possible to resize a Texture in runtime? So if I play my game on a small phone, the textures will be smaller in size.
I hope you guys understand what I'm trying to say.
Upvotes: 1
Views: 537
Reputation: 25177
Using extra storage space on the low-end phones is probably the best bet. The alternatives are less attractive:
Scale the images down when you load them. This will lengthen load times on an already under-powered phone. The scaling will have to be done on the CPU, as the GPU may not support textures that are a multiple of screen size. Plus you'll need to load these large images into memory, which will tax a small phone even more. (You could do this once and cache the results, so you don't penalize every startup but then you might as well just put the files in the .APK) (You could chop the HD image into parts to avoid overwhelming a low-end phone, but that just increases the startup latency even more.) If you still want to try it, with LibGDX you could use a FrameBuffer to create a low-resolution image at run-time from a higher-resolution one.
Scale the images down when you render them. This is unlikely to work reliably, and requires a significant memory footprint to keep the images loaded.
To get a real handle on what you are optimizing here, try building your APK with all the resolutions and then again with just the HD images. I bet the difference isn't that big (the low-end images are, by definition, not that big relatively.)
Upvotes: 1