NAME

cgCreateEffect - generate a new effect object from a string

SYNOPSIS

  #include <Cg/cg.h>

  CGeffect cgCreateEffect(CGcontext ctx, 
                          const char *effect,
                          const char **args)

PARAMETERS

ctx

Specifies the context that the new effect will be added to.

effect

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 as directly to the compiler as arguments. The last value of the array must be a NULL.

DESCRIPTION

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

The following is a typical sequence of commands for initializing a new effect:

   char *effectSource = ...;
   CGcontext ctx = cgCreateContext();
   CGeffect eff  = cgCreateEffect(ctx,
                                  effectSource,
                                  NULL);

RETURN VALUES

Returns a CGeffect handle on success.

Returns NULL if any error occurs. the "cgGetLastListing" document can be called to retrieve any warning or error messages from the compilation process.

ERRORS

CG_INVALID_CONTEXT_HANDLE_ERROR is generated if the ctx is not a valid context.

CG_COMPILER_ERROR is generated if the compile failed.

SEE ALSO

the "cgCreateContext" document, the "cgCreateEffectFromFile" document, and the "cgGetLastListing" document