Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / CgD3D9 / cgD3D9LoadProgram

Name

cgD3D9LoadProgram - create a D3D shader and enable the expanded interface routines

Synopsis

#include <Cg/cgD3D9.h>

HRESULT cgD3D9LoadProgram( CGprogram program,
                           CGbool paramShadowing,
                           DWORD assemFlags );

Parameters

program
A program whose compiled output is used to create the D3D shader.
paramShadowing
Indicates if parameter shadowing is desired for program.
assemFlags
The flags to pass to D3DXAssembleShader. See the D3D documentation for a list of valid flags.

Return Values

Returns D3D_OK if the function succeeds or program has already been loaded.

Returns the D3D failure code if the function fails due to a D3D call.

Description

cgD3D9LoadProgram creates a D3D shader for a program and enables use of expanded interface routines for that program.

cgD3D9LoadProgram assembles the compiled Cg output for program using D3DXAssembleShader and then creates a D3D shader using IDirect3DDevice9::CreateVertexShader or IDirect3DDevice9::CreatePixelShader depending on the program's profile.

Parameter shadowing is enabled or disabled for the program with paramShadowing. This behavior can be changed after creating the program by calling cgD3D9EnableParameterShadowing.

The D3D shader handle is not returned. If the shader handle is desired by the application, the expanded interface should not be used for that program.

Examples

// vertexProg is a CGprogram using a vertex profile
// pixelProg is a CGprogram using a pixel profile
...
HRESULT hr1 = cgD3D9LoadProgram(vertexProg, TRUE, D3DXASM_DEBUG);
HRESULT hr2 = cgD3D9LoadProgram(pixelProg, TRUE, 0);

Errors

cgD3D9Failed is generated if a D3D function returns an error.

CGD3D9ERR_INVALIDPROFILE is returned if program's profile is not a supported D3D profile.

CGD3D9ERR_NODEVICE is returned if a required D3D device is NULL. This usually occurs when an expanded interface routine is called but a D3D device has not been set with cgD3D9SetDevice.

History

cgD3D9LoadProgram was introduced in Cg 1.1.

See Also

cgD3D9EnableParameterShadowing, cgD3D9ValidateVertexDeclaration, cgD3D9SetDevice


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