Microsoft DirectX 8.1 (C++) |
Creates a vertex shader.
HRESULT CreateVertexShader( CONST DWORD* pDeclaration, CONST DWORD* pFunction, DWORD* pHandle, DWORD Usage );
Value | Description |
---|---|
0 | Vertex processing is done in hardware. |
D3DUSAGE_SOFTWAREPROCESSING | Vertex processing is done in software. |
It is good practice to match the usage parameter in CreateVertexShader with the behavior flags in CreateDevice. See the Remarks section for more information.
If the method succeeds, the return value is D3D_OK.
If the method fails, the return value can be one of the following values.
D3DERR_INVALIDCALL |
D3DERR_OUTOFVIDEOMEMORY |
E_OUTOFMEMORY |
A vertex shader can be used with either hardware or software vertex processing. This is determined by how the device and the vertex shader are created.
When a device is created, CreateDevice uses the behavior flag to determine whether to process vertices in hardware or software. There are three possibilities:
Mixed-mode devices may need to switch between software and hardware processing after the device is created. In this case, set the D3DRS_SOFTWAREVERTEXPROCESSING render state using SetRenderState.
When a vertex shader is created, CreateVertexShader uses the usage parameter to decide whether to process vertices in hardware or software.
To use a vertex shader with a mixed-mode device, create separate shaders for hardware and software processing. Use SetVertexShader to set the current shader and use SetRenderState, if necessary, to change the device behavior to match. It is recommended that the shader usage matches the device behavior.
A vertex shader is defined by two token arrays that specify the declaration and function of the shader. The token arrays are composed of single or multiple DWORD tokens terminated by a special 0xFFFFFFFF token value.
The shader declaration defines the static external interface of the shader, including binding of stream data to vertex register inputs and values loaded into the shader constant memory. The shader function defines the operation of the shader as an array of instructions that are executed in order for each vertex processed during the time the shader is bound to a device. Shaders created without a function array apply the fixed function vertex processing when that shader is current.
See D3d8types.h for a definition of the macros used to generate the declaration token array.
Header: Declared in D3d8.h.
Import Library: Use D3d8.lib.
DeleteVertexShader, D3DXAssembleShader, D3DXAssembleShaderFromFile, D3DXDeclaratorFromFVF, CreateDevice.