Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 31 May 2010
Offline Last Active Feb 25 2014 04:45 AM

Posts I've Made

In Topic: Android NDK Development - Would like feedback

28 December 2013 - 05:51 AM

Had a really busy month so I didn't finish the next page yet but I have started working on a slightly different take for this and was wondering if someone could give it a try and lend me some feedback.


I decided to try and simplify or better handle the NativeActivity state handling and events and compiled a small and simple library for use as a C++ source. It is still very much WIP but if anyone wants to give it a go I will appreciate it.


The library can be found here:



And an example project to use it is here:



Currently it handles letting you know when the window is hidden (and you should stop drawing then), application is paused and key/touch data. You can also call the keyboard from Native.


Next I will be adding simple access to assets and then either leave it there or extend the BaseGameUtils for Google Play Services.


I want to keep it as slim as possible so it is just bare bones but also help exposing Android APIs to C++ with it.

In Topic: Android NDK Development - Would like feedback

03 December 2013 - 06:13 AM

This is a good start. Most of my feedback would relate to grammar and not technical issues.


I generally find the NDK to be a mostly useless addition to Android.  I love C++ and would rather use that language all the time, but in the hands of the most experienced developer, switching to C++ improves performance by less than 1/2 of a generation of devices. In other words, if you are writing something very peculiar and "cutting edge," and only want it to work on the latest devices, you may need C++.  Otherwise, if you are writing a commercial application and want wide device support, you will get far more payoff from learning how to write efficient Java than from switching to C++ (and inviting the compatibility issues that can arise as a consequence).


Hi HScottH,


Thank you for the reply. The case is that I am not a native English speaker and still need to work on my writing so if you have any suggestions they will be warmly accepted.


As for using C++, the main reasons are performancecross-platform and convenience. I do agree performance for most applications will not be an issue and it will even be easier to create the whole program in Java with the tools given by Google, yet for more demanding applications - games for example, it is still highly beneficial to use C++.


In-fact many of the games out this day prove this is the case. An office I have been at had problems with things as simple as rendering smooth UI animations with the Java classes on devices such as the Galaxy S2, switching drawing and logic to C++ resolved the issue. It might be worth to note I am not familiar with the Java implementation which was at the time.


As for cross-platform: most games these days are out for iPhone before they are for Android and some are out on PC and then converted (FTL for example). This means there is an established code-base in C++ or Objective-C which could lead to a game being easily adapted for Android. In-fact, just the option to write games in C++ alone would influence people to choose it over Objective-C so their game can be played on both platforms.


As for convenience it is a simple matter, many programmers (myself included) are used to C++ and have some libraries they worked on. So added to the benefit of not having to write different code for different platforms (except for the application initialisation and some lifecycle events), the programmer will feel most comfortable using their "natural" language.


This is at least the case as I see it. I hope I made a good case for it ;)

In Topic: Android NDK Development - Would like feedback

02 December 2013 - 10:35 PM

I released Part III last night. You can find it here:



I might go over and give it a small edit still but I think it will not be anything major ;)

In Topic: Android NDK Development - Would like feedback

01 December 2013 - 09:27 AM

As for EGL and multi-threading for rendering. As far as I remember, and I will look into it again in the coming days/week: You can create the context on your C++ side and you can create multiple contexts for multi-threaded use.


The first half of the statement I know is 100% true. The second part I am pretty sure to be true except for Vertex Array Objects. I will try to get definitive answer by next week.


Thanks for the lovely feedback!

In Topic: Android NDK Development - Would like feedback

01 December 2013 - 09:21 AM

I just remembered there is an important subject I forgot to mention, the JNI_OnLoad. I will try to put it on the next article.

jint JNI_OnLoad( JavaVM* pJavaVM, void* pReserved )
    JNIEnv* pEnv;
    if ( pJavaVM->GetEnv(reinterpret_cast<void**>( &pEnv ), JNI_VERSION_1_6) != JNI_OK )
        return -1;
    // Get jclass with pJavaVM->FindClass.
    // Register methods with pJavaVM->RegisterNatives.
    return JNI_VERSION_1_6;