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, in the
  // style of cgGetArrayTotalSize(param)
  if (cgIsArray(param)) {
    int dim = cgGetArrayDimension(param);
    int elements = cgGetArraySize(param, 0);
    for (int i = 1; i < dim; i++) {
       elements *= cgGetArraySize(param, i);
    }
    return elements;
  }
       

RETURN VALUES

Returns the size of param if param is an array.

Returns 0 is param is not an array, or other 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.

SEE ALSO

the "cgGetArrayTotalSize" document, the "cgGetArrayDimension" document, the "cgGetArrayParameter" document