GL_COLOR_MATERIAL backlit on Android
Seems to be glColorMaterial()
missing from OpenGL ES . According to this post (for iPhone), you can enable GL_COLOR_MATERIAL
OpenGL ES 1.x, but you are stuck with the default settings GL_FRONT_AND_BACK
and GL_AMBIENT_AND_DIFFUSE
which you would otherwise install with glColorMaterial()
. I would be fine with this, but diffuse lighting is not working properly.
I set my scene and tested it with one light setting glMaterialfv()
for GL_AMBIENT
and GL_DIFFUSE
once in initialization. The standards are set correctly and the lighting is working as intended. I see Gouraud shading.
With disabled, the GL_LIGHTING
flat colors I set with glColor4f()
are displayed on different objects in the scene. This also works as expected. However, when called glEnable(GL_COLOR_MATERIAL)
, flat colors remain. I expect to see lighting effects.
glColorMaterial () is also mentioned on anddev.org , but I'm not sure if the information there is accurate.
I am testing this on Android 2.1 phone (Motorola Droid).
Edit : It works correctly on my 1.6 tube (ADP1). I have filed Issue 8015 . It does not work with emulator for Android 1.6 or 2.1.
Below is a minimal test file to reproduce the problem.
Screenshot on Android 1.6 (ADP1):

Screenshot with the same code as on Android 2.1 (Motorola Droid):

Screenshot on Android 1.6 (emulator):

a source to share
It was a stupid mistake on my part. Given a 32 bit Android integer color
, I forgot to scale the color components to float in the range [0, 1]:
gl.glColor4f(Color.red(color), Color.green(color), Color.blue(color), Color.alpha(color));
He must have bees like this:
gl.glColor4f(Color.red(color)/(float) 0xFF, Color.green(color)/(float) 0xFF, Color.blue(color)/(float) 0xFF, Color.alpha(color)/(float) 0xFF);
I'm not sure why the first method still worked on my G1.
a source to share