2

I am a C++ programmer and I currently have a few PC games which sell very well. I would like to port one of them to Android but I don't really know where to begin.

So I assume...

  1. I need to buy an Android device ( I guess a tablet is best to write code because of the big screen size).
  2. I need to download a C++ compiler.
  3. I need to convert from directX to openGL.

Is this all correct?

genpfault
  • 51,148
  • 11
  • 85
  • 139
carpman
  • 75
  • 8

4 Answers4

1

You don't have to buy an Android device. You can actually use an emulator that they provide. You can download and learn more about these emulators (one exists for just about every Android device that exists) here: http://developer.android.com/tools/help/emulator.html

I can't provide any help for C++ on Android, but there's a previous SO thread about it: Write applications in C or C++ for Android?

EDIT: After doing some more research, Android provides an NDK for coding apps in native-code languages such as C or C++. You should, however keep in mind that they give the warning that "In general, you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++." - it seems like you should only use it if you the application requires is.

Community
  • 1
  • 1
Joseph Boyle
  • 560
  • 5
  • 15
  • Many thanks for all the help. The progam is massive so it really does need to stay as C++ (far too much work rewriting the entire thing) so I will look into the NDK – carpman Feb 03 '14 at 13:42
  • Just fyi, the emulator isn't sufficient for OpenGL apps. It doesn't work at all with ES 2.0+. – Dave Feb 03 '14 at 15:29
1
  1. Yes, you need a device. (The emulator isn't sufficient for OpenGL.)
  2. The NDK provides the correct compiler. The Android make file is a little tricky if you aren't used to using make files, but it isn't too difficult to learn. There should be tutorials aplenty.
  3. Absolutely. OpenGL ES to be specific. The version you use depends on what versions of Android you intend to target. From ES 1.1 to ES 2.0 is a big difference in that 2.0 is shader based, so the type of code you are porting may play a role in your decisions here.
Dave
  • 4,282
  • 2
  • 19
  • 24
  • many thanks - very helpful. So if I use ES1.1 that means the app will function on any android device? The graphics in my games are pretty simple. – carpman Feb 03 '14 at 15:41
  • Yes, but it does not support shaders at all. If your DirectX code does not use shaders, then porting to 1.1 may be easiest. That said, market share on devices < Android 2.2 is minimal (you're not missing out on customers targeting the higher versions). – Dave Feb 03 '14 at 23:04
  • Thanks Dave. I do not fully understand what you are saying. If I use 1.1 the app will work on all devices so I will have access to all customers? Surely 1.1 will still work on the more recent devices? Is that correct? Cheers. – carpman Feb 04 '14 at 12:25
0

Am I being daft or is this what I need? compiler

Will the code this produces run on android apps?

Thanks

carpman
  • 75
  • 8
0

If you still want to write/compile code on device, there are a few Android-based compilers...or environments that include compiler packages...out there but I'm guessing you'd need a fairly beefy tablet.

For compiling, I use the KBOX environment, on a NookHD. There are several downloadable packages for it...including GCC 4.7, GCC 4.8 and nano packages. NOTE: I'm a beginner so I've only compiled very small programs with it; I wouldn't know how larger, more complex code would compile. There are other apps...both in the Play store and online...but I can't speak to them because I haven't used them.

For writing code, I use DroidEdit. Nano in the KBOX environment works in a pinch...but there are some screen draw bugs due to Androids minimal bionic library that could get annoying if you're writing lots of code.