Hi, i''m using the following code (and it works fine) to draw a textured object with trasparency. However, it requires to draw 2 quads and use 2 textures, so here is my question: can i achieve the same only drawing 1 quad and using only one texture ?
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture(GL_TEXTURE_2D, bw_texture);
glBegin(GL_QUADS);
// draw the quad
glEnd();
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, color_texture);
glBegin(GL_QUADS);
// draw the quad stuff
glEnd();
glHorizon_Project
www.web-discovery.net
Assuming that your quads exactly overlap, you can.
The easiest method is to assign an alpha channel to your coloured texture. Tha alpha channel has to be 1 wherever you want to draw your texture, and 0 wherever you don''t want to draw your texture (eg see what''s behind). But this works essentially if your coloured texture doesn''t already has an alpha channel. If your texture already has an alpha channel, it''s still possible but it''s a bit more difficult.
Then you have (at least) two solutions for using this texture that has a brand new alpha chennel :