Jump to content
  • Advertisement
Sign in to follow this  
mc30900

strange problom with masking

This topic is 4629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!