Lesson 20 (Masking)
I''m trying to get masking to work in my program. However the image is just displayed transparent. Here is what happens (note that the image should be right in front of the viewer and not behind the walls)
http://members.nbci.com/atcandrew/screen.jpg
Here is the code that displays the image:
void Character::Draw(GLuint mask, GLuint texture)
{
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture(GL_TEXTURE_2D, mask);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-xpos, -1.0, -zpos);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-xpos-width, -1.0, -zpos);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-xpos-width, -1.0+height, -zpos);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-xpos, -1.0 + height, -zpos);
glEnd();
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-xpos, -1.0, -zpos);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-xpos-width, -1.0, -zpos);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-xpos-width, -1.0+height, -zpos);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-xpos, -1.0 + height, -zpos);
glEnd();
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
}
mask and texture have been binded, so that is probably not the problem. Also the texture and vertex coordinates are all good.
Here are the images because that will probably help:
http://members.nbci.com/atcandrew/face.bmp (texture)
http://members.nbci.com/atcandrew/bwface.bmp (mask)
(I know I am not an artist!!)
I''ve been trying to get this to work for over an hour (I looked over that example code mannnnny times.)
Yeah, so if anyone knows what to do, thanks a lot!
[Edited by - atcdevil on October 12, 2006 10:22:07 AM]
At least tell me if this is a dumb question that doesn''t deserve an answer!!!!!!!!!!!!!!!!
try not disabling the depth test before the first pass
then before the second pass, set the depth function to less than or equal like so:
glDepthFunc(GL_LEQUAL)
Also disable blending for the first pass, enable it only on the second pass.
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
then before the second pass, set the depth function to less than or equal like so:
glDepthFunc(GL_LEQUAL)
Also disable blending for the first pass, enable it only on the second pass.
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
---I write code.DelphiGL (http://delphigl.cfxweb.net)
Also, if there is no texture on the quad for the first pass, disable texturing before you draw it, otherwise if texturing is enabled the quad will be texture mapped with whatever the current texture is.
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
---I write code.DelphiGL (http://delphigl.cfxweb.net)
Hey thanks for the help Jason, I did what you said. Just it''s not working perfect yet. Where I want it to be transparent, it is white. If you know what to do, thanks a lot.
You probably have to mess around with the glBlendFunc
try GL_SRC_COLOR, GL_DST_COLOR or GL_DST_COLOR, GL_SRC_COLOR.
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
try GL_SRC_COLOR, GL_DST_COLOR or GL_DST_COLOR, GL_SRC_COLOR.
Jason A.
---
I write code.
DelphiGL (http://delphigl.cfxweb.net)
---I write code.DelphiGL (http://delphigl.cfxweb.net)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement