Name

cgGetUniformBufferBlockName - get block name from a uniform buffer parameter

Synopsis

#include <Cg/cg.h>

const char * cgGetUniformBufferBlockName( CGparameter param );

Parameters

param
The uniform buffer parameter.

Return Values

Returns the null-terminated block name string for the uniform buffer parameter.

Returns NULL if an error occurs.

Description

cgGetUniformBufferBlockName allows the application to retrieve the block name of a uniform buffer parameter in a Cg program. This name can be used later to retrieve the parameter from the program or effect using cgGetNamedProgramUniformBuffer or cgGetNamedEffectUniformBuffer.

Declarations of uniform buffers have the form:

uniform mustHaveBlockName {
...  content
} optionalParameterName  : BUFFER;

The block name is required while the parameter name is optional. This means that for anonymous uniform buffers (i.e., those without a parameter name) the app cannot retrieve the parameter handle using cgGetNamedParameter. Since the block name is required, however, cgGetUniformBufferBlockName can always be used to retrieve the parameter handle for the uniform block.

Examples

If the file buf.cg contains this shader:

uniform myBuf {
  float4 var;
} a : BUFFER;

float4 vertex() : POSITION
{
  return float4(a.var.r, a.var.g, a.var.b, 1.0);
}

and if program refers to the CGprogram created from buf.cg, then the call sequence:

CGparameter param = cgGetNamedParameter(program, "a");
const char * BlockName = cgGetUniformBufferBlockName(param);

results in BlockName pointing at the character string "myBuf"

Errors

CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter.

CG_INVALID_PARAMETER_TYPE_ERROR is generated if param is not a uniform buffer parameter.

History

cgGetUniformBufferBlockName was introduced in Cg 3.1.

See Also

cgGetNamedParameter, cgGetNamedProgramUniformBuffer, cgGetNamedEffectUniformBuffer