2
votes

I am drawing non-textured triangles whose alpha is being explicitly set to to 0.5 in the pixel shader for testing purposes. My application is based on the Opengl ES prefab provided by Xcode. I have not touched my EAGLView class.

I call

glEnable(GL_ALPHA)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SC_ALPHA)
glDrawArrays(...)

My clearColor is 0,0,0,1 and CAEAGLayer's format is RGBA8.

The result I see is that no blending of any sort takes place and drawn pixels simply replace what's underneath. I have also attempted to use GL_ONE,GL_ONE.

I tried to set the opaque property of my CAEAGLayer to false. The result seems to be that regardless of blend mode, the color of the drawn pixels is blended with white based on the alpha value. So gl_FragColor of 1,0,0,1 comes out as 1,0,0,1 but 1,0,0,0 comes out as 1,1,1,?

This behavior is consistent on the device and simulator. What could be wrong here?

1

1 Answers

6
votes

You have to enable GL_BLEND and not GL_ALPHA. The GL_ALPHA constant has a completely different purpose (as a color channel identifier). So your glEnable call actually causes a GL_INVALID_ENUM error or something the like.