Game Development Reference
In-Depth Information
19.6.1 Obtaining a Handle to an Effect
The first step to using a technique is to obtain a D3DXHANDLE to that
technique. A handle to a technique can be obtained using this method:
D3DXHANDLE ID3DXEffect::GetTechniqueByName(
LPCSTR pName // Name of the technique.
);
Note: In practice, an effect file typically contains several techniques,
where each is designed for a particular set of hardware capabilities.
Therefore, the application normally runs some capability tests on the
system to determine its hardware and then selects the best technique
based on those tests. See ID3DXEffect::ValidateTechnique in the
following section.
19.6.2 Activating an Effect
Once the handle to the desired technique has been obtained, we must
activate that technique. This is done with the following method:
HRESULT ID3DXEffect::SetTechnique(
D3DXHANDLE hTechnique // Handle to the technique to set.
);
Note: Before activating a technique you will want to validate it with
the current device. That is, you will want to ensure that the hardware
supports the features the technique uses and the configuration of fea-
tures the technique uses. You can use the following method to do so:
HRESULT ID3DXEffect::ValidateTechnique(
D3DXHANDLE hTechnique // Handle to the technique to validate.
);
Recall that an effect file may have several techniques, each attempting
to implement a particular effect using different hardware features,
hoping that the implementation of at least one technique will work on
the user's system. For an effect, you will want to iterate through each
technique and run it through ID3DXEffect::ValidateTech-
nique so that you can verify which techniques are supported and
which ones are not, and then act appropriately.
19.6.3 Beginning an Effect
To render geometry using an effect, we must surround the drawing
function calls between the ID3DXEffect::Begin and ID3DXEffect
::End methods. These functions essentially enable and disable the
effect, respectively.
HRESULT ID3DXEffect::Begin(
UINT* pPasses,
DWORD Flags
);
Search WWH ::




Custom Search