|
|
After all that setup, actually using a shader is pretty easy: you just call SetVertexShader() or SetPixelShader() using the handle (DirectX 8) or interface (DirectX 9) that you got from a create shader call. Since there has been a change when using a shader or the FFP in DirectX 9, we'll discuss loading a shader in two version-specific sections.
If you don't want to use a vertex shader but use the FFP, then DirectX 8 will require you to make a call to SetVertexShader() but with a FVF code. This will activate the FFP. If you have a vertex shader, then you take the handle to the shader and call SetVertexShader().
// DirectX 8! // Assume we have a valid D3D pointr // pShader is a handle to a vertex shader g_pD3DDevice->SetVertexShader(pShader);
Since vertex declarations are decoupled from the vertex shaders in DirectX 9, they can be used with a vertex shader or the FFP. If you want to use the FFP, you need to call SetVertexShader() with a null argument and then call SetFVF() with the FVF you are using.
For a vertex shader, you call SetVertexShader() with the shader interface from the CreateVertexShader() call. If you're using a vertex element format that can be described with FVF, you can call SetFVF(). If you have a customized format, you would call SetVertexDeclaration() instead.
Loading a pixel shader is just as easy; you make a call to SetPixelShader() and the shader is active. The only difference is that the DirectX 8 uses a handle, whereas DirectX 9 uses an interface.
|
|