NAME

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

SYNOPSIS

  #include <Cg/cgD3D9.h>

  HRESULT cgD3D9LoadProgram( CGprogram program,
                             CGbool paramShadowing,
                             DWORD assemFlags );

PARAMETERS

program

A program whose compiled output is used to create the D3D shader.

paramShadowing

Indicates if parameter shadowing is desired for program.

assemFlags

The flags to pass to D3DXAssembleShader. See the D3D documentation for a list of valid flags.

RETURN VALUES

cgD3D9LoadProgram returns D3D_OK if the function succeeds or program has already been loaded.

If the function fails due to a D3D call, that D3D failure code is returned.

DESCRIPTION

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

cgD3D9LoadProgram assembles the compiled Cg output for program using D3DXAssembleShader() and then creates a D3D shader using IDirect3DDevice9::CreateVertexShader() or IDirect3DDevice9::CreatePixelShader() depending on the program's profile.

Parameter shadowing is enabled or disabled for the program with paramShadowing. This behavior can be changed after creating the program by calling cgD3D9EnableParameterShadowing.

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

The following example code illustrates the use of cgD3D9LoadProgram:

  // vertexProg is a CGprogram using a vertex profile
  // pixelProg is a CGprogram using a pixel profile
  ...
  HRESULT hr1 = cgD3D9LoadProgram(vertexProg, TRUE, D3DXASM_DEBUG);
  HRESULT hr2 = cgD3D9LoadProgram(pixelProg, TRUE, 0);

ERRORS

CGD3D9ERR_INVALIDPROFILE to-be-written.

CGD3D9ERR_NODEVICE to-be-written.

HISTORY

cgD3D9LoadProgram was introduced in Cg to-be-written.

SEE ALSO

cgD3D9EnableParameterShadowing, cgD3D9ValidateVertexDeclaration, cgD3D9SetDevice