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).
Edit: Here's a screenshot.
glBlendFunc()
). Check this question and see if it helps you (alpha channel being dropped). I would suggest trying to render 2 nontextured squares on top of one another to make sure blending is working, in case your alpha channel is somehow getting dropped. \$\endgroup\$