NAME

cgGetParameterOrdinalNumber - get a program parameter's ordinal number

SYNOPSIS

  #include <Cg/cg.h>

  int cgGetParameterOrdinalNumber(CGparameter param);

PARAMETERS

param

Specifies the program parameter.

DESCRIPTION

cgGetParameterOrdinalNumber returns an integer that represents the order in which the parameter was declared within the Cg program.

Ordinal numbering begins at zero, starting with a program's first local leaf parameter. The subsequent local leaf parameters are enumerated in turn, followed by the program's global leaf parameters.

For example, the following Cg program:

   struct MyStruct { float a; sampler2D b; };
   float globalvar1;
   float globalvar2
   float4 main(float2 position : POSITION,
               float4 color    : COLOR,
               uniform MyStruct mystruct,
               float2 texCoord : TEXCOORD0) : COLOR
    {
     // etc ...
    }

Would result in the following parameter ordinal numbering:

   position    -> 0
   color       -> 1
   mystruct.a  -> 2
   mystruct.b  -> 3
   texCoord    -> 4
   globalvar1  -> 5
   globalvar2  -> 6

RETURN VALUES

Returns the ordinal number associated with a parameter. The parameter must not be a constant. If it is a constant (cgGetParameterVariability returns CG_CONSTANT) then 0 is returned and no error is generated.

When cgGetParameterOrdinalNumber is passed an array, the ordinal number of the first array element is returned. When passed a struct, the ordinal number of first struct data member is returned.

ERRORS

CG_INVALID_PARAM_HANDLE_ERROR is generated if the handle param is invalid.

SEE ALSO

cgGetParameterVariability