1
\$\begingroup\$

I have worked on libSDL1.2. Since, the release of 2.0, SDL also supports android. So, I am trying to develop game that can work both on desktop and android. But there are few things that are confusing me.

  1. When we are creating a window, we pass the width and height of screen. But on android game covers whole screen and different devices have different resolutions. So how can we create a screen which appears uniform on both desktop and android.

  2. How to handle inputs like back button.

  3. Also, how to load graphics based on DPI.

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

It might be easier to deliberately develop two slightly differing versions of your game; one for PC and Android each. You could develop them in parallel git branches, for example.


However, if you want to take the full-on responsive resolution-independent user interface route:

It's been a while since I did SDL, but it has something to the tune of SDL_GetDisplayMode for finding the native screen resolution. Based on that, you could guess whether the game is running on Android or a desktop and hide / change UI elements or controls appropriately.

Such a comparison is only guess, of course, as you can't cover all possible screen resolutions. If you're really going to run the same code on both platforms, it might be best to add a user-configurable "phone / PC mode" option so nobody is accidentally stuck with the wrong UI.

\$\endgroup\$

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.