I’m planning on making a 2D game that uses sprites, so I’d like to have a transparent polygon I can put sprites on. However, my attempts to make one, with a texture on it or not, have been unsuccessful. Here’s my code:
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glAlphaFunc(GL_GREATER,0.1f); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); glTexCoord2i(0, 0); glVertex2i(10, 10); glTexCoord2i(0, 1); glVertex2i(10, 138); glTexCoord2i(1, 1); glVertex2i(74, 138); glTexCoord2i(1, 0); glVertex2i(74, 10); glEnd(); glColor4f(1.0f, 0.0f, 0.0f, 0.6f); glBegin(GL_QUADS); glVertex2i(45, 115); glVertex2i(45, 165); glVertex2i(100, 165); glVertex2i(100, 115); glEnd();
When I run this, neither polygon shows up, I just get a blank screen. If I take out glEnable(GL_BLEND), they both show up fine, except they’re both opaque. I also tried placing the glEnable in between the two polygons; this caused the second one to not appear, and the first one to appear as if it were the only one (even though the two polygons are supposed to overlap!)
Anyone have any ideas on what I’m doing wrong?