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

> ## Name

> cgCreateEffect - create an effect object from a source string

> ## Synopsis

>     #include <Cg/cg.h>

>     CGeffect cgCreateEffect( CGcontext context,
>                              const char * source,
>                              const char ** args );

> ## Parameters

> context
>   The context to which the new effect will be added.
> source
>   A string containing the effect's source code.
> args
>   If args is not NULL it is assumed to be an array of null-terminated strings that will be passed directly to the compiler as arguments. The last value of the array must be a NULL.

> ## Return Values

> Returns a CGeffect handle on success.

> Returns NULL if an error occurs.

> ## Description

> cgCreateEffect generates a new CGeffect object and adds it to the specified Cg context.

> If an error occurs cgGetLastListing can be called to retrieve any warning or error messages from the compilation process.

> ## Examples

> Creating an effect:

>     char *effectSource = ...;
>     CGcontext context = cgCreateContext();
>     CGeffect effect  = cgCreateEffect(context,
>                                       effectSource,
>                                       NULL);

> Iterating through the techniques in an effect:

>     CGtechnique technique = cgGetFirstTechnique(effect);
>     while (technique) {
>       // Do something with each technique
>       technique = cgGetNextTechnique(technique);
>     }

> ## Errors

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

> CG_COMPILER_ERROR is generated if compilation fails.

> ## History

> cgCreateEffect was introduced in Cg 1.4.

> ## See Also

> cgCreateContext, cgCreateEffectFromFile, cgGetLastListing, cgGetFirstTechnique, cgGetTechniqueEffect, cgGetFirstEffect