cgSetAutoCompile
Keywords: cgSetAutoCompile, NVIDIA, NVIDIA Cg Toolkit, Cg Toolkit, Shader, Shader Programming, GPU Shader Programming, GPU Program

> ## Name

> cgSetAutoCompile - sets the auto-compile mode for a context

> ## Synopsis

>     #include <Cg/cg.h>

>     void cgSetAutoCompile( CGcontext context,
>                            CGenum autoCompileMode );

> ## Parameters

> context
>   The context.
> autoCompileMode
>   The auto-compile mode to which to set context. Must be one of the following :
>   - CG_COMPILE_MANUAL
>   - CG_COMPILE_IMMEDIATE
>   - CG_COMPILE_LAZY

> ## Return Values

> None.

> ## Description

> cgSetAutoCompile sets the auto compile mode for a given context. By default, programs are immediately recompiled when they enter an uncompiled state. This may happen for a variety of reasons including :

> - Setting the value of a literal parameter.
> - Resizing arrays.
> - Binding structs to interface parameters.

> autoCompileMode may be one of the following three enumerants :

> CG_COMPILE_IMMEDIATE
>   CG_COMPILE_IMMEDIATE will force recompilation automatically and immediately when a program enters an uncompiled state. This is the default mode.
> CG_COMPILE_MANUAL
>   With this method the application is responsible for manually recompiling a program. It may check to see if a program requires recompilation with the entry point cgIsProgramCompiled. cgCompileProgram can then be used to force compilation.
> CG_COMPILE_LAZY
>   This method is similar to CG_COMPILE_IMMEDIATE but will delay program recompilation until the program object code is needed. The advantage of this method is the reduction of extraneous recompilations. The disadvantage is that compile time errors will not be encountered when the program is enters the uncompiled state but will instead be encountered at some later time.

> ## Examples

> to-be-written

> ## Errors

> CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context.

> CG_INVALID_ENUMERANT_ERROR is generated if autoCompileMode is not CG_COMPILE_MANUAL, CG_COMPILE_IMMEDIATE, or CG_COMPILE_LAZY.

> ## History

> cgSetAutoCompile was introduced in Cg 1.2.

> ## See Also

> cgGetAutoCompile, cgCompileProgram, cgIsProgramCompiled