Particles on my Android

Since I just got my first Android phone (an HTC Eris while I wait for my HTC Incredible to be shipped)

and I read about the Android NDK as well as OpenGL ES support it seemed like a good idea to write a simple particle system in C as practice for my Blender OpenCL Particle project. For some reason I also find it plain cool to write in C on a phone with such a nice SDK and support system.

I’ve uploaded my code in hopes that others trying to get into C development with OpenGL may benefit from this example. I based the Java part off the san-angeles demo in the NDK and added more touch interaction, dragging rotates the scene and touching moves the emitter of the particles. The system is pretty simple right now and I still need to get more familiar with OpenGL. I’m looking forward to trying OpenGL ES 2.0 but I need to wait for my Incredible since the Eris doesn’t support it.

This was a fun exercise and it feels good to get some fairly low level control over my phone. I need to focus more on the OpenCL acceleration of particle system’s on bigger GPUs, but luckily almost all of the C code could be copy pasted into a GLUT project and run on a PC. There are some interesting differences that need to be considered like the lack of floating point support in most Android hardware. As a hobby I’m going to explore more interesting effects on the phone, and for work I’m going to add timing/profiling and keep the code modular so I can measure performance on many different platforms (now including phones!).

Hmm… what if we ported the Blender Game Engine to Android with the NDK? I hear they have Bullet Physics already… ok I’m getting ahead of myself!

7 thoughts on “Particles on my Android

  1. Admiral Firebeard

    C on Android? I have an HTC Hero and every developer I’ve asked has assured me that you can only develop with Java on Android. If it’s possible to develop with C, it would actually be fun to write applications.

  2. enj Post author

    You can actually write in C or C++, and when you use the NDK you get access to OpenGL ES 2.0 (on supported devices).
    It’s pretty straight forward, you end up writing the interesting code in C/C++ then calling it from Java functions.

  3. Pingback: StreamComputing » Blog Archive » Mobile OpenCL 2010

  4. enj Post author

    I’m not running OpenCL on the Android… The OpenCL code runs on computers that have OpenCL support.
    Incidentally I’ve improved my C++ code in the Android section and used Crystax’s NDK tool chain to use the STL. Now my android library and desktop library are almost identical! With a little more work I should be able to have the CPU based code completely identical, I’ll write all this up in a little while when its ready.

  5. Pingback: RTPS on my Android | enj

  6. Bilal

    Yes C surely C/C++ on Android 3D Apps are possibe on Android and even its possible with Bullet Physics Engine, Check Website, in a day or two you have a video also on Bullet Integration

Comments are closed.