I got myself a second-hand Samsung Galaxy S at last, and started hacking on it!

The very first thing I wanted to try was porting the OpenGL wikibook C++ samples, that we wrote with OpenGL ES 2 in mind.

I started writing a minimal GLUT-compatible wrapper to run the samples as-is, using the Android NDK, and I'm making progress :) The Android NDK is getting nicer with Android 2.3, though it still feels less supported than Java apps (e.g. the resize events seem buggy and the keycodes header is incomplete...). Nonetheless, it's nice to be able to write C++ portable apps.

You can see how to use the wrapper, and how it works internally, at:

http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Android

One of the limitations is that GLES2 is not a true subset of OpenGL 2.1, in particular:

the shader version is declared differently (#version 100 vs. #version 120)

GLES2 shaders require float precision hints, but OpenGL 2.1 doesn't support them at all

I needed to pre-process these differences away, checking on GL_ES_VERSION_2_0 in the C++ source code to define a GLES2 macro in the shaders:

#ifdef GLES2 varying lowp vec4 f_color ; # else varying vec4 f_color ; #endif

Is there a better way?