I'm trying to do a two pass render by rendering two textured and coloured meshes on top of each other. The textured mesh that is rendered first has no alpha and the second textured mesh has alpha values provided by a colour array (i.e. the texture itself has no alpha values).
I have this working fine on mac (not iOS) but on iPhone only the 2nd textured mesh is visible, as if none of the alpha from the colour array is being applied.
The code is as follows:
Code:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
//First pass
glDisable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTexture1);
glVertexPointer(3, GL_FLOAT, 0, mVertices);
glNormalPointer(GL_FLOAT, 0, mNormals);
glTexCoordPointer(2, GL_FLOAT, 0, mTexCoords);
glColorPointer(4, GL_FLOAT, 0, mWhite);
glDrawElements(GL_TRIANGLE_STRIP, mNumIndices, GL_UNSIGNED_SHORT, mIndices );
//Second pass
glBindTexture(GL_TEXTURE_2D, mTexture2);
glDepthFunc(GL_EQUAL);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glVertexPointer(3, GL_FLOAT, 0, mVertices);
glNormalPointer(GL_FLOAT, 0, mNormals);
glTexCoordPointer(2, GL_FLOAT, 0, mTexCoords);
glColorPointer(4, GL_FLOAT, 0, colours);
glDrawElements(GL_TRIANGLE_STRIP, mNumIndices, GL_UNSIGNED_SHORT, mIndices );
//Finish up
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_LESS);
So the first mesh rendered is supposedly always being rendered, and the second mesh, which shares the vertices of the first mesh is forced to be visible because the depth testing is set to GL_EQUAL, but why doesn't the blend work?
Does anyone have any ideas?
Thanks.