开发者

Opengl: issue with masking

开发者 https://www.devze.com 2022-12-30 02:24 出处:网络
I\'m working on creating a hole in a wall using masking in opengl, my code is quit simple like this, //Draw the mask

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:

Opengl: issue with masking

any suggestions?


SOLVED :D It was a problem with the surfaces' Normals, once I set the normals in the correct position.The black shade faded out.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号