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

The array parameter handle.

dimension

The dimension whose size will be returned.

RETURN VALUES

Returns the size of param if param is an array.

Returns 0 is param is not an array, or other error.

DESCRIPTION

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

EXAMPLES

  // 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;
  }
       

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.

HISTORY

cgGetArraySize was introduced in Cg 1.1.

SEE ALSO

cgGetArrayTotalSize, cgGetArrayDimension, cgGetArrayParameter, cgGetMatrixSize, cgGetTypeSizes