Microsoft DirectX 8.1 (Visual Basic)

Direct3DDevice8.CreateVertexShader

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

object.CreateVertexShader( _ 
    DeclarationTokenArray As Long, _ 
    FunctionTokenArray As Any, _ 
    retHandle As Long, _ 
    Usage As Long)

Parts

object
Object expression that resolves to a Direct3DDevice8 object.
DeclarationTokenArray
First element of 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.
FunctionTokenArray
First element of the vertex shader function token array. This parameter defines the operations to apply to each vertex. If this parameter is set to ByVal 0, a shader is created for the fixed-function pipeline and the parameter declaration indicated by DeclarationTokenArray is made current and available to be set in a subsequent call to Direct3DDevice8.SetVertexShader.

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

retHandle
Returned vertex shader handle.
Usage
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 CONST_D3DRENDERSTATETYPE enumerated type is 1, and removed for vertex shaders used when D3DRS_SOFTWAREVERTEXPROCESSING is 0.

Error Codes

If the method fails, an error is raised and Err.Number can be set to one of the following values.

D3DERR_INVALIDCALL
D3DERR_OUTOFVIDEOMEMORY
E_OUTOFMEMORY

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

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 Long tokens terminated by a special &HFFFFFFFF 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 d3dshader.bas for a definition of the constants used to generate the declaration token array.

See Also

Direct3DDevice8.DeleteVertexShader, D3DX8.AssembleShader, D3DX8.AssembleShaderFromFile, D3DX8.DeclaratorFromFVF