Microsoft DirectX 8.0 (C++)

IDirect3DDevice8::CreateVertexShader

Creates a vertex shader and if created successfully sets that shader as the current shader.

HRESULT CreateVertexShader(
  CONST DWORD* pDeclaration,
  CONST DWORD* pFunction,
  DWORD* pHandle,
  DWORD Usage
);

Parameters

pDeclaration
[in, out] Pointer to the vertex shader declaration token array. This parameter defines the inputs to the shader, including how the vertex elements within the input data streams are used by the shader.
pFunction
[in, out] Pointer to the vertex shader function token array. This parameter defines the operations to apply to each vertex. If this parameter is set to NULL, a shader is created for the fixed-function pipeline and the parameter declaration indicated by pDeclaration is made current and available to be set in a subsequent call to IDirect3DDevice8::SetVertexShader as long as a handle pointer is provided.

If this parameter is not set to NULL, the shader is programmable.

pHandle
[in, out] Pointer to the returned vertex shader handle. This value cannot be set as NULL.
Usage
[in] Usage controls for the vertex shader. The following flag can be set.
D3DUSAGE_SOFTWAREPROCESSING
Set to indicate that the vertex shader is to be used with software vertex processing. The D3DUSAGE_SOFTWAREPROCESSING flag must be set for vertex shaders used when the D3DRS_SOFTWAREVERTEXPROCESSING member of the D3DRENDERSTATETYPE enumerated type is TRUE, and removed for vertex shaders used when D3DRS_SOFTWAREVERTEXPROCESSING is FALSE.

Return Values

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

Remarks

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.

Requirements

  Header: Declared in D3d8.h.
  Import Library: Use D3d8.lib.

See Also

IDirect3DDevice8::DeleteVertexShader, D3DXAssembleShader, D3DXAssembleShaderFromFileA, D3DXAssembleShaderFromFileW, D3DXDeclaratorFromFVF