MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Cg Core Runtime API                                cgCreateObj(3)



NAME
     cgCreateObj - create a cg object type from a shader string

SYNOPSIS
       #include 

       CGobj cgCreateObj( CGcontext context,
                          CGenum programtype,
                          const char * source,
                          CGprofile profile,
                          const char ** args );


PARAMETERS
     context The context to which the new object will be added.

     programtype
             An enumerant describing the contents of the source
             string.  The following enumerants are allowed:

             CGSOURCE
                 source contains Cg source code.

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

     source  A string containing either the programs source or
             object code.  See programtype for more information.

     profile The profile enumerant for the program.

     args    If args is not NUL it is assumed to be an array of
             NUL-terminated strings that will be passed directly
             to the compiler as arguments. The last value of the
             array must be a NUL.

RETURN VALUES
     Returns a  CGobj handle on success.

     Returns NUL if an error occurs.

DESCRIPTION
     cgCreateObj creates a new CGobj which is a source code
     object similar to a .obj or .o in C/C] programming where
     various forms of data can be extracted. This can be used,
     for example, to create user defined data types from a Cg
     source string.

EXAMPLES
      / Imagine a Cg source string that contains:




Cg Toolkit 2.1            Last change:                          1






Cg Core Runtime API                                cgCreateObj(3)



      const char src[] =
       "typedef struct { \n"
       " float3 param1;  \n"
       " half4  param2;  \n"
       "} MyType;";

      / To create a Cg obj:

      CGcontext ctx = cgCreateContext();
      CGobj structObj = cgCreateObj(ctx, CGSOURCE, src, CGPROFILEARBVP1, NUL);

      / Now we can get the CGtype:

      CGtype userDefinedMyType = cgGetNamedUserType(structObj, "MyType");

      / We could also iterate through all the types in the CGobj printing their
      / names like this:

      int numTypes = cgGetNumUserTypes(structObj);
      for (int i=0; i
OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™