NAME
cgGetNextParameter - iterate through a program's or effect's parameters
SYNOPSIS
#include <Cg/cg.h> CGparameter cgGetNextParameter( CGparameter current );PARAMETERS
- current
Specifies the "current" parameter.
DESCRIPTION
The parameters of a program or effect can be iterated over using the cgGetNextParameter, the "cgGetFirstParameter" document, the "cgGetNextStructParameter" document, and the "cgGetArrayParameter" document functions.
The following example code illustrates one way to do this:
void RecurseParams( CGparameter param ) { if(!param) return; do { switch(cgGetParameterType(param)) { case CG_STRUCT : RecurseParams(cgGetFirstStructParameter(param)); break; case CG_ARRAY : { int ArraySize = cgGetArraySize(param, 0); int i; for(i=0; i < ArraySize; ++i) RecurseParams(cgGetArrayParameter(param, i)); } break; default : /* Do stuff to param */ } } while((param = cgGetNextParameter(param)) != 0); } void RecurseParamsInProgram( CGprogram prog ) { RecurseParams( cgGetFirstParameter( prog ) ); }Similarly, the parameters in an effect can be iterated over starting with a call to the "cgGetFirstEffectParameter" document.
Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each parameter will be visited exactly once.
RETURN VALUES
cgGetNextParameter returns the next parameter in the program's internal sequence of parameters. It returns NULL when current is the last parameter in the program.
ERRORS
CG_INVALID_PARAM_HANDLE_ERROR is generated if current does not refer to a valid parameter.
SEE ALSO
the "cgFirstParameter" document, the "cgFirstEffectParameter" document, the "cgGetFirstStructParameter" document, the "cgGetArrayParameter" document, the "cgGetParameterType" document