Platform SDK: DirectX |
Setting a color key instructs Direct3D to treat the key color as transparent. When Direct3D applies a texture that was created with the DDSD_CKSRCBLT flag to a primitive, all texels that match the key color are not rendered on the primitive. Note that any textures that were not created with the DDSD_CKSRCBLT flag will not display color-key effects, even if they contain the color key.
C++ applications set color keys with the IDirectDrawSurface7::SetColorKey method for the surface that will be using the color key (in this case, the render-target surface). However, color keying can be toggled on and off by calling the IDirect3DDevice7::SetRenderState method. Set the first parameter to D3DRENDERSTATE_COLORKEYENABLE. Your application should set the second parameter to TRUE to enable color keying and FALSE to disable it. The default is FALSE.
// This code fragment assumes that lpD3DDevice is a valid pointer to // an IDirect3DDevice7 interface. // Disable color keying. lpD3DDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
Applications written in Visual Basic set color keys with the DirectDrawSurface7.SetColorKey method for the surface that will be using the color key (in this case, the render-target surface). However, color keying can be toggled on and off by calling the Direct3DDevice7.SetRenderState method. Set the first parameter to D3DRENDERSTATE_COLORKEYENABLE. Your application should set the second parameter to True to enable color keying and False to disable it. The default is False.
' This code fragment assumes that D3DDevice contains a valid reference ' to a Direct3DDevice7 object. ' Disable color keying. Call D3DDevice.SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, _ FALSE)