NAME

cgGetArraySize - get the size of one dimension of an array parameter

SYNOPSIS

  #include <Cg/cg.h>

  int cgGetArraySize( CGparameter param, int dimension );

PARAMETERS

param

Specifies the array parameter handle.

dimension

Specifies the dimension whose size will be returned.

DESCRIPTION

cgGetArraySize returns the size one the specified dimension of the array specified by param. This function is used when inspecting an array parameter in a program.

EXAMPLE

  // compute the number of elements in an array
  if( cgIsArray( param ) ) {
    int dim = cgGetArrayDimension( param );
    int elements = cgGetArraySize( param, 0);
    for( int i=1; i < dim; i++ ) {
       elements *= cgGetArraySize( param, i );
    }
    ...
  }
       

RETURN VALUES

Returns the size of param if param references an array.

Returns -1 on error.

ERRORS

CG_INVALID_DIMENSION_ERROR is generated if dimension is less than 0.

CG_INVALID_PARAM_HANDLE_ERROR is generated if param is an invalid parameter handle or not an array.

SEE ALSO

the "cgGetNextParameter" document, the "cgGetArrayDimension" document, the "cgGetArrayParameter" document