Multitexturing && Texture With Alpha Channel problem....

Hi all,
I have two textures, while texture0 has no alpha channel(RGB 565), and texture1 has alpha channel (RGBA8888), i export&load them via pvr format.
so the final rgb = texture0.rgb + (texture1.rgb * texture1.alpha). //and there is no need to blend with background color
I am new to opengl es, and i found glTexEnv(xxx) is so hard to understand and use…
I’ve tried code in “OGLES-1.1_WINDOWS_PCEMULATION_2.03.23.1162\TrainingCourse\10_Multitexture”, but the result looks strange, here is my code:


        glDisable(GL_BLEND); 
         glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, m_ui32Ground);
              // Set up the Second Texture
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_2D,  m_ui32WallForeground);//m_ui32WallForeground
		
	   /**/
		// Set the texture environment mode for this texture to combine
		myglTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);

		// Set the method we're going to combine the two textures by.
		myglTexEnv(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);//GL_MODULATE

		// Use the previous combine texture as source 0
		myglTexEnv(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);

		// Use the current texture as source 1
		myglTexEnv(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);

		
			//Set what we will operate on, in this case we are going to use
			//just the texture colours.
		
		myglTexEnv(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
		myglTexEnv(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_DST_ALPHA);
		

		// Indexed Triangle list
		glDrawElements(GL_TRIANGLES, Mesh.nNumFaces * 3, GL_UNSIGNED_SHORT, (unsigned short*)Mesh.sFaces.pData);

Please help me…

GL_DST_ALPHA is not a valid value for GL_OPERAND1_RGB, I suppose you meant GL_SRC_ALPHA.

However, to do what you want, i.e.
final rgb = texture0.rgb + (texture1.rgb * texture1.alpha)
you need to do the multiplication first, i.e. on texture environment TEXTURE0, and the addition on TEXTURE1. To keep it simple you can set the vertex color to black and use GL_DECAL and GL_ADD.

glColor4ub(0, 0, 0, 255);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_ui32WallForeground);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_ui32Ground);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);