Name
cgSetEffectParameterBuffer - sets a Cg buffer to every program in the effect that uses
the passed effect buffer parameter.
Synopsis
#include <Cg/cg.h>
void cgSetEffectParameterBuffer(CGparameter param,
CGbuffer buffer);
Parameters
- param
-
The effect parameter used by programs in the effect as a buffer parameter.
- buffer
-
The Cg buffer being set to param for each program in the effect that uses param.
Return Values
None.
Description
cgSetEffectParameterBuffer allows the application with a single API call to set a Cg
buffer to an effect parameter using the BUFFER semantic for each program in the effect
that uses this effect parameter.
cgSetEffectParameterBuffer does the equivalent of the following:
CGtechnique technique = cgGetFirstTechnique(myCgEffect);
for(; technique; technique = cgGetNextTechnique(technique))
{
if(!cgIsTechniqueValidated(technique))
continue;
CGpass pass = cgGetFirstPass(technique);
for(; pass; pass = cgiGetNextPass(pass))
{
for(int i = 0; i < numDomains; ++i)
{
CGprogram prog = cgGetPassProgram(pass, domains[i]);
if(!prog)
continue;
CGparameter param = cgGetNamedParameter(prog, "paramName");
CGbool isUsed = cgIsParameterUsed(param, prog);
if(isUsed == CG_FALSE)
continue;
int idx = cgGetParameterBufferIndex(param);
if(idx < 0)
continue;
cgSetProgramBuffer(prog, idx, myCgBuffer);
}
}
}
Examples
cgSetEffectParameterBuffer(cgGetNamedEffectParameter(myCgEffect, "paramName"), myCgBuffer);
See examples/OpenGL/advanced/cgfx_buffer_lighting.
Errors
CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter.
History
cgSetEffectParameterBuffer was introduced in Cg 3.0.
See Also
cgGetEffectParameterBuffer,
cgSetProgramBuffer
|