As the title says, whenever i enable blending like this:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I cannot draw any texture using immediate mode. It is an RGBA texture. I confirmed that image loading and generating works correctly, as when i "downloaded" the pixel from the GPU to debug this, the alpha values seemed to be correct (not all of them were 255, for example.). However, the texture just disappears when drawing it like this with blending enabled:
glColor4ub(255, 255, 255, 0);
_texture->setActive(0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(_x, _y);
glTexCoord2f(1.0f, 0.0f);
glVertex2f(_x + _width, _y);
glTexCoord2f(1.0f, 1.0f);
glVertex2f(_x + _width, _y + _height);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(_x, _y + _height);
glEnd();
Where _texture->setActive()
simply calls this:
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, m_ID);
Without blending, i get the following result:
But with blending it simply draws nothing (again, alpha values of the texture are confirmed to be correct!):
When it should look something like this:
What is the issue here?
Update
After applying glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
, i now get the expected output: