PDA

View Full Version : problem with masking



_patrice_
11-23-2009, 06:30 AM
Hello,

I have a problem with masking. My aim is to create an arrow with a moving stripes texture! (to illustrate a wind direction!)
So I tried to put an alpha-texture and color-texture on a quad-polygone.
Problem is, my masking works, but I'm not able to put the color-texture on my masked arrow.

I wrote this:


void drawRect(float height, float width, float texMove, GLuint tex, GLuint alpha)
{
glEnable(GL_TEXTURE_2D);

glBlendFunc(GL_DST_COLOR,GL_ZERO);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D,alpha);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


glBegin(GL_QUADS);

glNormal3f(0.0f,0.0f,1.0f);

glTexCoord2f(0.01,0.99); glVertex3f(-width/2,height/2,0.0);
glTexCoord2f(0.01,0.01); glVertex3f(-width/2,-height/2,0.0);
glTexCoord2f(0.99,0.01); glVertex3f(width/2,-height/2,0.0);
glTexCoord2f(0.99,0.99); glVertex3f(width/2,height/2,0.0);

glEnd();

glDisable(GL_BLEND);

glBlendFunc(GL_ONE,GL_ONE);
glBindTexture(GL_TEXTURE_2D,tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glBegin(GL_QUADS);

glNormal3f(0.0f,0.0f,1.0f);

glTexCoord2f(texMove,1.0); glVertex3f(-width/2,height/2,0.0);
glTexCoord2f(texMove,0.0); glVertex3f(-width/2,-height/2,0.0);
glTexCoord2f(texMove+1.0,0.0); glVertex3f(width/2,-height/2,0.0);
glTexCoord2f(texMove+1.0,1.0); glVertex3f(width/2,height/2,0.0);

glEnd();

glDisable(GL_TEXTURE_2D);
}

thx for any help!