0
\$\begingroup\$

I'm currently using SDL2 on Android and that's my first experience with that library (to be honest, mainly chosen because I'd like to learn it).
What is puzzling me is how to deal with different resolutions and density-independent pixels, for I cannot figure out which is the recommended approach to create images and let them look decently on screen on the most of the devices.

Unfortunately, googling around I've not been able to find a decent example or a bunch of information sufficient to clarify the doubts.
It seems that the most common suggestion is to choose a fixed size virtual resolution for the content rectangle, thus draw on top of it and finally resize it to the actual one, but it would be appreciated to know if this one is really a widely used approach and if there are some others that are more suitable.

Thank you.

\$\endgroup\$
1
\$\begingroup\$

Texture Filtering

enter image description here

SDL2 allows you to use texture filtering. This interpolates the pixels of your textures to be smooth when scaled larger or smaller than 1:1 or if the texture is not lined up with the display pixels. This gives you nice smooth sprites that move smoothly and look pretty good at nearly any resolution.

\$\endgroup\$
  • \$\begingroup\$ Yeah, that's what I'm currently doing. I'd like to know if this is the recommended approach or if there exist some others. \$\endgroup\$ – skypjack Dec 6 '15 at 8:31
  • \$\begingroup\$ @skypjack I'd recommend it. I'm pretty sure rendering-space is floating-point in SDL2, so you can just set a view-size and everything scales to any resolution without any aliasing or pixelation. You just have to use floating points for all your graphical elements. \$\endgroup\$ – Willy Goat Dec 6 '15 at 8:39
  • \$\begingroup\$ I confirm you that it's possible, of course. :-) ... So, there is nothing like dp, thus mdpi, hdpi, and so on, once one develops a game for android, is it? I mean, you confirm my thoughts, so it's good. :-) \$\endgroup\$ – skypjack Dec 6 '15 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.