PDA

View Full Version : How to draw fade-in/out Masked 2D image



mdive
06-18-2003, 09:45 PM
Hello.

To draw masked 2D image, I'm using next code:
(I study from next web site : http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20, (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=20) thanks)
------------------------------
//draw mask
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glBindTexture(GL_TEXTURE_2D, mask_id); //bind mask to current texture
glCallList(5); //draw textured quad

//draw image
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, image_id); //bind image to current texture
glCallList(5); //draw textured quad
---------------
above code draw no fade-in/out 2D Image.

By the way, I want to draw fade-in/out masked 2D image. How can I set glBlendFunc?

I tryed next code, but I don't get fade-in/out 2D masked iamge.
-------------------------
//draw mask
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glBindTexture(GL_TEXTURE_2D, mask_id);
glCallList(5);

//draw image
//glBlendFunc(GL_ONE, GL_ONE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE); //<-add
glBindTexture(GL_TEXTURE_2D, image_id);
glColor4f(1.0f, 1.0f, 1.0f, alpha); //<- set alpha factor to quad for 2D image.
glCallList(5);
-------------------------------
I should guess that If mask-image's black color can fade-in, we can get fade-in/out masked 2D image.

I want to understand how we set glBlendFunc in this case, to get fade-in/out Masked 2D images.

If you have any suggestion, I want to listen your suggestion very much.

sorry, my broken English.
Thanks.

[This message has been edited by mdive (edited 06-18-2003).]

nexusone
06-19-2003, 04:58 AM
I have some code I was playing around with fading in two textures, one fades in the other fads out.

If you are interested drop me an e-mail and I will send it to you.

Just make sure if it is an e-mail, that openGL is in the subject line.