NAME

cgCreateProgramFromFile - create a program object from a file

SYNOPSIS

  #include <Cg/cg.h>

  CGprogram cgCreateProgramFromFile( CGcontext context, 
                                     CGenum program_type,
                                     const char * program_file,
                                     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_file. The following enumerants are allowed:

CG_SOURCE

program_file contains Cg source code.

CG_OBJECT

program_file contains object code that resulted from the precompilation of some Cg source code.

program_file

Name of a file that contains 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 set to NULL this will default to "main".

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.

RETURN VALUES

Returns a CGprogram handle on success.

Returns NULL if any error occurs.

DESCRIPTION

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

EXAMPLES

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

   CGcontext context = cgCreateContext();
   CGprogram program = cgCreateProgramFromFile(context,
                                               CG_SOURCE,
                                               mysourcefilename,
                                               CG_PROFILE_ARBVP1,
                                               "myshader",
                                               NULL);

ERRORS

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

CG_INVALID_ENUMERANT_ERROR is generated if program_type is an invalid enumerant.

CG_UNKNOWN_PROFILE_ERROR is generated if profile is not a supported profile.

CG_COMPILE_ERROR is generated if the compile failed.

HISTORY

cgCreateProgramFromFile was introduced in Cg 1.1.

SEE ALSO

cgCreateContext, cgGetProgramString