Hey guys, basically my problem is that i need to apply a .PNG texture (with some transparent parts) to a polygon, but i need the polygon to be transparent in the parts where the .PNG is transparent. Problem is, i either apply the texture and both the texture and polygon are solid or both are transparent. Here is the code and thanks for any reply.
glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glAlphaFunc(GL_GREATER,0.0f);
glBindTexture(GL_TEXTURE_2D, hud_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ALPHA);
glColor4f(1.0f,1.0f,1.0f,0.0f);
glBegin(GL_QUADS); glTexCoord2d(0.0,1.0); glVertex3f(0,0,0); glTexCoord2d(1.0,1.0); glVertex3f(512,0,0); glTexCoord2d(1.0,0.0); glVertex3f(512,256,0); glTexCoord2d(0.0,0.0); glVertex3f(0,256,0); glEnd();
glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D);