Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / CgD3D11 / cgD3D11LoadProgram

Name

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

Synopsis

#include <Cg/cgD3D11.h>

HRESULT cgD3D11LoadProgram( CGprogram program,
                            UINT flags );

Parameters

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

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

cgD3D11LoadProgram compiles the compiled Cg output for program using D3DCompile and then creates a D3D shader using ID3D11Device::CreateVertexShader or ID3D11Device::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 = cgD3D11LoadProgram(vertexProg, 0);
HRESULT hr2 = cgD3D11LoadProgram(pixelProg, 0);

Errors

E_FAIL is generated if a D3D function returns an error.

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

E_FAIL 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 cgD3D11SetDevice.

History

cgD3D11LoadProgram was introduced in Cg 3.0.

See Also

cgD3D11SetDevice


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


Cg Runtime CgD3D11

cgD3D11BindProgram
cgD3D11CreateBufferFromObject
cgD3D11CreateBuffer
cgD3D11GetBufferByIndex
cgD3D11GetBufferObject
cgD3D11GetCompiledProgram
cgD3D11GetDevice
cgD3D11GetIASignatureByPass
cgD3D11GetLastError
cgD3D11GetLatestDomainProfile
cgD3D11GetLatestGeometryProfile
cgD3D11GetLatestHullProfile
cgD3D11GetLatestPixelProfile
cgD3D11GetLatestVertexProfile
cgD3D11GetManageTextureParameters
cgD3D11GetOptimalOptions
cgD3D11GetProgramErrors
cgD3D11IsProfileSupported
cgD3D11IsProgramLoaded
cgD3D11LoadProgram
cgD3D11RegisterStates
cgD3D11SetDevice
cgD3D11SetManageTextureParameters
cgD3D11SetSamplerStateParameter
cgD3D11SetTextureParameter
cgD3D11SetTextureSamplerStateParameter
cgD3D11TranslateCGerror
cgD3D11TranslateHRESULT
cgD3D11TypeToSize
cgD3D11UnbindProgram
cgD3D11UnloadProgram