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