Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / CgD3D10 / cgD3D10LoadProgram

Name

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

Synopsis

#include <Cg/cgD3D10.h>

HRESULT cgD3D10LoadProgram( CGprogram program,
                            UINT flags );

Parameters

program
A program whose compiled output is used to create the D3D shader.
flags
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

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

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

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 = cgD3D10LoadProgram(vertexProg, TRUE, D3DXASM_DEBUG);
HRESULT hr2 = cgD3D10LoadProgram(pixelProg, TRUE, 0);

Errors

cgD3D10Failed is generated if a D3D function returns an error.

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

CGD3D10ERR_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 cgD3D10SetDevice.

History

cgD3D10LoadProgram was introduced in Cg 2.1.

See Also

cgD3D10SetDevice


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


Cg Runtime CgD3D10

cgD3D10BindProgram
cgD3D10CreateBufferFromObject
cgD3D10CreateBuffer
cgD3D10GetBufferByIndex
cgD3D10GetBufferObject
cgD3D10GetCompiledProgram
cgD3D10GetDevice
cgD3D10GetIASignatureByPass
cgD3D10GetLastError
cgD3D10GetLatestGeometryProfile
cgD3D10GetLatestPixelProfile
cgD3D10GetLatestVertexProfile
cgD3D10GetManageTextureParameters
cgD3D10GetOptimalOptions
cgD3D10GetProgramErrors
cgD3D10IsProfileSupported
cgD3D10IsProgramLoaded
cgD3D10LoadProgram
cgD3D10RegisterStates
cgD3D10SetDevice
cgD3D10SetManageTextureParameters
cgD3D10SetSamplerStateParameter
cgD3D10SetTextureParameter
cgD3D10SetTextureSamplerStateParameter
cgD3D10TranslateCGerror
cgD3D10TranslateHRESULT
cgD3D10TypeToSize
cgD3D10UnbindProgram
cgD3D10UnloadProgram