cgD3D9BindProgram

Langue: en

Version: 46784 (openSuse - 09/10/07)

Section: 3 (Bibliothèques de fonctions)

NAME

cgD3D9BindProgram - activate a program with D3D

SYNOPSIS


  #include <Cg/cgD3D9.h>






  HRESULT cgD3D9BindProgram( 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

cgD3D9BindProgram activates a program with D3D. The program is activated using IDirect3DDevice9::SetVertexShader or IDirect3DDevice9::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.

If parameter shadowing is enabled for program, this call will set the D3D state for all shadowed parameters associated with program. If a parameter associated with program has not been shadowed when this function is called, the D3D state associated with that parameter is not modified.

If parameter shadowing is disabled, only the D3D shader is activated, and no other D3D state is modified.

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);





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

cgD3D9BindProgram was introduced in Cg 1.1.

SEE ALSO

cgD3D9LoadProgram, cgD3D9EnableParameterShadowing, cgD3D9IsParameterShadowingEnabled, cgD3D9SetUniform, cgD3D9SetUniformMatrix, cgD3D9SetTextureParameter