strange problom with masking

Started by
0 comments, last by lack the hack 18 years, 3 months ago
hello all. i am trying to mask and for some reason i can see the picture, it has white background and it has "holes" where is the real picture and i have no idea why. the code is glDisable(GL_DEPTH_TEST); glBlendFunc(GL_DST_COLOR,GL_ZERO); glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, texture[4]); glBegin(GL_QUADS); glTexCoord2f(1.0,1.0);glVertex3f(float(unit1[0]+6),float(unit1[1]+6),float(unit1[2])); glTexCoord2f(1.0,0.0);glVertex3f(float(unit1[0]+6),float(unit1[1]-6),float(unit1[2])); glTexCoord2f(0.0,0.0);glVertex3f(float(unit1[0]-6),float(unit1[1]-6),float(unit1[2])); glTexCoord2f(0.0,1.0);glVertex3f(float(unit1[0]-6),float(unit1[1]+6),float(unit1[2])); glEnd(); glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[3]); glBegin(GL_QUADS); glTexCoord2f(1.0,1.0);glVertex3f(float(unit1[0]+6),float(unit1[1]+6),float(unit1[2])); glTexCoord2f(1.0,0.0);glVertex3f(float(unit1[0]+6),float(unit1[1]-6),float(unit1[2])); glTexCoord2f(0.0,0.0);glVertex3f(float(unit1[0]-6),float(unit1[1]-6),float(unit1[2])); glTexCoord2f(0.0,1.0);glVertex3f(float(unit1[0]-6),float(unit1[1]+6),float(unit1[2])); glEnd(); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); does anyone have any idea why this isnt working? thanks in advance
Advertisement
try doing something like this
void draw(){   glBegin(GL_QUADS);   glTexCoord2f(0,0); glVertex3f(0,0,0);   glTexCoord2f(1,0); glVertex3f(10,0,0);   glTexCoord2f(1,1); glVertex3f(10,10,0);   glTexCoord2f(0,1); glVertex3f(0,10,0);   glEnd();}

and then do your masking like this
glEnable(GL_TEXTURE_2D)glDisable(GL_DEPTH_TEST);glEnable(GL_BLEND);glBlendFunc(GL_DST_COLOR,GL_ZERO);glBindTexture(GL_TEXTURE_2D,maskTexture);draw();glBlendFunc(GL_ONE,GL_ONE);glBindTexture(GL_TEXTURE_2D,texture);draw();glDisable(GL_BLEND);glDisable(GL_TEXTURE_2D);glEnable(GL_DEPTH_TEST);


i believe your problem is that your calling the BlendFunc() before you have enable GL_BLEND.

let me know if it works

--nathan

This topic is closed to new replies.

Advertisement