Graphics Reference
In-Depth Information
bool UWBD3D _ GraphicsSystem::ActivateTexture( ... texFile ) {
// find in table, or load
UWBD3D _ TextureResource * pTexture = FindTextureResource( texFile );
A:
// Use of Color in Texel
m _ pD3DDevice->SetTextureStageState(... D3DTSS _ COLOROP ...);
B:
α in Texel
m _ pD3DDevice->SetTextureStageState(... D3DTSS _ ALPHAOP ...);
// Use of
// select texture resource
m _ pD3DDevice->SetTexture(stage, pTexture->GetD3DTexture() );
.
Source file.
GraphicsSystem _ TextureControls1.h
file in the D3D Files/
D3D_GraphicsSystem
sub-
void UWBD3D _ GraphicsSystem::DeactivateTexture( DWORD stage ) {
folder of the
UWBGL _ D3D _ Lib13 project.
// Disable texture
m _ pD3DDevice->SetTexture(stage, NULL);
m _ pD3DDevice->SetTextureStageState(...D3DTOP _ DISABLE...);
.
C:
Listing 12.15. Enabling and disabling texture mapping in UWBGL .
we search the texture resource table (label B of Listing 12.14) for the texFile .
This file will be opened and loaded if it does not already exist in the table. At label
B, we see code similar to that from Listing 12.11 that enables texture mapping.
The difference is that in this case, the
α
channel is also enabled to support alpha
blending with texels.
Per-Primitive Texture Attribute Support
Label C of Listing 12.16 shows two new attributes defined for all primitives:
whether file texture is enabled, and if so, the image file name. Label B shows the
access functions for the new attributes. At label A, we are reminded that before
drawing of a primitive, the SetupDrawAttribute() function is always called to
pass the attribute information to the DrawHelper class. Listing 12.17 shows the
D3D _ DrawHelper class activating and deactivating texture-mapping functional-
ity based on the primitive attribute. In this way, by the time a primitive is being
drawn, the D3D rendering state will have been properly programmed according
to the corresponding texture attributes.
Search WWH ::




Custom Search