Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Runtime / Cg / cgGetDependentProgramArrayStateAssignmentParameter

Name

cgGetDependentProgramArrayStateAssignmentParameter - get one of the parameters that a state assignment's value depends on

Synopsis

#include <Cg/cg.h>

CGparameter cgGetDependentProgramArrayStateAssignmentParameter( CGstateassignment sa,
                                                                int index );

Parameters

sa
The state assignment handle.
index
The index of the parameter to return.

Return Values

Returns a handle to the selected dependent parameter on success.

Returns NULL if sa is not a program state assignment or an error occurs.

Description

State assignments in CgFX files may include references to an array indexed by an effect parameter (or expression) on the right hand side of the state assignment that is used for computing the state assignment's value. Usually this array holds the compile statements of shader programs and by changing the index of the shader array, it's possible to switch to a different program or profile on-the-fly.

Each compile statement in the array can depend on one or more effect parameters which are passed to the program in its parameter list. It is sometimes necessary for the application to query what those parameters are so values can be properly set to them.

cgGetDependentProgramArrayStateAssignmentParameter returns one of these parameters, as indicated by the given index.

Examples

In CgFX file:

vertexshader Torus[4] =
{
  compile vp40   C8E6v_torus( LightPosition, EyePosition, ModelViewProj,
                              float2( OuterRadius, InnerRadius ) ),

  compile vp30   C8E6v_torus( LightPosition, EyePosition, ModelViewProj,
                              float2( OuterRadius, InnerRadius ) ),

  compile arbvp1 C8E6v_torus( LightPosition, EyePosition, ModelViewProj,
                              float2( OuterRadius, InnerRadius ) ),

  compile vp20   C8E6v_torus( LightPosition, EyePosition, ModelViewProj,
                              float2( OuterRadius, InnerRadius ) )
};

pixelshader SpecSurf[4] =
{
  compile fp40   C8E4f_specSurf( Ambient, float4(DiffuseMaterial  * LightColor, 1),
                                 float4(SpecularMaterial * LightColor, 1),
                                 normalMap, normalizeCube, normalizeCube ),

  compile fp30   C8E4f_specSurf( Ambient, float4(DiffuseMaterial  * LightColor, 1),
                                 float4(SpecularMaterial * LightColor, 1),
                                 normalMap, normalizeCube, normalizeCube ),

  compile arbfp1 C8E4f_specSurf( Ambient, float4(DiffuseMaterial  * LightColor, 1),
                                 float4(SpecularMaterial * LightColor, 1),
                                 normalMap, normalizeCube, normalizeCube ),

  compile fp20   C8E4f_specSurf( Ambient, float4(DiffuseMaterial  * LightColor, 1),
                                 float4(SpecularMaterial * LightColor, 1),
                                 normalMap, normalizeCube, normalizeCube )
};

int select = 0;

technique bumpdemo
{
    pass
    {
        VertexProgram   = (Torus[select]);
        FragmentProgram = (SpecSurf[select]);
    }
}

In application:

int numParameters = cgGetNumDependentProgramArrayStateAssignmentParameters(stateAssignment);
for(int i = 0; i < numParameters; ++i) {
    CGparameter param = cgGetDependentProgramArrayStateAssignmentParameter(stateAssignment, i);

    /* Set value for 'param' */
}

In the above example, assuming select = 0 and stateAssignment is for VertexProgram, the list of parameters returned from cgGetDependentProgramArrayStateAssignmentParameter would be: LightPosition, EyePosition, ModelViewProj, OuterRadius, InnerRadius.

If stateAssignment was for FragmentProgram, then the list of parameters returned from cgGetDependentProgramArrayStateAssignmentParameter would be: Ambient, DiffuseMaterial, LightColor, SpecularMaterial, LightColor, normalMap, normalizeCube, normalizeCube.

Errors

CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment.

CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is less than zero or greater than or equal to the number of dependent parameters, as returned by cgGetNumDependentProgramArrayStateAssignmentParameters.

History

cgGetDependentProgramArrayStateAssignmentParameter was introduced in Cg 3.0.

See Also

cgGetNumDependentProgramArrayStateAssignmentParameters


Cg Toolkit | Cg Toolkit | Download | Release Archive | Profiles | Reference | Books | Discussions |


Cg Runtime Cg

cgAddStateEnumerant
cgCallStateResetCallback
cgCallStateSetCallback
cgCallStateValidateCallback
cgCombinePrograms2
cgCombinePrograms3
cgCombinePrograms4
cgCombinePrograms5
cgCombinePrograms
cgCompileProgram
cgConnectParameter
cgCopyEffect
cgCopyProgram
cgCreateArraySamplerState
cgCreateArrayState
cgCreateBuffer
cgCreateContext
cgCreateEffectAnnotation
cgCreateEffectFromFile
cgCreateEffectParameterArray
cgCreateEffectParameterMultiDimArray
cgCreateEffectParameter
cgCreateEffect
cgCreateObjFromFile
cgCreateObj
cgCreateParameterAnnotation
cgCreateParameterArray
cgCreateParameterMultiDimArray
cgCreateParameter
cgCreatePassAnnotation
cgCreatePass
cgCreateProgramAnnotation
cgCreateProgramFromEffect
cgCreateProgramFromFile
cgCreateProgram
cgCreateSamplerStateAssignment
cgCreateSamplerState
cgCreateStateAssignmentIndex
cgCreateStateAssignment
cgCreateState
cgCreateTechniqueAnnotation
cgCreateTechnique
cgDestroyBuffer
cgDestroyContext
cgDestroyEffect
cgDestroyObj
cgDestroyParameter
cgDestroyProgram
cgDisconnectParameter
cgEvaluateProgram
cgGetAnnotationName
cgGetAnnotationType
cgGetArrayDimension
cgGetArrayParameter
cgGetArraySize
cgGetArrayTotalSize
cgGetArrayType
cgGetAutoCompile
cgGetBehavior
cgGetBehaviorString
cgGetBoolAnnotationValues
cgGetBooleanAnnotationValues
cgGetBoolStateAssignmentValues
cgGetBufferSize
cgGetCompilerIncludeCallback
cgGetConnectedParameter
cgGetConnectedStateAssignmentParameter
cgGetConnectedToParameter
cgGetContextBehavior
cgGetDependentAnnotationParameter
cgGetDependentProgramArrayStateAssignmentParameter
cgGetDependentStateAssignmentParameter
cgGetDomain
cgGetDomainString
cgGetEffectContext
cgGetEffectName
cgGetEffectParameterBuffer
cgGetEffectParameterBySemantic
cgGetEnum
cgGetEnumString
cgGetErrorCallback
cgGetErrorHandler
cgGetError
cgGetErrorString
cgGetFirstDependentParameter
cgGetFirstEffectAnnotation
cgGetFirstEffectParameter
cgGetFirstEffect
cgGetFirstError
cgGetFirstLeafEffectParameter
cgGetFirstLeafParameter
cgGetFirstParameterAnnotation
cgGetFirstParameter
cgGetFirstPassAnnotation
cgGetFirstPass
cgGetFirstProgramAnnotation
cgGetFirstProgram
cgGetFirstSamplerStateAssignment
cgGetFirstSamplerState
cgGetFirstStateAssignment
cgGetFirstState
cgGetFirstStructParameter
cgGetFirstTechniqueAnnotation
cgGetFirstTechnique
cgGetFirstUniformBufferParameter
cgGetFloatAnnotationValues
cgGetFloatStateAssignmentValues
cgGetIntAnnotationValues
cgGetIntStateAssignmentValues
cgGetLastErrorString
cgGetLastListing
cgGetLockingPolicy
cgGetMatrixParameterdc
cgGetMatrixParameterdr
cgGetMatrixParameterfc
cgGetMatrixParameterfr
cgGetMatrixParameteric
cgGetMatrixParameterir
cgGetMatrixParameterOrder
cgGetMatrixParameter
cgGetMatrixSize
cgGetNamedEffectAnnotation
cgGetNamedEffectParameter
cgGetNamedEffect
cgGetNamedEffectUniformBuffer
cgGetNamedParameterAnnotation
cgGetNamedParameter
cgGetNamedPassAnnotation
cgGetNamedPass
cgGetNamedProgramAnnotation
cgGetNamedProgramParameter
cgGetNamedProgramUniformBuffer
cgGetNamedSamplerStateAssignment
cgGetNamedSamplerState
cgGetNamedStateAssignment
cgGetNamedState
cgGetNamedStructParameter
cgGetNamedSubParameter
cgGetNamedTechniqueAnnotation
cgGetNamedTechnique
cgGetNamedUniformBufferParameter
cgGetNamedUserType
cgGetNextAnnotation
cgGetNextEffect
cgGetNextLeafParameter
cgGetNextParameter
cgGetNextPass
cgGetNextProgram
cgGetNextStateAssignment
cgGetNextState
cgGetNextTechnique
cgGetNumConnectedToParameters
cgGetNumDependentAnnotationParameters
cgGetNumDependentProgramArrayStateAssignmentParameters
cgGetNumDependentStateAssignmentParameters
cgGetNumParentTypes
cgGetNumProgramDomains
cgGetNumStateEnumerants
cgGetNumSupportedProfiles
cgGetNumUserTypes
cgGetParameterBaseResource
cgGetParameterBaseType
cgGetParameterBufferIndex
cgGetParameterBufferOffset
cgGetParameterClassEnum
cgGetParameterClass
cgGetParameterClassString
cgGetParameterColumns
cgGetParameterContext
cgGetParameterDefaultValuedc
cgGetParameterDefaultValuedr
cgGetParameterDefaultValuefc
cgGetParameterDefaultValuefr
cgGetParameterDefaultValueic
cgGetParameterDefaultValueir
cgGetParameterDefaultValue
cgGetParameterDirection
cgGetParameterEffect
cgGetParameterIndex
cgGetParameterNamedType
cgGetParameterName
cgGetParameterOrdinalNumber
cgGetParameterProgram
cgGetParameterResourceIndex
cgGetParameterResourceName
cgGetParameterResource
cgGetParameterResourceSize
cgGetParameterResourceType
cgGetParameterRows
cgGetParameterSemantic
cgGetParameterSettingMode
cgGetParameterType
cgGetParameterValuedc
cgGetParameterValuedr
cgGetParameterValuefc
cgGetParameterValuefr
cgGetParameterValueic
cgGetParameterValueir
cgGetParameterValue
cgGetParameterValues
cgGetParameterVariability
cgGetParentType
cgGetPassName
cgGetPassProgram
cgGetPassTechnique
cgGetProfileDomain
cgGetProfile
cgGetProfileProperty
cgGetProfileSibling
cgGetProfileString
cgGetProgramBufferMaxIndex
cgGetProgramBufferMaxSize
cgGetProgramBuffer
cgGetProgramContext
cgGetProgramDomain
cgGetProgramDomainProfile
cgGetProgramDomainProgram
cgGetProgramInput
cgGetProgramOptions
cgGetProgramOutput
cgGetProgramOutputVertices
cgGetProgramProfile
cgGetProgramStateAssignmentValue
cgGetProgramString
cgGetResource
cgGetResourceString
cgGetSamplerStateAssignmentParameter
cgGetSamplerStateAssignmentState
cgGetSamplerStateAssignmentValue
cgGetSemanticCasePolicy
cgGetStateAssignmentIndex
cgGetStateAssignmentPass
cgGetStateAssignmentState
cgGetStateContext
cgGetStateEnumerantName
cgGetStateEnumerant
cgGetStateEnumerantValue
cgGetStateLatestProfile
cgGetStateName
cgGetStateResetCallback
cgGetStateSetCallback
cgGetStateType
cgGetStateValidateCallback
cgGetStringAnnotationValue
cgGetStringAnnotationValues
cgGetStringParameterValue
cgGetString
cgGetStringStateAssignmentValue
cgGetSupportedProfile
cgGetTechniqueEffect
cgGetTechniqueName
cgGetTextureStateAssignmentValue
cgGetTypeBase
cgGetTypeClass
cgGetType
cgGetTypeSizes
cgGetTypeString
cgGetUniformBufferBlockName
cgGetUniformBufferParameter
cgGetUserType
cgIsAnnotation
cgIsBuffer
cgIsContext
cgIsEffect
cgIsInterfaceType
cgIsParameterGlobal
cgIsParameter
cgIsParameterReferenced
cgIsParameterUsed
cgIsParentType
cgIsPass
cgIsProfileSupported
cgIsProgramCompiled
cgIsProgram
cgIsStateAssignment
cgIsState
cgIsTechnique
cgIsTechniqueValidated
cgMapBuffer
cgResetPassState
cgSetArraySize
cgSetAutoCompile
cgSetBoolAnnotation
cgSetBoolArrayStateAssignment
cgSetBoolStateAssignment
cgSetBufferData
cgSetBufferSubData
cgSetCompilerIncludeCallback
cgSetCompilerIncludeFile
cgSetCompilerIncludeString
cgSetContextBehavior
cgSetEffectName
cgSetEffectParameterBuffer
cgSetErrorCallback
cgSetErrorHandler
cgSetFloatAnnotation
cgSetFloatArrayStateAssignment
cgSetFloatStateAssignment
cgSetIntAnnotation
cgSetIntArrayStateAssignment
cgSetIntStateAssignment
cgSetLastListing
cgSetLockingPolicy
cgSetMatrixParameterdc
cgSetMatrixParameterdr
cgSetMatrixParameterfc
cgSetMatrixParameterfr
cgSetMatrixParameteric
cgSetMatrixParameterir
cgSetMatrixParameter
cgSetMultiDimArraySize
cgSetParameter1d
cgSetParameter1dv
cgSetParameter1f
cgSetParameter1fv
cgSetParameter1i
cgSetParameter1iv
cgSetParameter2d
cgSetParameter2dv
cgSetParameter2f
cgSetParameter2fv
cgSetParameter2i
cgSetParameter2iv
cgSetParameter3d
cgSetParameter3dv
cgSetParameter3f
cgSetParameter3fv
cgSetParameter3i
cgSetParameter3iv
cgSetParameter4d
cgSetParameter4dv
cgSetParameter4f
cgSetParameter4fv
cgSetParameter4i
cgSetParameter4iv
cgSetParameter
cgSetParameterSemantic
cgSetParameterSettingMode
cgSetParameterValuedc
cgSetParameterValuedr
cgSetParameterValuefc
cgSetParameterValuefr
cgSetParameterValueic
cgSetParameterValueir
cgSetParameterValue
cgSetParameterVariability
cgSetPassProgramParameters
cgSetPassState
cgSetProgramBuffer
cgSetProgramOutputVertices
cgSetProgramProfile
cgSetProgramStateAssignment
cgSetSamplerStateAssignment
cgSetSamplerState
cgSetSemanticCasePolicy
cgSetStateCallbacks
cgSetStateLatestProfile
cgSetStringAnnotation
cgSetStringParameterValue
cgSetStringStateAssignment
cgSetTextureStateAssignment
cgSetUniformBufferParameter
cgUnmapBuffer
cgUpdatePassParameters
cgUpdateProgramParameters
cgValidateTechnique