PDA

View Full Version : Using a black & white image as a mask



ericb81
11-29-2010, 02:08 AM
Hi all,

I am pretty new to OpenGL, and I still find some of the options confusing. My goal is to use a black & white image as a mask for any other image, i.e. I only want my image to display through the white parts of my mask image. It's not very clear to me whether I should use blending, stencils, etc.

Any help would be appreciated.

Thanks,
Eric

ericb81
11-29-2010, 03:29 AM
I have implemented the following solution (C# + OpenTK)

GL.Disable(EnableCap.Blend);
GL.Clear(ClearBufferMask.ColorBufferBit);

// render the mask
textures[0].GlRender();

GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.SrcColor);

// render the image (which will be clipped to the masks white region)
textures[1].GlRender();