Opengl: Problem with masking
Posted
by Shaza
on Stack Overflow
See other posts from Stack Overflow
or by Shaza
Published on 2010-05-14T14:03:34Z
Indexed on
2010/05/14
14:04 UTC
Read the original article
Hit count: 264
Hey all, I'm working on creating a hole in a wall using masking in opengl, my code is quit simple like this,
//Draw the mask
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture(GL_TEXTURE_2D, texture[3]);
glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex3f(-20,40,-20);
glTexCoord2d(0,1);glVertex3f(-20,40,40);
glTexCoord2d(1,1);glVertex3f(20,40,40);
glTexCoord2d(1,0);glVertex3f(20,40,-20);
glEnd();
//Draw the Texture
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex3f(-20,40,-20);
glTexCoord2d(0,1);glVertex3f(-20,40,40);
glTexCoord2d(1,1);glVertex3f(20,40,40);
glTexCoord2d(1,0);glVertex3f(20,40,-20);
glEnd();
The problem is, I got the hole in the wall correctly but it's semi transparent, I'm getting like black shade over it, also I can see through it. Here's a photo for what I'm getting:
any suggestions?
© Stack Overflow or respective owner