Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / CgD3D10 / cgD3D10BindProgram

Name

cgD3D10BindProgram - activate a program with D3D

Synopsis

#include <Cg/cgD3D10.h>

HRESULT cgD3D10BindProgram( CGprogram program );

Parameters

program
The program to activate with D3D.

Return Values

Returns D3D_OK if the function succeeds.

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

Description

cgD3D10BindProgram activates a program with D3D. The program is activated using ID3D10Device::SetVertexShader or ID3D10Device::SetPixelShader depending on the program's profile type.

D3D allows only one vertex shader and one pixel shader to be active at any given time, so activating a program of a given type implicitly deactivates any other program of a that type.

Examples

// vertexProg and pixelProg are CGprograms initialized elsewhere
// pDev is an ID3D10Device interface intialized elsewhere
...
HRESULT hr = cgD3D10BindProgram(vertexProg);
HRESULT hr2 = cgD3D10BindProgram(pixelProg);
// Draw a quad using the vertex and pixel shader
// A vertex and index buffer are set up elsewhere.
HRESULT hr3 = pDev->DrawIndexedPrimitve(D3DPT_TRIANGLELIST, 0, 4, 0, 2);

Errors

cgD3D10Failed is generated if a D3D function returns an error.

CGD3D10ERR_NOTLOADED is returned if program was not loaded with the cgD3D10LoadProgram.

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

cgD3D10BindProgram was introduced in Cg 2.1.

See Also

cgD3D10LoadProgram, cgD3D10SetTextureParameter


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