Download Users Manual

Transcript
Cg Language Toolkit
void main(BarStruct Bar[3]) {
// ...
}
The following are valid names for retrieving the corresponding parameter:
“Bar”
“Bar[1]”
“Bar[1].Foo”
“Bar[1].Foo[0]”
“Bar[1].Foo[0].B”
Parameter Values
The core Cg runtime provides a number of entry points for setting and retrieving parameter values. In addition, the graphics‐API‐specific Cg runtimes provide additional entry points for managing parameter values. When managing numeric parameters, choosing which set of entry points to use is largely a matter of programmer preference. In some circumstances, it may be slightly more efficient to use the core Cg runtime entry points. However, parameters that hold graphics‐API‐specific quantities, such as sampler handles, must be set using the API‐specific entry points. The API‐
specific entry points must be used because the core Cg runtime, which is graphics‐API‐agnostic, provides no such entry points.
The most often‐used parameter value routines are used to set and get a parameter’s current values. A parameter’s current value is initialized to any default value assigned in the Cg source, or 0 otherwise. The current value of a numeric parameter can be queried using the family of entry points:
int cgGetParameterValue{i,f,d}{r,c}(CGparameter param,
int nvals, type *v);
The given parameter must be a scalar, vector, matrix, or an (possibly‐
multidimensional) array of scalars, vectors, or matrices. There are versions of each function to retrieve the values into an int, float, or double buffer; these are signified by the i, f, and d in the entry point name, respectively. Similarly, there are versions of each function that retrieve any matrices in the given parameter in row‐major or column‐major order. These are specified using r or c, respectively. At most, nvals values will be copied into the given array, v. The total number of values copied into v is returned.
For example, cgGetParameterValueic() retrieves the values of the given parameter into the supplied array of integer data, and copies matrix data in column‐major order. The total number of values associated with a given 58
NVIDIA
808-00504-0000-006