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

> ## Name

> cgCreateProgram - create a program object from a string

> ## Synopsis

>     #include <Cg/cg.h>

>     CGprogram cgCreateProgram( CGcontext context,
>                                CGenum program_type,
>                                const char * program,
>                                CGprofile profile,
>                                const char * entry,
>                                const char ** args );

> ## Parameters

> context
>   The context to which the new program will be added.
> program_type
>   An enumerant describing the contents of the program string. The following enumerants are allowed:
>   CG_SOURCE
>     program contains Cg source code.
>   CG_OBJECT
>     program contains object code that resulted from the precompilation of some Cg source code.
> program
>   A string containing either the programs source or object code. See program_type for more information.
> profile
>   The profile enumerant for the program.
> entry
>   The entry point to the program in the Cg source. If NULL, the entry point defaults to "main".
> 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 CGprogram handle on success.

> Returns NULL if an error occurs.

> ## Description

> cgCreateProgram generates a new CGprogram object and adds it to the specified Cg context.

> ## Examples

>     CGcontext context = cgCreateContext();
>     CGprogram program = cgCreateProgram(context,
>                                         CG_SOURCE,
>                                         mysourcestring,
>                                         CG_PROFILE_ARBVP1,
>                                         "myshader",
>                                         NULL);

> ## Errors

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

> CG_INVALID_ENUMERANT_ERROR is generated if program_type is not CG_SOURCE or CG_OBJECT.

> CG_UNKNOWN_PROFILE_ERROR is generated if profile is not a supported profile.

> CG_COMPILER_ERROR is generated if compilation fails.

> ## History

> cgCreateProgram was introduced in Cg 1.1.

> ## See Also

> cgCreateContext, cgCreateProgramFromFile, cgDestroyProgram, cgGetProgramString