Game Development Reference
In-Depth Information
the alphachannel.bmp file that is located in this chapter's texAlpha
sample folder. Figure 7.6 shows the program after the alpha channel
data has been inserted.
Figure 7.6: Resulting texture
with an alpha channel
Now save the texture with the name of your choice; we used the name
cratewalpha.dds.
7.5 Sample Application: Transparency
The sample application draws a transparent teapot on top of a crate
background—the same one shown in Figure 7.2. The alpha is taken
from the material in this example. The application allows you to
increase/decrease the alpha component interactively by pressing the A
and S keys. The A key increases the alpha component; the S key
decreases it.
The steps required to use blending are:
1. Set the blend factors D3DRS_SRCBLEND and D3DRS_DESTBLEND .
2. If using the alpha component, specify the source (material or alpha
channel).
3. Enable the alpha blending render state.
For this sample, we instantiate the following self-explanatory global
variables:
ID3DXMesh* Teapot = 0; // the teapot
D3DMATERIAL9 TeapotMtrl; // the teapot's material
IDirect3DVertexBuffer9* BkGndQuad = 0; // background quad - crate
IDirect3DTexture9*
BkGndTex = 0; // crate texture
D3DMATERIAL9
BkGndMtrl;
// background material
Search WWH ::




Custom Search