Transparent parts of texture are opaque black instead
- by Aaron
I render a sprite twice, one on top of the other. The sprites have transparent parts, so I should be able to see the bottom sprite under the top sprite. The transparent parts are black (the clear colour) and opaque instead though and the topmost sprite blocks the bottom sprite.
My fragment shader is trivial:
uniform sampler2D texture;
varying vec2 f_texcoord;
void main()
{
gl_FragColor = texture2D(texture, f_texcoord);
}
I have glEnable(GL_BLEND) and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) in my initialization code. My texture comes from a PNG file that I load with libpng. I'm sure to use GL_RGBA when initializing the texture with glTexImage2D (otherwise the sprites look like noise).