Reputation: 1505
I'm developing an Android game using libgdx and define the virtual camera width/height to be: 800x1280.
I have 3 test devices:
I'm using GIMP to develop the graphics. How do I pick a appropriate size in GIMP for sprites, coins and background picture so it won't be displayed pixelated? I don't just want to pick a extremely high resolution and increase the app size unnecessary. Would all graphics have to be a power of 2?
Upvotes: 1
Views: 2050
Reputation: 10320
If you use OpenGLES1.x, yes the textures must be power of 2. If you use OpenGLES2.0, then they aren't forced to, but some devices do not support them anyways.
It is recommended you always use power of 2 textures. Try to get all the images in big atlases (1024x1024 for example). That will give you very big performance increase.
Also I would recommend you to make the graphics for the camera viewport that you are already using (800x1280).
And decide if you want the graphics to be stretched in different screen ratios or having the sprites look the same but change how much of your world every user can see.
For the first, leave your viewport like that (800x1280) It will stretch automatically.
For the second, make your longer side fixed and calculate the other side. (or the other way around, it depends on if you want the user to see more or less in horizontal or vertical). Something like this:
cam = new OrthographicCamera(((float)Gdx.graphics.getWidth()/Gdx.graphics.getHeight())*800, 1280);
I suggest you to make them for 800x1280, and use the Linear filter for the images so they dont look pixelated when stretched/shrinked.
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
Upvotes: 2
Reputation: 645
For OpenGL on phones it is kind of mandatory to have power of 2 textures but some devices may support non-power of 2 textures ( with some limitations ). So if you want to make sure it will work stick with power of 2 textures.
For generic drawing I think anything can go there is no limit, generic drawing I mean, bitmaps in the layout.
It is usually up to you how you solve the independence issue, since first of all you may suffer from aspect ratio problems which will cause distortion like 4:3 in 16:9 will be stretched so you have to do something about that, the usual way in 3D games is to let the camera "see" more in 16:9.
Anyway generally you should use android's built-in method of selecting the best image set for the current display, as far as I know its not just about choosing a pixel size that is closest to what resolution you have since the actual pixels you will see may vary depending on the device ( ppi ).
The other way around this problem is that you may generate the images every time you run making it the most suitable every time, I'm saying that you store the source and pre-render the images on startup to make them the most appropriate.
So the best which gives a tradeoff between quality and speed is to have different sets for different screens and pick to best upon startup ( or let android do that for you ) and render with those images. If you just want to use 1 set of images, try to tune it so it looks okay on the bigger screens since down scaling tends to look better than up scaling.
Upvotes: 2