> ## Name

> cgCreateStateAssignment - create a state assignment

> ## Synopsis

>     #include <Cg/cg.h>

>     CGstateassignment cgCreateStateAssignment( CGpass pass,
>                                                CGstate state );

> ## Parameters

> pass
>   The pass in which to create the state assignment.
> state
>   The state used to create the state assignment.

> ## Return Values

> Returns the handle to the created state assignment.

> Returns NULL if an error occurs.

> ## Description

> cgCreateStateAssignment creates a state assignment for the specified pass. The new state assignment is appended to the pass' existing list of state assignments. If the state is actually a state array, the created state assignment is created for array index zero. Use cgCreateStateAssignmentIndex to create state assignments for other indices of an array state.

> ## Examples

>     /* Procedurally create state assignment equivalent to */
>     /* "BlendFunc = { SrcAlpha, OneMinusSrcAlpha };"  */
>     CGstate blendFuncState = cgGetNamedState(context, "BlendFunc");
>     CGstateassignment blendFuncSA =
>         cgCreateStateAssignment(pass, blendFuncState);
>     static const int blendFuncConfig[2] =
>         { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA };
>     cgSetIntArrayStateAssignment(blendFuncSA, blendFuncConfig);

>     /* Procedurally create state assignment equivalent to */
>     /* "BlendEnable = true;" */
>     CGstate blendEnableState =
>         cgGetNamedState(context, "BlendEnable");
>     CGstateassignment blendEnableSA =
>         cgCreateStateAssignment(pass, blendEnableState);
>     cgSetBoolStateAssignment(blendEnableSA, CG_TRUE);

> ## Errors

> CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass.

> CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state.

> ## History

> cgCreateStateAssignment was introduced in Cg 1.5.

> ## See Also

> cgCreateTechnique, cgCreateSamplerStateAssignment, cgCreateState, cgCreateStateAssignmentIndex