opengl es - GL_COLOR_MATERIAL with lighting on Android -
it appears glcolormaterial()
absent opengl es. according this post (for iphone), may still enable gl_color_material
in opengl es 1.x, you're stuck default settings of gl_front_and_back
, gl_ambient_and_diffuse
otherwise set glcolormaterial()
. ok this, diffuse lighting not working correctly.
i set scene , tested 1 light, setting glmaterialfv()
gl_ambient
, gl_diffuse
once in initialization. normals have been set correctly, , lighting works way it's supposed to. see gouraud shading.
with gl_lighting
disabled, flat colors have set glcolor4f()
appear on various objects in scene. functions expected. however, when glenable(gl_color_material)
called, flat colors remain. expect see lighting effects.
glcolormaterial() mentioned on anddev.org, i'm not sure if information there accurate.
i'm testing on android 2.1 handset (motorola droid).
edit: works on 1.6 handset (adp1). i've filed issue 8015. not work emulator android 1.6 or 2.1.
here minimal testcase reproduce problem.
screenshot on android 1.6 (adp1):
screenshot of same code running on android 2.1 (motorola droid):
screenshot on android 1.6 (emulator):
this silly mistake on part. given 32-bit integer android color
, had forgotten scale color components floats in range [0, 1]:
gl.glcolor4f(color.red(color), color.green(color), color.blue(color), color.alpha(color));
it should have bee 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 first way still worked on g1.
Comments
Post a Comment