Name
cgGetNextParameter - iterate through a program's or effect's parameters
Synopsis
#include <Cg/cg.h>
CGparameter cgGetNextParameter( CGparameter current );
Parameters
- current
-
The current parameter.
Return Values
Returns the next parameter in the program or effect's internal sequence of parameters.
Returns NULL when current is the last parameter in the program or effect.
Description
The parameters of a program or effect can be iterated over using
cgGetNextParameter with cgGetFirstParameter, or cgGetArrayParameter.
Similarly, the parameters in an effect can be iterated over starting
with a call to cgGetFirstEffectParameter.
Note that no specific order of traversal is defined by
this mechanism. The only guarantee is that each parameter
will be visited exactly once.
Examples
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 program )
{
RecurseParams( cgGetFirstParameter( program ) );
}
Errors
CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter.
History
cgGetNextParameter was introduced in Cg 1.1.
See Also
cgGetFirstParameter,
cgGetFirstEffectParameter,
cgGetFirstStructParameter,
cgGetArrayParameter,
cgGetParameterType
|