Handmade Hero»Forums»Code
Neil Blakey-Milner
45 posts
Android NDK platform layer port
I've started an Android NDK platform layer port for Handmade Hero.

Code is at:

https://github.com/nxsy/ndk_handmade

Here's a screenshot:

https://www.facebook.com/photo.php?fbid=10152981144237457

Currently "runs" on my Kindle Fire HDX and my Fire TV.

The major missing features are input and audio, but I imagine I'll have the input done for the Fire TV part at least in the next day or so, while I might leave audio until we get there in the series again.

Enjoy!
Mārtiņš Možeiko
2562 posts / 2 projects
Android NDK platform layer port
Nice.
Why do you stick 0 at end of file you read?

Couple suggestions:
1) You can avoid OpenGL and use less code to simply draw pixels to window using ANativeWindow_lock/unlockAndPost calls. See native-bitmap example in NDK.

2) There is no need to copy android_app_glue.h/c files to jni folder. No idea how to do that in gradle, but when using NDK makefile systrem (Android.mk) then you need to simply reference this library with "$(call import-module,android/native_app_glue)" command.
Neil Blakey-Milner
45 posts
Android NDK platform layer port
I used the ANativeWindow_lock/unlockAndPost in previous revisions. They are much much slower than just using OpenGL - was consistently missing 30fps on my Kindle Fire HDX just with displaying a blank bitmap. The emulator was also very unhappy - but that doesn't change all that much with OpenGL.

I'm trying to use Android Studio/Gradle exclusively without editing any of the generated files, which is why I went this way. Almost all the documentation and examples are about ADT in Eclipse and a lot of manual file editing, so I figured this was the lesser evil.
Mārtiņš Možeiko
2562 posts / 2 projects
Android NDK platform layer port
Hm, interesting. Maybe this is device dependent. In my tests on Nexus phone using ANativeWindow for drawing pixels was pretty fast (going way over 60fps).

Not sure what you mean about Eclipse/ADT. NDK doesn't depend on Eclipse/ADT. I'm building my NDK stuff with similar setup as Casey does handmadehero - just Android.mk + editor for sources and running ndk-build command in commandline.
Neil Blakey-Milner
45 posts
Android NDK platform layer port
I've now added some horrendous input code (swipe in the direction with two fingers to go that way, release to stop going that way), and also support for "keyboards" like the keyboard in the Android emulator.

Also added support for the Fire TV Remote - was playing Handmade Hero on my TV earlier!
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Android NDK platform layer port
Awesome!! I will add it to the Coding Resources page.

- Casey