Tonight I spent some time playing with the native bindings to OpenGL ES on my shiny new Android-based phone, with the eventual far-off goal of porting the Universe client to it. There’s plenty of information on Google about porting C/C++ command line apps and libraries, but nothing that I could see about 3D applications – the closest was this thread which talked about porting a software renderer. So, I figured I’d write this post up with some tips and perhaps spare someone else some pain
- First I followed the steps on this site to download and build the Android source. I used the agcc wrapper script linked off there to simplify compiling, which seems to work fairly well.
- My test application consists of a coloured triangle, that can be rotated with ‘w’ and ‘d’ on the keyboard. Not very exciting, but it’s enough to test with.
- ’src/androidgl.cpp’ – This is a quick little library of helper functions I put together to ease the pain of setting up a fullscreen GL context and getting keyboard events. It also contains implementations of some GLU functions, as GLES doesn’t provide them.
- It’s still rather buggy – I have the same problem as the software renderer guys have with the application ‘behind’ the GL context showing through. This seems to happen whenever an event is signalled – ie: every time I push a key. There’s also a problem with the screen not refreshing properly when the application exits. Both of these issues could probably be solved by using a minimal java program that would invoke the C++ binary, instead of just running it from the shell.
Anyway, the source is here, should anyone find it helpful:
Assuming you have the Android toolchain, agcc script and adb set up properly, ‘make && make run-app‘ should compile, push the binary to the phone over adb and execute it. Note that /sdcard is unhelpfully mounted noexec, so I used /cache instead.
no comment untill now