Android game development in c++

kamziro
  • Android game development in c++ kamziro

    So being a primarily c/c++ developer, I've always thought that the only option for mobile game development for me was using iOS, which allows for c/c++ (and minimising objective C).

    I heard from a friend though, that android has a native development toolkit which allows for c++ code to work on android.

    Has anyone used this, and if so, how do you find it? I mean, will it "just work" like iOS, or are there more considerations that need to be taken care of due to the wide variety of android devices available?

  • Android has supported native applications since version 1.5 through Android NDK, which should cover your target audience very well. You still need a simple Android Java application that loads the native side of your application through JNI and passes forward e.g. input and render calls.

    There has been several versions of the NDK, but you can use the latest NDK and select the target API you want to support. Since Android version 2.3 you can do a lot more on the native side and need less Java code, but the device support for 2.3 is currently very limited.

    Native Android C/C++ development is a working solution at least for fullscreen games and the effort needed to port existing C/C++ OpenGL ES applications is quite small.

  • Android APIs are Java. Since 2010, Google provides the NDK (a SDK) for C/C++ developers.

    The NDK offers two ways:

    • for android 1.5 devices, you can load an elf library and uses it from the java application via a JNI bridge
    • for android 2.3 devices, you can use a NativeActivity to bypass the Java Activity code for Fullscreen Application.

    The NDK offers few C/C++ API:

    • a pseudo libc called bionics: many functions aren't availabled
    • a pthread library
    • OpenGL ES 1.x (>Android 1.5) and OpenGL ES 2.x (Android 2.0)
    • OpenSL (limited support on Android 2.3)

    But many API are Java only (also available via JNI).

    NDK 5 version is the first usable for C++ developers because it offers:

    • RTTI
    • Exceptions supports
    • STLport
    • gdb support for multi-threaded programs

    The most painful operation is debugging on android devices. So i develop my own multi-platform framework (OS X, Windows, Linux, iOS and Android) to debug first on desktop platform, next iOS platform (on Simulator) and Last (Android).

    The android Emulator (not a simulator) have a poor performance and can't emulate OpenGL ES 2.x. I recommend real devices to develop.

    You can find many useful informations :

  • I have successfully used the Android NDK to port two SDL + OpenGL games to Android and found it surprisingly easy. I have a 200-line Java wrapper that creates the GL context and provides utility classes such as input, sound and image loading for the C++ code to call back. The "San-Angeles" sample program in the NDK is an excellent starting point.

    By the way, it is possible to build C/C++ programs without a line of Java, but I find it convenient to access some OS-level methods by calling back the JVM from time to time.

    I think if your game already compiles on Linux, you will feel at home. Out of 100+ files in my current project, only 4 have an #ifdef ANDROID_NDK directive (the image and sound related classes).

    In fact most of the time spent porting the game was because of a known emulator bug that I wasn't aware of.

Tags
c++ android
Related questions and answers
  • 3D authoring application (3ds Max, Maya, Softimage) into the game. However, doing so from scratch is going to be really be a lot of work. Therefore, is there any available solution/middleware...Say I develop a game for mobile platform running OpenGL ES 2.0. I have done 2D part, and now I wish to import some 3D objects. The imported 3D objects must contain the following: Vertices... the above mentioned features plus things I haven't considered yet Programming language is: C++. Currently, I'm developing under Windows 7, Visual Studio 2010, and OpenGL ES 2.0 emulator. Later

  • 1st Question is I want to write a board game for iOS and Android so I'm coming up with CoronaSDK and AirPlay. Since I have a mac, development platform is not an issue but the problem is which one should I choose. I'm fluent with PHP and web languages and familiar with C but it's a new language for Lua. I know a lot of people prefer Corona but why not Airplay? It even provides more devices and able to write in C/C++. 2nd Question is I want a SDK with shortest development time and easier coding. I don't need complex 3D or animation engine since the game is a board game like chess or monopoly

  • I'm working on mobile platforms as Android, IOS... Many users of Moblox ask us a windows and an OS X version. There is no difficulties to provide these versions, because we are developing on OS X C++ code but we miss global scores and social network part (facebook, twitter). Is there any library to implement these functions on Desktops plaforms ? On mobile platforms, we have many SDK to provide theses functions as OpenFeint, ScoreLoop, Plus+. We have used cocoslive and uploaded scores with libcurl but it's very limited.

  • When it comes to mobile game development on iOS and Android NDK, some developers write their own C++ containers, while others claim that STL is more than adequate for mobile game development (For example, the author of iPhone 3D Programming uses STL rather than Objective-C in his examples. His defense is that STL is no slower than Objective-C). Then there are also mobile developers who abandon C++ entirely and develop games entirely (or mostly) in the C language (C89/C90). What are the benefits and drawbacks of each approach?

  • I have a good grasp in C++ and C and have also experience developing AAA game using C++. Now, I'm shamelessly thinking to dive into mobile game development either in iOS or Android. Unfortunately, I don't know objective-C and java and neither have courage to learn it. So, As above mentioned reason, Is there any possibility to do mobile development in C++ without using any single statement of JAVA and Objective-C ?

  • These days, I'm focusing on games development on the iOS. C++ is the lingua franca for games development but seriously, I prefer to code in C programming language, not in C++. So for iOS games development, are C and Objective-C sufficient for creating games?

  • After spending time today to jot down some notes regarding the implementation of walls into my tile-based game, I've suddenly realized it's not going to be as simple as I imagined before. While the current stage of my work is not even close to actually making the wall-related code, I've come up with three different ways to do it. Right now I'm unsure which one of my ideas will work best, and whether I missed something or not. Important: a character CAN stand on a tile that has walls, regardless of their form. The common thing for all the three variants: the tilemap will be "kept

  • that.... Allows easy setup of controls for a game Makes events like clicking and holding on an object easy to setup, as so objects can be dragged around afterward Are there any simple libraries... controls easy to set up (i'm using SFML and Box2D at the moment) I don't want to re-invent things like buttons, arrows being placed wherever the mouse is located, and more game specific items such as "controls settings" or even being able to drag objects around with the mouse. More specifically i want source code for interfaces that.... Makes Buttons and Textboxes easy to create allows mouse

  • of wasting it on incorrect approaches. I use Softimage as my 3D authoring tool. Target platform is OpenGL ES 2.0 running on mobile devices (iOS, Android). Programming language: C++. ...After careful consideration to use middleware, I have decided on creating my own 3d file format format to export meshes from 3D authoring application (Softimage) into my game. I will need to export the following: Vertices Indices Normals UVs Material Information Animation information (no clue, how to import it) Collision mesh Game Properties defined within 3D authoring tool (object

Data information