Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / CgD3D9 / cgD3D9GetVertexDeclaration

Name

cgD3D9GetVertexDeclaration - get the default vertex declaration stream

Synopsis

#include <Cg/cgD3D9.h>

CGbool cgD3D9GetVertexDeclaration( CGprogram program,
                                   D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH] );

Parameters

program
The program from which to retrieve the vertex declaration.
decl
A D3DVERTEXELEMENT9 array that will be filled with the D3D9 vertex declaration.

Return Values

Returns CG_TRUE on success.

Returns CG_FALSE otherwise.

Description

cgD3D9GetVertexDeclaration retrieves the default vertex declaration stream for a program. The declaration always uses a tightly packed single stream. The stream is always terminated with D3DDECL_END(), so this can be used to determine the actual length of the returned declaration.

The default vertex declaration is always a single stream. There will be one D3DVERTEXELEMENT9 element for each varying input parameter.

If you want to use a custom vertex declaration, you can test that declaration for compatibility by calling cgD3D9ValidateVertexDeclaration.

Examples

For example:

void main( in float4 pos : POSITION,
           in float4 dif : COLOR0,
           in float4 tex : TEXCOORD0,
           out float4 hpos : POSITION );

would have this default vertex declaration:

const D3DVERTEXELEMENT9 decl[] = {
  { 0,  0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
  { 0, 16, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
  { 0, 32, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
  D3DDECL_END()
};

Errors

CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.

History

cgD3D9GetVertexDeclaration was introduced in Cg 1.1.

See Also

cgD3D9ValidateVertexDeclaration


Cg Toolkit | Cg Toolkit | Download | Release Archive | Profiles | Reference | Books | Discussions |


Cg Runtime CgD3D9

cgD3D9BindProgram
cgD3D9EnableDebugTracing
cgD3D9EnableParameterShadowing
cgD3D9GetDevice
cgD3D9GetLastError
cgD3D9GetLatestPixelProfile
cgD3D9GetLatestVertexProfile
cgD3D9GetManageTextureParameters
cgD3D9GetOptimalOptions
cgD3D9GetTextureParameter
cgD3D9GetVertexDeclaration
cgD3D9IsParameterShadowingEnabled
cgD3D9IsProfileSupported
cgD3D9IsProgramLoaded
cgD3D9LoadProgram
cgD3D9RegisterStates
cgD3D9ResourceToDeclUsage
cgD3D9SetDevice
cgD3D9SetManageTextureParameters
cgD3D9SetSamplerState
cgD3D9SetTextureParameter
cgD3D9SetTexture
cgD3D9SetTextureWrapMode
cgD3D9SetUniformArray
cgD3D9SetUniformMatrixArray
cgD3D9SetUniformMatrix
cgD3D9SetUniform
cgD3D9TranslateCGerror
cgD3D9TranslateHRESULT
cgD3D9TypeToSize
cgD3D9UnbindProgram
cgD3D9UnloadAllPrograms
cgD3D9UnloadProgram
cgD3D9ValidateVertexDeclaration