Name

cgD3D9UnbindProgram - de-activate a program with D3D

Synopsis

#include <Cg/cgD3D9.h>

HRESULT cgD3D9UnbindProgram( CGprogram program );

Parameters

program
The program to de-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

cgD3D9UnbindProgram de-activates a program with D3D. The program is de-activated using IDirect3DDevice9::SetVertexShader or IDirect3DDevice9::SetPixelShader with a NULL argument depending on the program's profile type.

Examples

// vertexProg and pixelProg are CGprograms initialized elsewhere
// pDev is an IDirect3DDevice9 interface intialized elsewhere
...
HRESULT hr = cgD3D9BindProgram(vertexProg);
HRESULT hr2 = cgD3D9BindProgram(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);

cgD3D9UnbindProgram(vertexProg);
cgD3D9UnbindProgram(pixelProg);

Errors

cgD3D9Failed is generated if a D3D function returns an error.

CGD3D9ERR_NOTLOADED is returned if program was not loaded with the cgD3D9LoadProgram.

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

cgD3D9UnbindProgram was introduced in Cg 3.0.

See Also

cgD3D9LoadProgram, cgD3D9BindProgram