Handmade Hero » Forums » Code » Android NDK platform layer port
nxsy
Neil Blakey-Milner
46 posts
#2021 Android NDK platform layer port
3 years, 10 months ago

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!

Linux XCB platform layer: https://github.com/nxsy/xcb_handmade

Android NDK platform layer: https://github.com/nxsy/ndk_handmade
mmozeiko
Mārtiņš Možeiko
1826 posts / 1 project
#2022 Android NDK platform layer port
3 years, 10 months ago

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.
nxsy
Neil Blakey-Milner
46 posts
#2023 Android NDK platform layer port
3 years, 10 months ago

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.

Linux XCB platform layer: https://github.com/nxsy/xcb_handmade

Android NDK platform layer: https://github.com/nxsy/ndk_handmade
mmozeiko
Mārtiņš Možeiko
1826 posts / 1 project
#2024 Android NDK platform layer port
3 years, 10 months ago

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.
nxsy
Neil Blakey-Milner
46 posts
#2025 Android NDK platform layer port
3 years, 10 months ago

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!

Linux XCB platform layer: https://github.com/nxsy/xcb_handmade

Android NDK platform layer: https://github.com/nxsy/ndk_handmade
cmuratori
Casey Muratori
813 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.

#2026 Android NDK platform layer port
3 years, 10 months ago

Awesome!! I will add it to the Coding Resources page.

- Casey