glFog causing transparent png to lose transparency
Posted
by Jamesz
on Stack Overflow
See other posts from Stack Overflow
or by Jamesz
Published on 2010-05-09T07:40:10Z
Indexed on
2010/05/09
7:48 UTC
Read the original article
Hit count: 186
Without glFog, my transparent png displays fine, but with it you can see the rectanglular background and strips of other colours (notice the other dirt material is working as intended, but not using a png or transparency).
Here's my code for the fog:
GLfloat colour[4]={0.8f,0.8f,1.0f, 1.0f};
glFogi(GL_FOG_MODE, GL_EXP);
glFogfv(GL_FOG_COLOR, colour);
glFogf(GL_FOG_DENSITY, 0.1);
glHint(GL_FOG_HINT, GL_NICEST);
glFogf(GL_FOG_START, 1.0);
glFogf(GL_FOG_END, 5.0);
glEnable(GL_FOG);
glClearColor(0.8f,0.8f,1.0f,1.0f);
And my code for the png:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GLfloat myAmbient[] = {0.7,0.7,0.7,1.0};
glMaterialfv(GL_FRONT, GL_AMBIENT, myAmbient);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, plantTexture);
glColor3f(0.5,0.5,0.2);
glPushMatrix();
glTranslated(-1,-14,10);
glScaled(10,10,10);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
glTexCoord2f(0,1); glVertex2i(1,0);
glNormal3f(0,0,1);
glTexCoord2f(0,0); glVertex2i(1,1);
glNormal3f(0,0,1);
glTexCoord2f(1,0); glVertex2i(0,1);
glNormal3f(0,0,1);
glTexCoord2f(1,1); glVertex2i(0,0);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
I'm completely lost on this one. Any ideas?
© Stack Overflow or respective owner