Dear Lazyweb, why doesn’t alpha blending work when lighting is enabled on Android? Transparency works with glColor but not with glMaterial.
GL_VERSION in the Android simulator is “OpenGL ES-CM 1.1 (4.1 Metal - 88.1)”.
This works fine on iOS and Cocoa, so it’s not strictly a GLES thing, just Android. GLSL is not involved.
Test case:
Bool lights_p = time(0) & 1; glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable (GL_BLEND); glDisable (GL_COLOR_MATERIAL); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #define glColor4fv(v) glColor4f (v[0], v[1], v[2], v[3]) GLfloat c1[] = { 1, 0, 0, 0.5 }; GLfloat c2[] = { 0, 1, 0, 0.5 }; GLfloat v[] = { 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, }; glVertexPointer (3, GL_FLOAT, 0, v); glEnableClientState (GL_VERTEX_ARRAY); if (lights_p) { GLfloat amb[] = {0.5, 0.5, 0.5, 1}; glLightfv (GL_LIGHT0, GL_AMBIENT, amb); glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); glColor3f (0, 0, 0); } else { glDisable (GL_LIGHTING); glDisable (GL_LIGHT0); } if (lights_p) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, c1); else glColor4fv (c1); glDrawArrays (GL_TRIANGLES, 0, 6); glPushMatrix(); glTranslatef (0.5, 0.25, 0); if (lights_p) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, c2); else glColor4fv (c2); glDrawArrays (GL_TRIANGLES, 0, 6); glPopMatrix(); glDisableClientState (GL_VERTEX_ARRAY); glVertexPointer (3, GL_FLOAT, 0, 0);
From jwz via this RSS feed


