18

I have a game written in C/C++ with SDL 2.0, I would like to port it to mobile platforms (specifically Android and maybe other platforms too). I read SDL has a native support for Android but the game itself is written for Windows at first, although no Windows-dependent libraries/code were used. As for Android, I only used the Java based SDK before and never integrated it with native code. Which changes (if any) do I have to make to the C/C++ so I could use it on Android platform? How exactly do I acually compile the whole thing to an APK? Is it possible to use Java and C/C++ for the application, I mean, the game's activity will be the native one but the other activities (menus, settings, etc) can be written with the regular Android Java SDK?

UnTraDe
  • 3,747
  • 10
  • 36
  • 60

2 Answers2

10

The Android README file in the SDL source release outlines most of what you need to know with regards to porting your SDL App to Android. There's also an example project for Eclipse that demonstrates you can modify to suit your needs.

https://hg.libsdl.org/SDL/file/d6a8fa507a45/README-android.txt

The iOS README file is also useful, namely for the sections on events and input, as much of it carries over to the Android port.

https://hg.libsdl.org/SDL/file/d6a8fa507a45/README-ios.txt

If you need help setting up the build environment, check out this (brief) tutorial which covers installing the ADK and NDK, SDL source, building a project, programming for Android and interfacing with Java.

http://www.dinomage.com/2013/01/howto-sdl-on-android/

http://www.dinomage.com/2013/05/howto-sdl-on-android-part-2-platform-details/

nick.amor
  • 192
  • 1
  • 7
  • 1
    Since I wrote the questions I kept reading and experimenting with this subject. Later I understood that my question should of been mainly addressed to the difference between OpenGL Core and ES versions. The example project they have in the SDL which you mentioned here answered almost all my questions. Thanks alot! – UnTraDe Jul 16 '14 at 12:34
  • Readme links are broken – Hubro Sep 06 '14 at 12:05
  • I've followed the readme and am starting from said sample project yet i am missing libmain. http://stackoverflow.com/questions/26198562/ive-followed-dinomages-guide-to-sdl-on-android-but-its-not-making-libmain . thanks – John Oct 05 '14 at 13:40
2

(1)

I dont know anything about SDL but as long as you only make calls suported by the android NDK and what ever android supported library it should be ok. I guess you would have to set up your tool chain such that it links with SDL for android?

(2) Yes it is possible to call c++ (ndk) from the android sdk and vice versa (see 3)

(3+ rest)

See

https://developer.android.com/tools/sdk/ndk/index.html

If you download the NDK you can also see examples of how to compile with NDK to APK

Niels
  • 81
  • 7