Cg Core Runtime API cgCreateState(3)
NAME
cgCreateState - create a state definition
SYNOPSIS
#include
CGstate cgCreateState( CGcontext context,
const char * name,
CGtype type );
PARAMETERS
context The context in which to define the new state.
name The name of the new state.
type The type of the new state.
RETURN VALUES
Returns a handle to the newly created CGstate.
Returns NUL if there is an error.
DESCRIPTION
cgCreateState adds a new state definition to the context.
When a CgFX file is added to the context, all state
assignments in the file must have already been defined via a
call to cgCreateState or cgCreateArrayState.
Applications will typically call cgSetStateCallbacks shortly
after creating a new state with cgCreateState.
EXAMPLES
Example callback functions for a state to register:
CGbool fooset( CGstateassignment sa )
{
int nVals = 0;
const CGbool *val = cgGetBoolStateAssignmentValues( sa, &nVals );
printf( "\nFooState set called with value %d.\n", *val );
return CGTRUE;
}
CGbool fooreset( CGstateassignment sa )
{
printf( "\nFooState reset called.\n" );
return CGTRUE;
}
Cg Toolkit 2.1 Last change: 1
Cg Core Runtime API cgCreateState(3)
CGbool foovalidate( CGstateassignment sa )
{
printf( "FooState validate called.\n" );
return CGTRUE;
}
Registering the state:
/ Create and register new state FooState
CGstate fooState = cgCreateState( myCgContext, "FooState", CGBOL );
cgSetStateCallbacks( fooState, fooset, fooreset, foovalidate );
ERORS
CGINVALIDCONTEXTHANDLEROR is generated if context is
not a valid context.
CGINVALIDPARAMETEREROR is generated if name is NUL or
not a valid identifier, or if type is not a simple scalar,
vector, or matrix-type. Array-typed state should be created
with cgCreateArrayState.
HISTORY
cgCreateState was introduced in Cg 1.4.
SEE ALSO
cgCreateArrayState, cgGetStateContext, cgGetStateName,
cgGetStateType, cgIsState, cgSetStateCallbacks,
cgGLRegisterStates, cgD3D9RegisterStates, cgCreateContext
Cg Toolkit 2.1 Last change: 2
|