122 Chapter 2 The Graphics System
EnableAlphaBlending(SBF_SRC_ALPHA,DBF_ONE_MINUS_SRC_ALPHA);
EnableAlphaTesting(1); // alpha reference = 1
// first pass
SetAlphaTestCompare(equal);
EnableDepthWrite();
Draw(objects);
// second pass
SetAlphaTestCompare(not_equal);
DisableDepthWrite();
Draw(objects);
Another application for alpha testing is for drawing objects that have textures
whose alpha values are either 0 or 1. The idea is that the texture in some sense defines
what the object is. A classic example involves applying a decal to an object. The decal
geometry is a rectangle that has a texture associated with it. The texture image has
an artistically drawn object that does not cover all the image pixels. The pixels not
covered are “see-through”; that is,