Cg Reference Manual
User Manual:
Open the PDF directly: View PDF .
Page Count: 1159
Download | ![]() |
Open PDF In Browser | View PDF |
CG(Cg) Cg Topics CG(Cg) NAME Cg − A multi-platform, multi-API C−based programming language for GPUs DESCRIPTION Cg is a high-level programming language designed to compile to the instruction sets of the programmable portions of GPUs. While Cg programs have great flexibility in the way that they express the computations they perform, the inputs, outputs, and basic resources available to those programs are dictated by where they execute in the graphics pipeline. Other documents describe how to write Cg programs. This document describes the library that application programs use to interact with Cg programs. This library and its associated API is referred to as the Cg runtime. DOCUMENTATION ORGANIZATION Cg Topics Cg Language Specification Cg Commands Cg Core Runtime API Cg OpenGL Runtime API Cg Direct3D11 Runtime API Cg Direct3D10 Runtime API Cg Direct3D9 Runtime API Cg Direct3D8 Runtime API Cg Profiles Cg Standard Libary Routines CgFX States CgFX Sampler States SEE ALSO Cg_language, cgc, cgCreateContext, cgDestroyContext perl v5.10.0 Cg Toolkit 3.0 1 CG1_2_RUNTIME_CHANGES(Cg) Cg Topics CG1_2_RUNTIME_CHANGES(Cg) Cg 1.2 RUNTIME API ADDITIONS Version 1.2 of the Cg runtime adds a number of new capabilities to the existing set of functionality from previous releases. These new features include functionality that make it possible to write programs that can run more efficiently on the GPU, techniques that help hide some of the inherent limitations of some Cg profiles on the GPU, and entrypoints that support new language functionality in the Cg 1.2 release. Parameter Literalization The 1.2 Cg runtime makes it possible to denote some of the parameters to a program as having a fixed constant value. This feature can lead to substantially more efficient programs in a number of cases. For example, a program might have a block of code that implements functionality that is only used some of the time: float4 main(uniform float enableDazzle, ...) : COLOR { if (enableDazzle) { // do lengthy computation } else { // do basic computation } } Some hardware profiles don’t directly support branching (this includes all of the fragment program profiles supported in this release), and have to handle code like the program by effectively following both sides of the if() test. (They still compute the correct result in the end, just not very efficiently.) However, if the ‘‘enableDazzle’’ parameter is marked as a literal parameter and a value is provided for it, the compiler can generate an optimized version of the program with the knowledge of ‘‘enableDazzle’’’s value, just generating GPU code for one of the two cases. This can lead to substantial performance improvments. This feature also makes it easier to write general purpose shaders with a wide variety of supported functionality, while only paying the runtime cost for the functionality provided. This feature is also useful for parameters with numeric values. For example, consider a shader that implements a diffuse reflection model: float4 main(uniform float3 lightPos, uniform float3 lightColor, uniform float3 Kd, float3 pos : TEXCOORD0, float3 normal : TEXCOORD1) : COLOR { return Kd*lightColor*max(0., dot(normalize(lightPos−pos), normal)); } If the ‘‘lightColor’’ and ‘‘Kd’’ parameters are set to literals, it is possible for the compiler to compute the product ‘‘Kd * lightColor’’ once, rather than once each time the program executes. Given a parameter handle, the cgSetParameterVariability() entrypoint sets the variability of a parameter: void cgSetParameterVariability(CGparameter param, CGenum vary); To set it to a literal parameter, the CG_LITERAL enumerant should be passed as the second parameter. After a parameter has set to be a literal, the following routines should be used to set the parameter’s value. perl v5.10.0 Cg Toolkit 3.0 2 CG1_2_RUNTIME_CHANGES(Cg) void void void void void void void void Cg Topics cgSetParameter1f(CGparameter cgSetParameter2f(CGparameter cgSetParameter3f(CGparameter cgSetParameter4f(CGparameter float w); cgSetParameter1d(CGparameter cgSetParameter2d(CGparameter cgSetParameter3d(CGparameter cgSetParameter4d(CGparameter double w); CG1_2_RUNTIME_CHANGES(Cg) param, param, param, param, float float float float param, param, param, param, double double double double void void void void void void void void cgSetParameter1fv(CGparameter cgSetParameter2fv(CGparameter cgSetParameter3fv(CGparameter cgSetParameter4fv(CGparameter cgSetParameter1dv(CGparameter cgSetParameter2dv(CGparameter cgSetParameter3dv(CGparameter cgSetParameter4dv(CGparameter param, param, param, param, param, param, param, param, void void void void cgSetMatrixParameterdr(CGparameter cgSetMatrixParameterfr(CGparameter cgSetMatrixParameterdc(CGparameter cgSetMatrixParameterfc(CGparameter x); x, float y); x, float y, float z); x, float y, float z, const const const const const const const const x); x, double y); x, double y, double z); x, double y, double z, param, param, param, param, float *v); float *v); float *v); float *v); double *v); double *v); double *v); double *v); const const const const double *matrix); float *matrix); double *matrix); float *matrix); After a parameter has been set to be a literal, or after the value of a literal parameter has been changed, the program must be compiled and loaded into the GPU, regardless of whether it had already been compiled. This issue is discussed further in the section on program recompilation below. Array Size Specification The Cg 1.2 language also adds support for ‘‘unsized array’’ variables; programs can be written to take parameters that are arrays with an indeterminate size. The actual size of these arrays is then set via the Cg runtime. This feature is useful for writing general-purpose shaders with a minimal performance penalty. For example, consider a shader that computes shading given some number of light sources. If the information about each light source is stored in a struct LightInfo, the shader might be written as: float4 main(LightInfo lights[], ...) : COLOR { float4 color = float4(0,0,0,1); for (i = 0; i < lights.length; ++i) { // add lights[i]'s contribution to color } return color; } The runtime can then be used to set the length of the lights[] array (and then to initialize the values of the LightInfo structures.) As with literal parameters, the program must be recompiled and reloaded after a parameter’s array size is set or changes. These two entrypoints set the size of an unsized array parameter referenced by the given parameter handle. To set the size of a multidimensional unsized array, all of the dimensions’ sizes must be set simultaneously, by providing them all via the pointer to an array of integer values. void cgSetArraySize(CGparameter param, int size); void cgSetMultiDimArraySize(CGparameter param, const int *sizes); XXX what happens if these are called with an already-sized array?? XXX perl v5.10.0 Cg Toolkit 3.0 3 CG1_2_RUNTIME_CHANGES(Cg) Cg Topics CG1_2_RUNTIME_CHANGES(Cg) To get the size of an array parameter, the cgGetArraySize() entrypoint can be used. int cgGetArraySize(CGparameter param, int dimension); Program Recompilation at Runtime The Cg 1.2 runtime environment will allow automatic and manual recompilation of programs. This functionality is useful for multiple reasons : • Changing variability of parameters Parameters may be changed from uniform variability to literal variability as described above. • Changing value of literal parameters Changing the value of a literal parameter will require recompilation since the value is used at compile time. • Resizing parameter arrays Changing the length of a parameter array may require recompilation depending on the capabilities of the profile of the program. • Binding sub-shader parameters Sub-shader parameters are structures that overload methods that need to be provided at compile time; they are described below. Binding such parameters to program parameters will require recompilation. See ‘‘Sub-Shaders’’ for more information. Recompilation can be executed manually by the application using the runtime or automatically by the runtime. The entry point: void cgCompileProgram(CGprogram program); causes the given program to be recompiled, and the function: CGbool cgIsProgramCompiled(CGprogram program); reurns a boolean value indicating whether the current program needs recompilation. By default, programs are automatically compiled when cgCreateProgram() or cgCreateProgramFromFile() is called. This behavior can be controled with the entry point : void cgSetAutoCompile(CGcontext ctx, CGenum flag); Where flag is one of the following three enumerants : • CG_COMPILE_MANUAL With this method the application is responsible for manually recompiling a program. It may check to see if a program requires recompilation with the entry point cgIsProgramCompiled(). cgCompileProgram() can then be used to force compilation. • CG_COMPILE_IMMEDIATE CG_COMPILE_IMMEDIATE will force recompilation automatically and immediately when a program enters an uncompiled state. • CG_COMPILE_LAZY This method is similar to CG_COMPILE_IMMEDIATE but will delay program recompilation until the program object code is needed. The advantage of this method is the reduction of extraneous recompilations. The disadvantage is that compile time errors will not be encountered when the program is enters the uncompiled state but will instead be encountered at some later time. For programs that use features like unsized arrays that can not be compiled until their array sizes are set, it is good practice to change the default behavior of compilation to CG_COMPILE_MANUAL so that perl v5.10.0 Cg Toolkit 3.0 4 CG1_2_RUNTIME_CHANGES(Cg) Cg Topics CG1_2_RUNTIME_CHANGES(Cg) cgCreateProgram() or cgCreateProgramFromFile() do not unnecessarily encounter and report compilation errors. Shared Parameters (context global parameters) Version 1.2 of the runtime introduces parameters that may be shared across programs in the same context via a new binding mechanism. Once shared parameters are constructed and bound to program parameters, setting the value of the shared parameter will automatically set the value of all of the program parameters they are bound to. Shared parameters belong to a CGcontext instead of a CGprogram. They may be created with the following new entry points : CGparameter cgCreateParameter(CGcontext ctx, CGtype type); CGparameter cgCreateParameterArray(CGcontext ctx, CGtype type, int length); CGparameter cgCreateParameterMultiDimArray(CGcontext ctx, CGtype type, int dim, const int *lengths); They may be deleted with : void cgDestroyParameter(CGparameter param); After a parameter has been created, its value should be set with the cgSetParameter*() routines described in the literalization section above. Once a shared parameter is created it may be associated with any number of program parameters with the call: void cgConnectParameter(CGparameter from, CGparameter to); where ‘‘from’’ is a parameter created with one of the cgCreateParameter() calls, and ‘‘to’’ is a program parameter. Given a program parameter, the handle to the shared parameter that is bound to it (if any) can be found with the call: CGparameter cgGetConnectedParameter(CGparameter param); It returns NULL if no shared parameter has been connected to ‘‘param’’. There are also calls that make it possible to find the set of program parameters to which a given shared parameter has been connected to. The entry point: int cgGetNumConnectedToParameters(CGparameter param); returns the total number of program parameters that ‘‘param’’ has been conencted to, and the entry point: CGparameter cgGetConnectedToParameter(CGparameter param, int index); can be used to get CGparameter handles for each of the program parameters to which a shared parameter is connected. A shared parameter can be unbound from a program parameter with : void cgDisconnectParameter(CGparameter param); The context in which a shared parameter was created can be returned with: CGcontext cgGetParameterContext(CGparameter param); And the entrypoint: CGbool cgIsParameterGlobal(CGparameter param); can be used to determine if a parameter is a shared (global) parameter. perl v5.10.0 Cg Toolkit 3.0 5 CG1_2_RUNTIME_CHANGES(Cg) Cg Topics CG1_2_RUNTIME_CHANGES(Cg) Shader Interface Support From the runtime’s perspective, shader interfaces are simply struct parameters that have a CGtype associated with them. For example, if the following Cg code is included in some program source compiled in the runtime : interface FooInterface { float SomeMethod(float x); } struct FooStruct : FooInterface { float SomeMethod(float x); { return(Scale * x); } float Scale; }; The named types FooInterface and FooStruct will be added to the context. Each one will have a unique CGtype associated with it. The CGtype can be retrieved with : CGtype cgGetNamedUserType(CGprogram program, const char *name); int cgGetNumUserTypes(CGprogram program); CGtype cgGetUserType(CGprogram program, int index); CGbool cgIsParentType(CGtype parent, CGtype child); CGbool cgIsInterfaceType(CGtype type); Once the CGtype has been retrieved, it may be used to construct an instance of the struct using cgCreateParameter(). It may then be bound to a program parameter of the parent type (in the above example this would be FooInterface) using cgBindParameter(). Calling cgGetParameterType() on such a parameter will return the CG_STRUCT to keep backwards compatibility with code that recurses parameter trees. In order to obtain the enumerant of the named type the following entry point should be used : CGtype cgGetParameterNamedType(CGparameter param); The parent types of a given named type may be obtained with the following entry points : int cgGetNumParentTypes(CGtype type); CGtype cgGetParentType(CGtype type, int index); If Cg source modules with differing definitions of named types are added to the same context, an error will be thrown. XXX update for new scoping/context/program local definitions stuff XXX Updated Parameter Management Routines XXX where should these go? Some entrypoints from before have been updated in backwards compatible ways CGparameter cgGetFirstParameter(CGprogram program, CGenum name_space); CGparameter cgGetFirstLeafParameter(CGprogram program, CGenum name_space); like cgGetNamedParameter, but limits search to the given name_space (CG_PROGRAM or CG_GLOBAL)... perl v5.10.0 Cg Toolkit 3.0 6 CG1_2_RUNTIME_CHANGES(Cg) Cg Topics CG1_2_RUNTIME_CHANGES(Cg) CGparameter cgGetNamedProgramParameter(CGprogram program, CGenum name_space, const char *name); perl v5.10.0 Cg Toolkit 3.0 7 GLUT(Cg) Cg Topics GLUT(Cg) TOPIC glut − using Cg with the OpenGL Utility Toolkit (GLUT) ABSTRACT GLUT provides a cross-platform window system API for writing OpenGL examples and demos. For this reason, the Cg examples packaged with the Cg Toolkit rely on GLUT. WINDOWS INSTALLATION The Cg Toolkit installer for Windows provides a pre-compiled 32−bit (and 64−bit if selected) versions of GLUT. GLUT is provided both as a Dynamic Link Library (DLL) and a static library. The GLUT DLL is called glut32.dll and requires linking against glut32.lib. These 32−bit versions are typically installed at: c:\Program Files\NVIDIA Corporation\Cg\bin\glut32.dll c:\Program Files\NVIDIA Corporation\Cg\lib\glut32.lib The 64−bit (x64) versions are installed at: c:\Program Files\NVIDIA Corporation\Cg\bin.x64\glut32.dll c:\Program Files\NVIDIA Corporation\Cg\lib.x64\glut32.lib As with any DLL in Windows, if you link your application with the GLUT DLL, running your application requires that glut32.dll can be found when executing GLUT. Alternatively you can link statically with GLUT. This can easily be done by defining the GLUT_STATIC_LIB preprocessor macro before including GLUT’sheader file. This is typically done by adding the −DGLUT_STATIC_LIB option to your compiler command line. When defined, a #pragma in requests the linker link against glutstatic.lib instead of glut32.lib. The 32−bit and 64−bit versions of the GLUT static library are installed at: c:\Program Files\NVIDIA Corporation\Cg\lib\glutstatic.lib c:\Program Files\NVIDIA Corporation\Cg\lib.x64\glutstatic.lib SEE ALSO TBD perl v5.10.0 Cg Toolkit 3.0 8 TRACE(Cg) Cg Topics TRACE(Cg) TOPIC Trace − API Trace for Cg, CgGL, OpenGL and GLUT INTRODUCTION The NVIDIA Cg Toolkit provides trace wrapper libraries for logging API calls to Cg, CgGL, OpenGL and GLUT libraries. The log includes nested function call information and function parameter and return values. The logged data can be useful for debugging, trouble shooting and reporting issues. The libraries are experimental and require some software development expertise. REQUIREMENTS AND LIMITATIONS Trace supports Cg version 2.2.010 (October 2009) and onwards. Cg, CgGL, OpenGL, and GLUT trace libraries are included. CgD3D8, CgD3D9, CgD3D10 and CgD3D10 are not currently supported. Cg and GLUT are supported for OSX, but currently not OpenGL. Trace captures calls and parameters, but not the contents of files referenced by calls such as cgCreateProgramFromFile. Archive the logs, .cg and .cgfx files together into a .zip or .tgz for later reference. BUILDING The trace library source code, makefile and Visual Studio projects are located in the examples/Tools/trace directory of the Cg Toolkit installation. Pre-built binaries are also included. The trace library components are as follows. trace.c traceOutput.c traceFilter.c traceTime.c b64.c traceCg.c traceCgGL.c traceGLUT.c traceGL.c traceGLX.c traceWGL.c } } −−−−> } } } −−−−> −−−−> −−−−> } } −−−−> } trace library Cg wrapper library CgGL wrapper library GLUT wrapper library GL wrapper library DEPLOYMENT ENVIRONMENT VARIABLES The CG_TRACE_FILE and CG_TRACE_ERROR environment variables specify paths to the trace log and error log. The two file names can be the same. Otherwise stdout and stderr are used. The CG_TRACE_CG_LIBRARY and CG_TRACE_CGGL_LIBRARY environment variables specify the path of the target Cg and CgGL libraries. The CG_TRACE_GL_LIBRARY environment variable specifies the path of the target OpenGL library. The CG_TRACE_GLUT_LIBRARY environment variable specifies the path of the target OpenGL library. Otherwise, default system locations are used. The CG_TRACE_BLOB_LIMIT environment variable limits the size of raw data logged. Just the pointer value is stored for parameters that exceed the limit. This variable is typically set to avoid capturing texture image data. By default there is no limit and all parameter data is logged. The CG_TRACE_TIMESTAMP environment variable specifies timestamp logging for each call. Any nonzero integer value enables timestamp tracing. By default timestamp logging is disabled. perl v5.10.0 Cg Toolkit 3.0 9 TRACE(Cg) Cg Topics TRACE(Cg) Recommended settings: CG_TRACE_FILE traceLog.txt CG_TRACE_ERROR traceError.txt WINDOWS Select a trace directory to copy the trace libraries to. This can be the same as the application directory. The directory of the target .exe is recommended. Copy trace.dll to the trace directory. The API-specific trace libraries depend on trace.dll. The other trace libraries are optional. Optionally copy trace cg.dll and cgGL.dll to the trace directory. The CG_BIN_PATH (32−bit) or CG_BIN64_PATH (64−bit) environment variables are used unless CG_TRACE_CG_LIBRARY or CG_TRACE_CGGL_LIBRARY are defined. Optionally copy trace opengl32.dll to the trace directory. Optionally copy trace glut32.dll to the trace directory. LINUX and SOLARIS Set the LD_LIBRARY_PATH environment variable to the directory containing the trace libraries. The APIspecific trace libraries depend on libtrace.so. The other trace libraries are optional. OSX Set the DYLD_LIBRARY_PATH environment variable to the directory containing the trace libraries. These are installed to /Developer/NVIDIA/Cg/examples/Tools/trace by default. The API-specific trace libraries depend on libtrace.dylib. The Cg and GLUT trace frameworks are both optional. The symlinks libCg.dylib and libGLUT.dylib specify the full path of the native frameworks. CREDITS AND LICENCES The core trace library uses the base64 C implementation of Base64 Content-Transfer-Encoding standard (also known as RFC1113) by Bob Trower, Trantor Standard Systems Inc. The Cg trace library uses the uthash C hash table implementation by Troy D. Hanson. perl v5.10.0 Cg Toolkit 3.0 10 WIN64(Cg) Cg Topics WIN64(Cg) TOPIC win64 − using Cg with 64−bit Windows ABSTRACT The Cg Toolkit for Windows installs versions of the Cg compiler and runtime libraries for both 32−bit (x86) and 64−bit (x64) compilation. This topic documents how to use Cg for 64−bit Windows. 64−BIT INSTALLATION The Cg Toolkit installer (CgSetup.exe) installs the 32−bit version of the Cg compiler and the Cg runtime libraries by default. To install the 64−bit support, you must check the component labeled ‘‘Files to run and link 64−bit (x64) Cg-based applications’’ during your installation. If you’ve forgotten to install the 64−bit component, you can re-run the Cg Toolkit installer and check the 64−bit component. EXAMPLES The Cg Toolkit includes Visual Studio .NET 2003 projects intended to compile 64−bit versions of the Cg Toolkit examples. These project files match the pattern *_x64.vcproj The solution files that collect these projects matches the pattern *_x64.sln To use these project files with Visual Studio .NET 2003, you must also install the latest Windows Platform SDK to obtain 64−bit compiler tools and libraries. Once the Platform SDK is installed, from the Start menu navigate to start a Windows shell for the 64−bit Windows Build Environment. This shell is started with the correct environment variables (Path, Include, and Lib) for the 64−bit compiler tools and libraries. Now run devenv.exe with the /useenv command line option that forces Visual Studio to pick up Path, Include, and Lib settings from the shell’s environment. When the Visual Studio IDE appears, select File−>Open−>Project... and locate one of the *_x64.sln files for the Cg examples. These are usually under: c:\Program Files\NVIDIA Corporation\Cg\examples When you open a *_x64.vcproj solution, it references a number of *_x64.vcproj projects. These have a ‘‘Debug x64’’ and ‘‘Release x64’’ configuration to build. HINTS Remember to link with BufferOverflowU.lib because of the /GS option to help detect string overflow runtime errors because Microsoft has enabled this option by default in its 64−bit compilers. See: http://support.microsoft.com/?id=894573 IA64 SUPPORT The Cg Toolkit does not provide 64−bit support for Intel’s Itanium architecture. SEE ALSO TBD perl v5.10.0 Cg Toolkit 3.0 11 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Cg Language Specification Copyright (c) 2001−2011 NVIDIA Corp. This is version 2.0 of the Cg Language specification. This language specification describes version 2.0 of the Cg language Language Overview The Cg language is primarily modeled on ANSI C, but adopts some ideas from modern languages such as C++ and Java, and from earlier shading languages such as RenderMan and the Stanford shading language. The language also introduces a few new ideas. In particular, it includes features designed to represent data flow in stream-processing architectures such as GPUs. Profiles, which are specified at compile time, may subset certain features of the language, including the ability to implement loops and the precision at which certain computations are performed. Like C, Cg is designed primarily as a low-level programming language. Features are provided that map as directly as possible to hardware capabilities. Higher level abstractions are designed primarily to not get in the way of writing code that maps directly to the hardware in the most efficient way possible. The changes in the language from C primarily reflect differences in the way GPU hardware works compared to conventional CPUs. GPUs are designed to run large numbers of small threads of processing in parallel, each running a copy of the same program on a different data set. Differences from ANSI C Cg was developed based on the ANSI-C language with the following major additions, deletions, and changes. (This is a summary-more detail is provided later in this document): Silent Incompatibilities Most of the changes from ANSI C are either omissions or additions, but there are a few potentially silent incompatibilities. These are changes within Cg that could cause a program that compiles without errors to behave in a manner different from C: • The type promotion rules for constants are different when the constant is not explicitly typed using a type cast or type suffix. In general, a binary operation between a constant that is not explicitly typed and a variable is performed at the variable’s precision, rather than at the constant’s default precision. • Declarations of struct perform an automatic typedef (as in C++) and thus could override a previously declared type. • Arrays are first-class types that are distinct from pointers. As a result, array assignments semantically perform a copy operation for the entire array. Similar Operations That Must be Expressed Differently There are several changes that force the same operation to be expressed differently in Cg than in C: • A Boolean type, bool, is introduced, with corresponding implications for operators and control constructs. • Arrays are first-class types because Cg does not support pointers. • Functions pass values by value/result, and thus use an out or inout modifier in the formal parameter list to return a parameter. By default, formal parameters are in, but it is acceptable to specify this explicitly. Parameters can also be specified as in out, which is semantically the same as inout. C features not present in Cg • Language profiles (described in the Profiles section) may subset language capabilities in a variety of ways. In particular, language profiles may restrict the use of for and while loops. For example, some profiles may only support loops that can be fully unrolled at compile time. • Reserved keywords goto, switch, case, and default are not supported, nor are labels. perl v5.10.0 Cg Toolkit 3.0 12 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) • Pointers and pointer-related capabilities, such as the & and −> operators, are not supported. • Arrays are supported, but with some limitations on size and dimensionality. Restrictions on the use of computed subscripts are also permitted. Arrays may be designated as packed. The operations allowed on packed arrays may be different from those allowed on unpacked arrays. Predefined packed types are provided for vectors and matrices. It is strongly recommended that these predefined types be used. • There is no enum or union. • There are no bit-field declarations in structures. • All integral types are implicitly signed, there is no signed keyword. Cg features not present in C • A binding semantic may be associated with a structure tag, a variable, or a structure element to denote that object’s mapping to a specific hardware or API resource. Binding semantics are described in the Binding Semantics section. • There is a built-in swizzle operator: .xyzw or .rgba for vectors. This operator allows the components of a vector to be rearranged and also replicated. It also allows the creation of a vector from a scalar. • For an lvalue, the swizzle operator allows components of a vector or matrix to be selectively written. • There is a similar built-in swizzle operator for matrices: ._m |
[_m |
][...]. This operator allows access to individual matrix components and allows the creation of a vector from elements of a matrix. For compatibility with DirectX 8 notation, there is a second form of matrix swizzle, which is described later. • Numeric data types are different. Cg’s primary numeric data types are float, half, and fixed. Fragment profiles are required to support all three data types, but may choose to implement half and/or fixed at float precision. Vertex profiles are required to support half and float, but may choose to implement half at float precision. Vertex profiles may omit support for fixed operations, but must still support definition of fixed variables. Cg allows profiles to omit run-time support for int and other integer types. Cg allows profiles to treat double as float. • Many operators support per-element vector operations. • The ?:, ||, &&, !, and comparison operators can be used with bool vectors to perform multiple conditional operations simultaneously. The side effects of all operands to vector ?:, ||, and && operators are always executed. • Non-static global variables, and parameters to top-level functions (such as main()) may be designated as uniform. A uniform variable may be read and written within a program, just like any other variable. However, the uniform modifier indicates that the initial value of the variable/parameter is expected to be constant across a large number of invocations of the program. • A new set of sampler* types represents handles to texture sampler units. • Functions may have default values for their parameters, as in C++. These defaults are expressed using assignment syntax. • Function and operator overloading is supported. • Variables may be defined anywhere before they are used, rather than just at the beginning of a scope as in C. (That is, we adopt the C++ rules that govern where variable declarations are allowed.) Variables may not be redeclared within the same scope. • Vector constructors, such as the form float4(1,2,3,4), and matrix constructors may be used anywhere in an expression. • A struct definition automatically performs a corresponding typedef, as in C++. perl v5.10.0 Cg Toolkit 3.0 13 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) • C++−style // comments are allowed in addition to C−style /* ... */ comments. • A limited form of inheritance is supported; interface types may be defined which contain only member functions (no data members) and struct types may inherit from a single interface and provide specific implementations for all the member functions. Interface objects may not be created; a variable of interface type may have any implementing struct type assigned to it. Detailed Language Specification Definitions The following definitions are based on the ANSI C standard: Object An object is a region of data storage in the execution environment, the contents of which can represent values. When referenced, an object may be interpreted as having a particular type. Declaration A declaration specifies the interpretation and attributes of a set of identifiers. Definition A declaration that also causes storage to be reserved for an object or code that will be generated for a function named by an identifier is a definition. Profiles Compilation of a Cg program, a top-level function, always occurs in the context of a compilation profile. The profile specifies whether certain optional language features are supported. These optional language features include certain control constructs and standard library functions. The compilation profile also defines the precision of the float, half, and fixed data types, and specifies whether the fixed and sampler* data types are fully or only partially supported. The profile also specifies the environment in which the program will be run. The choice of a compilation profile is made externally to the language, by using a compiler command-line switch, for example. The profile restrictions are only applied to the top-level function that is being compiled and to any variables or functions that it references, either directly or indirectly. If a function is present in the source code, but not called directly or indirectly by the top-level function, it is free to use capabilities that are not supported by the current profile. The intent of these rules is to allow a single Cg source file to contain many different top-level functions that are targeted at different profiles. The core Cg language specification is sufficiently complete to allow all of these functions to be parsed. The restrictions provided by a compilation profile are only needed for code generation, and are therefore only applied to those functions for which code is being generated. This specification uses the word ‘‘program’’ to refer to the top-level function, any functions the top-level function calls, and any global variables or typedef definitions it references. Each profile must have a separate specification that describes its characteristics and limitations. This core Cg specification requires certain minimum capabilities for all profiles. In some cases, the core specification distinguishes between vertex-program and fragment-program profiles, with different minimum capabilities for each. Declarations and declaration specifiers. A Cg program consists of a series of declarations, each of which declares one or more variables or functions, or declares and defines a single function. Each declaration consists of zero or more declaration specifiers, a type, and one or more declarators. Some of the declaration specifiers are the same as those in ANSI C; others are new to Cg const Marks a variable as a constant that cannot be assigned to within the program. Unless this is combined with uniform or varying, the declarator must include an initializer to give the variable a value. perl v5.10.0 Cg Toolkit 3.0 14 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) extern Marks this declaration as solely a declaration and not a definition. There must be a non−extern declaration elsewhere in the program. in Only usable on parameter and varying declarations. Marks the parameter or varying as an input to the function or program. Function parameters with no in, out, or inout specifier are implicitly in inline Only usable on a function definition. Tells the compiler that it should always inline calls to the function if at all possible. inout Only usable on parameter and varying declarations. Marks the parameter or varying as both an input to and an output from the function or program static Only usable on global variables. Marks the variable as ’private’ to the program, and not visible externally. Cannot be combined with uniform or varying out Only usable on parameter and varying declarations. Marks the parameter or varying as an output from the function or program uniform Only usable on global variables and parameters to the top-level main function of a program. If specified on a non-top-level function parameter it is ignored. The intent of this rule is to allow a function to serve as either a top-level function or as one that is not. Note that uniform variables may be read and written just like non−uniform variables. The uniform qualifier simply provides information about how the initial value of the variable is to be specified and stored, through a mechanism external to the language. varying Only usable on global variables and parameters to the top-level main function of a program. If specified on a non-top-level function parameter it is ignored. profile name The name of any profile (or profile wildcard — see Profiles) may be used as a specifier on any function declaration. It defines a function that is only visible in the corresponding profiles. The specifiers uniform and varying specify how data is transferred between the rest of the world and a Cg program. Typically, the initial value of a uniform variable or parameter is stored in a different class of hardware register for a varying. Furthermore, the external mechanism for specifying the initial value of uniform variables or parameters may be different than that used for specifying the initial value of varying variables or parameters. Parameters qualified as uniform are normally treated as persistent state, while varying parameters are treated as streaming data, with a new value specified for each stream record (such as within a vertex array). Non−static global variables are treated as uniform by default, while parameters to the top-level function are treated as varying by default. Each declaration is visible (‘‘in scope’’) from the point of its declarator until the end of the enclosing block or the end of the compilation unit if outside any block. Declarations in named scopes (such as structs and interfaces) may be visible outside of their scope using explicit scope qualifiers, as in C++. Semantics Each declarator in a declaration may optionally have a semantic specified with it. A semantic specifies how the variable is connected to the environment in which the program runs. All semantics are profile specific (so they have different meanings in different profiles), though there is some attempt to be consistent across profiles. Each profile specification must specify the set of semantics which the profile understands, as well as what behavior occurs for any other unspecified semantics. perl v5.10.0 Cg Toolkit 3.0 15 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Function Declarations Functions are declared essentially as in C. A function that does not return a value must be declared with a void return type. A function that takes no parameters may be declared in one of two ways: As in C, using the void keyword: functionName(void) With no parameters at all: functionName() Functions may be declared as static. If so, they may not be compiled as a program and are not visible externally Function overloading and optional arguments Cg supports function overloading; that is you may define multiple functions with the same name. The function actually called at any given call site is based on the types of the arguments at that call site; the definition that best matches is called. See the function overloading section for the precise rules. Trailing arguments with initializers are optional arguments; defining a function with optional arguments is equivalent to defining multiple overloaded functions that differ by having and not having the optional argument. The value of the initializer is used only for the version that does not have the argument and is ignored if the argument is present. Overloading of Functions by Profile Cg supports overloading of functions by compilation profile. This capability allows a function to be implemented differently for different profiles. It is also useful because different profiles may support different subsets of the language capabilities, and because the most efficient implementation of a function may be different for different profiles. The profile name must precede the return type name in the function declaration. For example, to define two different versions of the function myfunc for the profileA and profileB profiles: profileA float myfunc(float x) {...}; profileB float myfunc(float x) {...}; If a type is defined (using a typedef) that has the same name as a profile, the identifier is treated as a type name, and is not available for profile overloading at any subsequent point in the file. If a function definition does not include a profile, the function is referred to as an ‘‘open-profile’’ function. Open-profile functions apply to all profiles. Several wildcard profile names are defined. The name vs matches any vertex profile, while the name ps matches any fragment or pixel profile. The names ps_1 and ps_2 match any DX8 pixel shader 1.x profile, or DX9 pixel shader 2.x profile, respectively. Similarly, the names vs_1 and vs_2 match any DX vertex shader 1.x or 2.x, respectively. Additional valid wildcard profile names may be defined by individual profiles. In general, the most specific version of a function is used. More details are provided in the section on function overloading, but roughly speaking, the search order is the following: 1. version of the function with the exact profile overload 2. version of the function with the most specific wildcard profile overload (e.g. vs, ‘‘ps_1’’) 3. version of function with no profile overload This search process allows generic versions of a function to be defined that can be overridden as needed for particular hardware. perl v5.10.0 Cg Toolkit 3.0 16 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Syntax for Parameters in Function Definitions Functions are declared in a manner similar to C, but the parameters in function definitions may include a binding semantic (discussed later) and a default value. Each parameter in a function definition takes the following form: identifier [: ] [= ] is an expression that resolves to a constant at compile time. Default values are only permitted for uniform parameters, and for in parameters to non top-level functions. Function Calls A function call returns an rvalue. Therefore, if a function returns an array, the array may be read but not written. For example, the following is allowed: y = myfunc(x)[2]; But, this is not: myfunc(x)[2] = y; For multiple function calls within an expression, the calls can occur in any order — it is undefined. Types Cg’s types are as follows: • The int type is preferably 32−bit two’s complement. Profiles may optionally treat int as float. • The unsigned type is preferably a 32−bit ordinal value. unsigned may also be used with other integer types to make different sized unsigned values • The char, short, and long types are two’s complement integers of various sizes. The only requirement is that char is no larger that short, short is no larger than int and long is at least as large as int • The float type is as close as possible to the IEEE single precision (32−bit) floating point format. Profiles must support the float data type. • The half type is lower-precision IEEE-like floating point. Profiles must support the half type, but may choose to implement it with the same precision as the float type. • The fixed type is a signed type with a range of at least [−2,2) and with at least 10 bits of fractional precision. Overflow operations on the data type clamp rather than wrap. Fragment profiles must support the fixed type, but may implement it with the same precision as the half or float types. Vertex profiles are required to provide partial support (as defined below) for the fixed type. Vertex profiles have the option to provide full support for the fixed type or to implement the fixed type with the same precision as the half or float types. • The bool type represents Boolean values. Objects of bool type are either true or false. • The cint type is 32−bit two’s complement. This type is meaningful only at compile time; it is not possible to declare objects of type cint. • The cfloat type is IEEE single-precision (32−bit) floating point. This type is meaningful only at compile time; it is not possible to declare objects of type cfloat. • The void type may not be used in any expression. It may only be used as the return type of functions that do not return a value. • The sampler* types are handles to texture objects. Formal parameters of a program or function may be of type sampler*. No other definition of sampler* variables is permitted. A sampler* variable may only be used by passing it to another function as an in parameter. Assignment to sampler* variables is not permitted, and sampler* expressions are not permitted. perl v5.10.0 Cg Toolkit 3.0 17 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) The following sampler types are always defined: sampler, sampler1D, sampler2D, sampler3D, samplerCUBE, samplerRECT. The base sampler type may be used in any context in which a more specific sampler type is valid. However, a sampler variable must be used in a consistent way throughout the program. For example, it cannot be used in place of both a sampler1D and a sampler2D in the same program. The sampler type is deprecated and only provided for backwards compatibility with Cg 1.0 Fragment profiles are required to fully support the sampler, sampler1D, sampler2D, sampler3D, and samplerCUBE data types. Fragment profiles are required to provide partial support (as defined below) for the samplerRECT data type and may optionally provide full support for this data type. Vertex profiles are required to provide partial support for the six sampler data types and may optionally provide full support for these data types. • An array type is a collection of one or more elements of the same type. An array variable has a single index. • Some array types may be optionally designated as packed, using the packed type modifier. The storage format of a packed type may be different from the storage format of the corresponding unpacked type. The storage format of packed types is implementation dependent, but must be consistent for any particular combination of compiler and profile. The operations supported on a packed type in a particular profile may be different than the operations supported on the corresponding unpacked type in that same profile. Profiles may define a maximum allowable size for packed arrays, but must support at least size 4 for packed vector (1D array) types, and 4x4 for packed matrix (2D array) types. • When declaring an array of arrays in a single declaration, the packed modifier refers to all of the arrays. However, it is possible to declare an unpacked array of packed arrays by declaring the first level of array in a typedef using the packed keyword and then declaring an array of this type in a second statement. It is not possible to declare a packed array of unpacked arrays. • For any supported numeric data type TYPE, implementations must support the following packed array types, which are called vector types. Type identifiers must be predefined for these types in the global scope: typedef typedef typedef typedef packed packed packed packed TYPE TYPE TYPE TYPE TYPE1[1]; TYPE2[2]; TYPE3[3]; TYPE4[4]; For example, implementations must predefine the type identifiers float1, float2, float3, float4, and so on for any other supported numeric type. • For any supported numeric data type TYPE, implementations must support the following packed array types, which are called matrix types. Implementations must also predefine type identifiers (in the global scope) to represent these types: packed packed packed packed packed packed packed packed packed packed packed perl v5.10.0 TYPE1 TYPE2 TYPE3 TYPE4 TYPE1 TYPE2 TYPE3 TYPE4 TYPE1 TYPE2 TYPE3 TYPE1x1[1]; TYPE1x2[1]; TYPE1x3[1]; TYPE1x4[1]; TYPE2x1[2]; TYPE2x2[2]; TYPE2x3[2]; TYPE2x4[2]; TYPE3x1[3]; TYPE3x2[3]; TYPE3x3[3]; Cg Toolkit 3.0 18 CG_LANGUAGE(Cg) Cg Language Specification packed packed packed packed packed TYPE4 TYPE1 TYPE2 TYPE3 TYPE4 CG_LANGUAGE(Cg) TYPE3x4[3]; TYPE4x1[4]; TYPE4x2[4]; TYPE4x3[4]; TYPE4x4[4]; For example, implementations must predefine the type identifiers float2x1, float3x3, float4x4, and so on. A typedef follows the usual matrix-naming convention of TYPErows_X_columns. If we declare float4x4 a, then a[3] is equivalent to a._m30_m31_m32_m33 Both expressions extract the third row of the matrix. • Implementations are required to support indexing of vectors and matrices with constant indices. • A struct type is a collection of one or more members of possibly different types. It may include both function members (methods) and data members (fields). Struct and Interface types Interface types are defined with a interface keyword in place of the normal struct keyword. Interface types may only declare member functions, not data members. Interface member functions may only be declared, not defined (no default implementations in C++ parlance). Struct types may inherit from a single interface type, and must define an implementation member function for every member function declared in the interface type. Partial Support of Types This specification mandates ‘‘partial support’’ for some types. Partial support for a type requires the following: • Definitions and declarations using the type are supported. • Assignment and copy of objects of that type are supported (including implicit copies when passing function parameters). • Top-level function parameters may be defined using that type. If a type is partially supported, variables may be defined using that type but no useful operations can be performed on them. Partial support for types makes it easier to share data structures in code that is targeted at different profiles. Type Categories • The signed integral type category includes types cint, char, short, int, and long. • The unsigned integral type category includes types unsigned char, unsigned short, unsigned int, and unsigned long. unsigned is the same as unsigned int • The integral category includes both signed integral and unsigned integral types • The floating type category includes types cfloat, float, half, and fixed (Note that floating really means floating or fixed/fractional.) • The numeric type category includes integral and floating types. • The compile-time type category includes types cfloat and cint. These types are used by the compiler for constant type conversions. • The dynamic type category includes all interface and unsized array types • The concrete type category includes all types that are not included in the compile-time and dynamic type category. perl v5.10.0 Cg Toolkit 3.0 19 CG_LANGUAGE(Cg) • Cg Language Specification CG_LANGUAGE(Cg) The scalar type category includes all types in the numeric category, the bool type, and all types in the compile-time category. In this specification, a reference to a category type (such as a reference to a numeric type) means one of the types included in the category (such as float, half, or fixed). Constants Constant literals are defined as in C, including an optional 0 or 0x prefix for octal or hexadecimal constants, and e exponent suffix for floating point constants. A constant may be explicitly typed or implicitly typed. Explicit typing of a constant is performed, as in C, by suffixing the constant with a one or two characters indicating the type of the constant: • d for double • f for float • h for half • i for int • l for long • s for short • t for char • u for unsigned, which may also be followed by s, t, i, or l • x for fixed Any constant that is not explicitly typed is implicitly typed. If the constant includes a decimal point or an ’e’ exponent suffix, it is implicitly typed as cfloat. If it does not include a decimal point, it is implicitly typed as cint. By default, constants are base 10. For compatibility with C, integer hexadecimal constants may be specified by prefixing the constant with 0x, and integer octal constants may be specified by prefixing the constant with 0. Compile-time constant folding is preferably performed at the same precision that would be used if the operation were performed at run time. Some compilation profiles may allow some precision flexibility for the hardware; in such cases the compiler should ideally perform the constant folding at the highest hardware precision allowed for that data type in that profile. If constant folding cannot be performed at run-time precision, it may optionally be performed using the precision indicated below for each of the numeric datatypes: float s23e8 (‘‘fp32’’) IEEE single precision floating point half s10e5 (‘‘fp16’’) floating point w/ IEEE semantics fixed S1.10 fixed point, clamping to [−2, 2) double s52e11 (‘‘fp64’’) IEEE double precision floating point int signed 32 bit twos-complement integer char signed 8 bit twos-complement integer short signed 16 bit twos-complement integer long signed 64 bit twos-complement integer perl v5.10.0 Cg Toolkit 3.0 20 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Type Conversions Some type conversions are allowed implicitly, while others require an cast. Some implicit conversions may cause a warning, which can be suppressed by using an explicit cast. Explicit casts are indicated using C−style syntax (e.g., casting variable to the float4 type may be achieved via ‘‘(float4)variablename’’). Scalar conversions Implicit conversion of any scalar numeric type to any other scalar numeric type is allowed. A warning may be issued if the conversion is implicit and it is possible that precision is lost. implicit conversion of any scalar object type to any compatible scalar object type is also allowed. Conversions between incompatible scalar object types or object and numeric types are not allowed, even with an explicit cast. ‘‘sampler’’ is compatible with ‘‘sampler1D’’, ‘‘sampler2D’’, ‘‘sampler3D’’, ‘‘samplerCube’’, and ‘‘samplerRECT’’. No other object types are compatible (‘‘sampler1D’’ is not compatible with ‘‘sampler2D’’, even though both are compatible with ‘‘sampler’’). Scalar types may be implicitly converted to vectors and matrixes of compatible type. The scalar will be replicated to all elements of the vector or matrix. Scalar types may also be explicitly cast to structure types if the scalar type can be legally cast to every member of the structure. Vector conversions Vectors may be converted to scalar types (selects the first element of the vector). A warning is issued if this is done implicitly. A vector may also be implicitly converted to another vector of the same size and compatible element type. A vector may be converted to a smaller compatible vector, or a matrix of the same total size, but a warning if issued if an explicit cast is not used. Matrix conversions Matrixes may be converted to a scalar type (selects to 0,0 element). As with vectors, this causes a warning if its done implicitly. A matrix may also be converted implicitly to a matrix of the same size and shape and compatible element type A Matrix may be converted to a smaller matrix type (selects the upper− left submatrix), or to a vector of the same total size, but a warning is issued if an explicit cast is not used. Structure conversions a structure may be explicitly cast to the type of its first member, or to another structure type with the same number of members, if each member of the struct can be converted to the corresponding member of the new struct. No implicit conversions of struct types are allowed. Array conversions An array may be explicitly converted to another array type with the same number of elements and a compatible element type. A compatible element type is any type to which the element type of the initial array may be implicitly converted to. No implicit conversions of array types are allowed. T a r g e t t y p e perl v5.10.0 Source type | Scalar | Vector | Matrix | Struct | Array | −−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+ Scalar | A | W | W | E(3) | − | −−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+ Vector | A | A/W(1) | W(2) | E(3) | E(6) | −−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+ Matrix | A | W(2) | A/W(1) | E(3) | E(7) | −−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+ Struct | E | E(4) | E(4) | E(4/5) | E(4) | −−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+ Array | − | E(6) | E(7) | E(3) | E(6) | −−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+−−−−−−−−+ Cg Toolkit 3.0 21 CG_LANGUAGE(Cg) A W E − notes (1) (2) (3) (4) (5) (6) (7) Cg Language Specification = = = = CG_LANGUAGE(Cg) allowed implicitly or explicitly allowed, but warning issued if implicit only allowed with explicit cast not allowed not allowed if target is larger than source. Warning if target is smaller than source only allowed if source and target are the same total size only if the first member of the source can be converted to the target only if the target struct contains a single field of the source type only if both source and target have the same number of members and each member of the source can be converted to the corresponding member of the target. Source and target sizes must be the same and element types must be compatible Array type must be an array of vectors that matches the matrix type. Explicit casts are: • compile-time type when applied to expressions of compile-time type. • numeric type when applied to expressions of numeric or compile-time types. • numeric vector type when applied to another vector type of the same number of elements. • numeric matrix type when applied to another matrix type of the same number of rows and columns. Type Equivalency Type T1 is equivalent to type T2 if any of the following are true: • T2 is equivalent to T1. • T1 and T2 are the same scalar, vector, or structure type. A packed array type is not equivalent to the same size unpacked array. • T1 is a typedef name of T2. • T1 and T2 are arrays of equivalent types with the same number of elements. • The unqualified types of T1 and T2 are equivalent, and both types have the same qualifications. • T1 and T2 are functions with equivalent return types, the same number of parameters, and all corresponding parameters are pair-wise equivalent. Type-Promotion Rules The cfloat and cint types behave like float and int types, except for the usual arithmetic conversion behavior (defined below) and function-overloading rules (defined later). The usual arithmetic conversions for binary operators are defined as follows: 1. If one operand is cint it is converted to the other type 2. If one operand is cfloat and the other is floating, the cfloat is converted to the other type 3. If both operands are floating then the smaller type is converted to the larger type 4. If one operand is floating and the other is integral, the integral argument is converted to the floating type. perl v5.10.0 Cg Toolkit 3.0 22 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) 5. If both operands are integral the smaller type is converted to the larger type 6. If one operand is signed integral while the other is unsigned integral and they are the same size, the signed type is converted to unsigned. Note that conversions happen prior to performing the operation. Assignment Assignment of an expression to a concrete typed object converts the expression to the type of the object. The resulting value is then assigned to the object or value. The value of the assignment expressions (=, *=, and so on) is defined as in C: An assignment expression has the value of the left operand after the assignment but is not an lvalue. The type of an assignment expression is the type of the left operand unless the left operand has a qualified type, in which case it is the unqualified version of the type of the left operand. The side effect of updating the stored value of the left operand occurs between the previous and the next sequence point. An assignment of an expression to a dynamic typed object is only possible if the type of the expression is compatible with the dynamic object type. The object will then take on the type of the expression assigned to it until the next assignment to it. ‘‘Smearing’’ of Scalars to Vectors If a binary operator is applied to a vector and a scalar, the scalar is automatically type-promoted to a samesized vector by replicating the scalar into each component. The ternary ?: operator also supports smearing. The binary rule is applied to the second and third operands first, and then the binary rule is applied to this result and the first operand. Namespaces Just as in C, there are two namespaces. Each has multiple scopes, as in C. • Tag namespace, which consists of struct tags • Regular namespace: − typedef names (including an automatic typedef from a struct declaration) − variables − function names Arrays and Subscripting Arrays are declared as in C, except that they may optionally be declared to be packed, as described earlier. Arrays in Cg are first-class types, so array parameters to functions and programs must be declared using array syntax, rather than pointer syntax. Likewise, assignment of an array−typed object implies an array copy rather than a pointer copy. Arrays with size [1] may be declared but are considered a different type from the corresponding non-array type. Because the language does not currently support pointers, the storage order of arrays is only visible when an application passes parameters to a vertex or fragment program. Therefore, the compiler is currently free to allocate temporary variables as it sees fit. The declaration and use of arrays of arrays is in the same style as in C. That is, if the 2D array A is declared as float A[4][4]; then, the following statements are true: • perl v5.10.0 The array is indexed as A[row][column]; Cg Toolkit 3.0 23 CG_LANGUAGE(Cg) • Cg Language Specification The array can be built with a constructor using float4x4 A = { { { { { • CG_LANGUAGE(Cg) A[0][0], A[1][0], A[2][0], A[3][0], A[0][1], A[1][1], A[2][1], A[3][1], A[0][2], A[1][2], A[2][2], A[3][2], A[0][3] A[1][3] A[2][3] A[3][3] }, }, }, } }; A[0] is equivalent to float4(A[0][0], A[0][1], A[0][2], A[0][3]) Support must be provided for structs containing arrays. Unsized Arrays Objects may be declared as unsized arrays by using a declaration with an empty size [] and no initializer. If a declarator uses unsized array syntax with an initializer, it is declared with a concrete (sized) array type based on the declarator. Unsized arrays are dynamic typed objects that take on the size of any array assigned to them. Minimum Array Requirements Profiles are required to provide partial support for certain kinds of arrays. This partial support is designed to support vectors and matrices in all profiles. For vertex profiles, it is additionally designed to support arrays of light state (indexed by light number) passed as uniform parameters, and arrays of skinning matrices passed as uniform parameters. Profiles must support subscripting, copying, size querying and swizzling of vectors and matrices. However, subscripting with run-time computed indices is not required to be supported. Vertex profiles must support the following operations for any non-packed array that is a uniform parameter to the program, or is an element of a structure that is a uniform parameter to the program. This requirement also applies when the array is indirectly a uniform program parameter (that is, it and or the structure containing it has been passed via a chain of in function parameters). The three operations that must be supported are • rvalue subscripting by a run-time computed value or a compile-time value. • passing the entire array as a parameter to a function, where the corresponding formal function parameter is declared as in. • querying the size of the array with a .length suffix. The following operations are explicitly not required to be supported: • lvalue-subscripting • copying • other operators, including multiply, add, compare, and so on Note that when a uniform array is rvalue subscripted, the result is an expression, and this expression is no longer considered to be a uniform program parameter. Therefore, if this expression is an array, its subsequent use must conform to the standard rules for array usage. These rules are not limited to arrays of numeric types, and thus imply support for arrays of struct, arrays of matrices, and arrays of vectors when the array is a uniform program parameter. Maximum array sizes may be limited by the number of available registers or other resource limits, and compilers are permitted to issue error messages in these cases. However, profiles must support sizes of at least float arr[8], float4 arr[8], and float4x4 arr[4][4]. Fragment profiles are not required to support any operations on arbitrarily sized arrays; only support for vectors and matrices is required. perl v5.10.0 Cg Toolkit 3.0 24 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Function Overloading Multiple functions may be defined with the same name, as long as the definitions can be distinguished by unqualified parameter types and do not have an open-profile conflict (as described in the section on open functions). Function-matching rules: 1. Add all visible functions with a matching name in the calling scope to the set of function candidates. 2. Eliminate functions whose profile conflicts with the current compilation profile. 3. Eliminate functions with the wrong number of formal parameters. If a candidate function has excess formal parameters, and each of the excess parameters has a default value, do not eliminate the function. 4. If the set is empty, fail. 5. For each actual parameter expression in sequence (left to right), perform the following: 6. 7. a. If the type of the actual parameter matches the unqualified type of the corresponding formal parameter in any function in the set, remove all functions whose corresponding parameter does not match exactly. b. If there is a function with a dynamically typed formal argument which is compatible with the actual parameter type, remove all functions whose corresponding parameter is not similarly compatible. c. If there is a defined promotion for the type of the actual parameter to the unqualified type of the formal parameter of any function, remove all functions for which this is not true from the set. d. If there is a valid implicit cast that converts the type of the actual parameter to the unqualified type of the formal parameter of any function, remove all functions for which this is not true from the set e. Fail. Choose a function based on profile: a. If there is at least one function with a profile that exactly matches the compilation profile, discard all functions that don’t exactly match. b. Otherwise, if there is at least one function with a wildcard profile that matches the compilation profile, determine the ’most specific’ matching wildcard profile in the candidate set. Discard all functions except those with this ’most specific’ wildcard profile. How ’specific’ a given wildcard profile name is relative to a particular profile is determined by the profile specification. If the number of functions remaining in the set is not one, then fail. Global Variables Global variables are declared and used as in C. Non-static variables may have a semantic associated with them. Uniform non-static variables may have their value set through the run-time API. Use of Uninitialized Variables It is incorrect for a program to use an uninitialized static or local variable. However, the compiler is not obligated to detect such errors, even if it would be possible to do so by compile-time data-flow analysis. The value obtained from reading an uninitialized variable is undefined. This same rule applies to the implicit use of a variable that occurs when it is returned by a top-level function. In particular, if a top-level function returns a struct, and some element of that struct is never written, then the value of that element is undefined. Note: The language designers did not choose to define variables as being initialized to zero because that would result in a performance penalty in cases where the compiler is unable to determine if a variable is properly initialized by the programmer. perl v5.10.0 Cg Toolkit 3.0 25 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Preprocessor Cg profiles must support the full ANSI C standard preprocessor capabilities: #if, #define, and so on. However, while #include must be supported the mechanism by which the file to be included is located is implementation defined. Overview of Binding Semantics In stream-processing architectures, data packets flow between different programmable units. On a GPU, for example, packets of vertex data flow from the application to the vertex program. Because packets are produced by one program (the application, in this case), and consumed by another (the vertex program), there must be some mechanism for defining the interface between the two. Cg allows the user to choose between two different approaches to defining these interfaces. The first approach is to associate a binding semantic with each element of the packet. This approach is a bind-by-name approach. For example, an output with the binding semantic FOO is fed to an input with the binding semantic FOO. Profiles may allow the user to define arbitrary identifiers in this ‘‘semantic namespace’’, or they may restrict the allowed identifiers to a predefined set. Often, these predefined names correspond to the names of hardware registers or API resources. In some cases, predefined names may control non-programmable parts of the hardware. For example, vertex programs normally compute a position that is fed to the rasterizer, and this position is stored in an output with the binding semantic POSITION. For any profile, there are two namespaces for predefined binding semantics — the namespace used for in variables and the namespace used for out variables. The primary implication of having two namespaces is that the binding semantic cannot be used to implicitly specify whether a variable is in or out. The second approach to defining data packets is to describe the data that is present in a packet and allow the compiler to decide how to store it. In Cg, the user can describe the contents of a data packet by placing all of its contents into a struct. When a struct is used in this manner, we refer to it as a connector. The two approaches are not mutually exclusive, as is discussed later. The connector approach allows the user to rely on a combination of user-specified semantic bindings and compiler-determined bindings. Binding Semantics A binding semantic may be associated with an input to a top-level function or a global variable in one of three ways: • The binding semantic is specified in the formal parameter declaration for the function. The syntax for formal parameters to a function is: [const] [in | out | inout] [: ] • If the formal parameter is a struct, the binding semantic may be specified with an element of the struct when the struct is defined: struct { [ : ]; ... }; • If the input to the function is implicit (a non-static global variable that is read by the function), the binding semantic may be specified when the non-static global variable is declared: [varying [in | out]] [ : ]; If the non-static global variable is a struct, the binding semantic may be specified when the struct is defined, as described in the second bullet above. • perl v5.10.0 A binding semantic may be associated with the output of a top-level function in a similar manner: Cg Toolkit 3.0 26 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) ( ) [: ] { : Another method available for specifying a semantic for an output value is to return a struct, and to specify the binding semantic(s) with elements of the struct when the struct is defined. In addition, if the output is a formal parameter, then the binding semantic may be specified using the same approach used to specify binding semantics for inputs. Aliasing of Semantics Semantics must honor a copy-on-input and copy-on-output model. Thus, if the same input binding semantic is used for two different variables, those variables are initialized with the same value, but the variables are not aliased thereafter. Output aliasing is illegal, but implementations are not required to detect it. If the compiler does not issue an error on a program that aliases output binding semantics, the results are undefined. Additional Details for Binding Semantics The following are somewhat redundant, but provide extra clarity: • Semantic names are case-insensitive. • Semantics attached to parameters to non-main functions are ignored. • Input semantics may be aliased by multiple variables. • Output semantics may not be aliased. Using a Structure to Define Binding Semantics (Connectors) Cg profiles may optionally allow the user to avoid the requirement that a binding semantic be specified for every non-uniform input (or output) variable to a top-level program. To avoid this requirement, all the nonuniform variables should be included within a single struct. The compiler automatically allocates the elements of this structure to hardware resources in a manner that allows any program that returns this struct to interoperate with any program that uses this struct as an input. It is not required that all non-uniform inputs be included within a single struct in order to omit binding semantics. Binding semantics may be omitted from any input or output, and the compiler performs automatic allocation of that input or output to a hardware resource. However, to guarantee interoperability of one program’s output with another program’s input when automatic binding is performed, it is necessary to put all of the variables in a single struct. It is permissible to explicitly specify a binding semantic for some elements of the struct, but not others. The compiler’s automatic allocation must honor these explicit bindings. The allowed set of explicitly specified binding semantics is defined by the allocation-rule identifier. The most common use of this capability is to bind variables to hardware registers that write to, or read from, non-programmable parts of the hardware. For example, in a typical vertex-program profile, the output struct would contain an element with an explicitly specified POSITION semantic. This element is used to control the hardware rasterizer. Defining Binding Semantics via an external API It may be possible to define binding semantics on inputs and outputs by using an external API that manipulates the programs environment. The Cg Runtime API is such an API that allows this, and others may exist. How Programs Receive and Return Data A program is a non-static function that has been designated as the main entry point at compilation time. The varying inputs to the program come from this top-level function’s varying in parameters, and any global varying variables that do not have an out modifier. The uniform inputs to the program come from the top-level function’s uniform in parameters and from any non-static global variables that are referenced perl v5.10.0 Cg Toolkit 3.0 27 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) by the top-level function or by any functions that it calls. The output of the program comes from the return value of the function (which is always implicitly varying), from any out parameters, which must also be varying, and from any varying out global variables that are written by the program. Parameters to a program of type sampler* are implicitly const. Statements and Expressions Statements are expressed just as in C, unless an exception is stated elsewhere in this document. Additionally, • if, while, and for require bool expressions in the appropriate places. • Assignment is performed using =. The assignment operator returns a value, just as in C, so assignments may be chained. • The new discard statement terminates execution of the program for the current data element (such as the current vertex or current fragment) and suppresses its output. Vertex profiles may choose to omit support for discard. Minimum Requirements for if, while, for The minimum requirements are as follows: • All profiles should support if, but such support is not strictly required for older hardware. • All profiles should support for and while loops if the number of loop iterations can be determined at compile time. ‘‘Can be determined at compile time’’ is defined as follows: The loop-iteration expressions can be evaluated at compile time by use of intra-procedural constant propagation and folding, where the variables through which constant values are propagated do not appear as lvalues within any kind of control statement (if, for, or while) or ?: construct. Profiles may choose to support more general constant propagation techniques, but such support is not required. • Profiles may optionally support fully general for and while loops. New Vector Operators These new operators are defined for vector types: • Vector construction operator: typeID(...): This operator builds a vector from multiple scalars or shorter vectors: • − float4(scalar, scalar, scalar, scalar) − float4(float3, scalar) Matrix construction operator: typeID(...): This operator builds a matrix from multiple rows. Each row may be specified either as multiple scalars or as any combination of scalars and vectors with the appropriate size, e.g. float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9) float3x3(float3, float3, float3) float3x3(1, float2, float3, 1, 1, 1) • Vector swizzle operator: (.) a = b.xxyz; // A swizzle operator example perl v5.10.0 − At least one swizzle character must follow the operator. − There are three sets of swizzle characters and they may not be mixed: Set one is xyzw = 0123, set two is rgba = 0123, and set three is stpq = 0123. − The vector swizzle operator may only be applied to vectors or to scalars. Cg Toolkit 3.0 28 CG_LANGUAGE(Cg) • Cg Language Specification CG_LANGUAGE(Cg) − Applying the vector swizzle operator to a scalar gives the same result as applying the operator to a vector of length one. Thus, myscalar.xxx and float3(myscalar, myscalar, myscalar) yield the same value. − If only one swizzle character is specified, the result is a scalar not a vector of length one. Therefore, the expression b.y returns a scalar. − Care is required when swizzling a constant scalar because of ambiguity in the use of the decimal point character. For example, to create a three-vector from a scalar, use one of the following: (1).xxx or 1..xxx or 1.0.xxx or 1.0f.xxx − The size of the returned vector is determined by the number of swizzle characters. Therefore, the size of the result may be larger or smaller than the size of the original vector. For example, float2(0,1).xxyy and float4(0,0,1,1) yields the same result. Matrix swizzle operator: For any matrix type of the form ’ x ’, the notation: ’ ._m |
[_m |
][...]’ can be used to access individual matrix elements (in the case of only one ,
pair) or to construct vectors from elements of a matrix (in the case of more than one ,
pair). The row and column numbers are zero-based. For example: float4x4 myMatrix; float myFloatScalar; float4 myFloatVec4; // Set myFloatScalar to myMatrix[3][2] myFloatScalar = myMatrix._m32; // Assign the main diagonal of myMatrix to myFloatVec4 myFloatVec4 = myMatrix._m00_m11_m22_m33; For compatibility with the D3DMatrix data type, Cg also allows one-based swizzles, using a form with the m omitted after the _: ’ ._ |
[_ |
][...]’ In this form, the indexes for and
are one-based, rather than the C standard zero-based. So, the two forms are functionally equivalent: float4x4 myMatrix; float4 myVec; // These two statements are functionally equivalent: myVec = myMatrix._m00_m23_m11_m31; myVec = myMatrix._11_34_22_42; Because of the confusion that can be caused by the one-based indexing, its use is strongly discouraged. Also one-based indexing and zero-based indexing cannot be mixed in a single swizzle The matrix swizzles may only be applied to matrices. When multiple components are extracted from a matrix using a swizzle, the result is an appropriately sized vector. When a swizzle is used to extract a single component from a matrix, the result is a scalar. • perl v5.10.0 The write-mask operator: (.) It can only be applied to an lvalue that is a vector or matrix. It allows assignment to particular elements of a vector or matrix, leaving other elements unchanged. It looks exactly like a swizzle, with the additional restriction that a component cannot be repeated. Cg Toolkit 3.0 29 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Arithmetic Precision and Range Some hardware may not conform exactly to IEEE arithmetic rules. Fixed-point data types do not have IEEE-defined rules. Optimizations are permitted to produce slightly different results than unoptimized code. Constant folding must be done with approximately the correct precision and range, but is not required to produce bit-exact results. It is recommended that compilers provide an option either to forbid these optimizations or to guarantee that they are made in bit-exact fashion. Operator Precedence Cg uses the same operator precedence as C for operators that are common between the two languages. The swizzle and write-mask operators (.) have the same precedence as the structure member operator (.) and the array index operator []. Operator Enhancements The standard C arithmetic operators (+, −, *, /, %, unary −) are extended to support vectors and matrices. Sizes of vectors and matrices must be appropriately matched, according to standard mathematical rules. Scalar-to-vector promotion, as described earlier, allows relaxation of these rules. M[n][m] Matrix with n rows and m columns V[n] Vector with n elements −V[n] −> V[n] Unary vector negate −M[n] −> M[n] Unary matrix negate V[n] * V[n] −> V[n] Componentwise * V[n] / V[n] −> V[n] Componentwise / V[n] % V[n] −> V[n] Componentwise % V[n] + V[n] −> V[n] Componentwise + V[n] − V[n] −> V[n] Componentwise − M[n][m] * M[n][m] −> M[n][m] Componentwise * M[n][m] / M[n][m] −> M[n][m] Componentwise / M[n][m] % M[n][m] −> M[n][m] Componentwise % M[n][m] + M[n][m] −> M[n][m] Componentwise + M[n][m] − M[n][m] −> M[n][m] Componentwise − perl v5.10.0 Cg Toolkit 3.0 30 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) Operators Boolean && || ! Boolean operators may be applied to bool packed bool vectors, in which case they are applied in elementwise fashion to produce a result vector of the same size. Each operand must be a bool vector of the same size. Both sides of && and || are always evaluated; there is no short-circuiting as there is in C. Comparisons < > <= >= != == Comparison operators may be applied to numeric vectors. Both operands must be vectors of the same size. The comparison operation is performed in elementwise fashion to produce a bool vector of the same size. Comparison operators may also be applied to bool vectors. For the purpose of relational comparisons, true is treated as one and false is treated as zero. The comparison operation is performed in elementwise fashion to produce a bool vector of the same size. Comparison operators may also be applied to numeric or bool scalars. Arithmetic + − * / % ++ −− unary− unary+ The arithmetic operator % is the remainder operator, as in C. It may only be applied to two operands of cint or int types. When / or % is used with cint or int operands, C rules for integer / and % apply. The C operators that combine assignment with arithmetic operations (such as +=) are also supported when the corresponding arithmetic operator is supported by Cg. Conditional Operator ?: If the first operand is of type bool, one of the following must hold for the second and third operands: • Both operands have compatible structure types. • Both operands are scalars with numeric or bool type. • Both operands are vectors with numeric or bool type, where the two vectors are of the same size, which is less than or equal to four. If the first operand is a packed vector of bool, then the conditional selection is performed on an elementwise basis. Both the second and third operands must be numeric vectors of the same size as the first operand. Unlike C, side effects in the expressions in the second and third operands are always executed, regardless of the condition. Miscellaneous Operators (typecast) , Cg supports C’s typecast and comma operators. Reserved Words The following are currently used reserved words in Cg. A ’*’ indicates that the reserved word is caseinsensitive. _ _[anything] (i.e. any identifier with two underscores as a prefix) asm* perl v5.10.0 Cg Toolkit 3.0 31 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) asm_fragment auto bool break case catch char class column_major compile const const_cast continue decl* default delete discard do double dword* dynamic_cast else emit enum explicit extern false fixed float* for friend get goto half if in inline inout int interface long matrix* mutable namespace new operator out packed pass* pixelfragment* pixelshader* private perl v5.10.0 Cg Toolkit 3.0 32 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) protected public register reinterpret_cast return row_major sampler sampler_state sampler1D sampler2D sampler3D samplerCUBE shared short signed sizeof static static_cast string* struct switch technique* template texture* texture1D texture2D texture3D textureCUBE textureRECT this throw true try typedef typeid typename uniform union unsigned using vector* vertexfragment* vertexshader* virtual void volatile while Cg Standard Library Functions Cg provides a set of built-in functions and structures to simplify GPU programming. These functions are similar in spirit to the C standard library functions, providing a convenient set of common functions. The Cg Standard Library is documented in ‘‘spec_stdlib.txt’’. perl v5.10.0 Cg Toolkit 3.0 33 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) VERTEX PROGRAM PROFILES A few features of the Cg language that are specific to vertex program profiles are required to be implemented in the same manner for all vertex program profiles. Mandatory Computation of Position Output Vertex program profiles may (and typically do) require that the program compute a position output. This homogeneous clip-space position is used by the hardware rasterizer and must be stored in a program output with an output binding semantic of POSITION (or HPOS for backward compatibility). Position Invariance In many graphics APIs, the user can choose between two different approaches to specifying per-vertex computations: use a built-in configurable ‘‘fixed-function’’ pipeline or specify a user-written vertex program. If the user wishes to mix these two approaches, it is sometimes desirable to guarantee that the position computed by the first approach is bit-identical to the position computed by the second approach. This ‘‘position invariance’’ is particularly important for multipass rendering. Support for position invariance is optional in Cg vertex profiles, but for those vertex profiles that support it, the following rules apply: • Position invariance with respect to the fixed function pipeline is guaranteed if two conditions are met: − A #pragma position_invariant appears before the body of the top-level function for the vertex program. − The vertex program computes position as follows: OUT_POSITION = mul(MVP, IN_POSITION) where: OUT_POSITION is a variable (or structure element) of type float4 with an output binding semantic of POSITION or HPOS. IN_POSITION is a variable (or structure element) of type float4 with an input binding semantic of POSITION. MVP is a uniform variable (or structure element) of type float4x4 with an input binding semantic that causes it to track the fixed-function modelview-projection matrix. (The name of this binding semantic is currently profile-specific — for OpenGL profiles, the semantic state.matrix.mvp is recommended). • If the first condition is met but not the second, the compiler is encouraged to issue a warning. • Implementations may choose to recognize more general versions of the second condition (such as the variables being copy propagated from the original inputs and outputs), but this additional generality is not required. Binding Semantics for Outputs As shown in Table 10, there are two output binding semantics for vertex program profiles: Table 10 Name −−−−−−−− POSITION PSIZE Vertex Output Binding Semantics Meaning Type −−−−−−− −−−−−− Homogeneous clip−space float4 position; fed to rasterizer. Point size float Default Value −−−−−−−−−−−−− Undefined Undefined Profiles may define additional output binding semantics with specific behaviors, and these definitions are perl v5.10.0 Cg Toolkit 3.0 34 CG_LANGUAGE(Cg) Cg Language Specification CG_LANGUAGE(Cg) expected to be consistent across commonly used profiles. FRAGMENT PROGRAM PROFILES A few features of the Cg language that are specific to fragment program profiles are required to be implemented in the same manner for all fragment program profiles. Binding semantics for outputs As shown in Table 11, there are three output binding semantics for fragment program profiles: Table 11 Fragment Output Binding Semantics Name Meaning Type Default Value −−−− −−−−−−− −−−−−− −−−−−−−−−−−−− COLOR RGBA output color float4 Undefined COLOR0 Same as COLOR DEPTH Fragment depth value float Interpolated depth from rasterizer (in range [0,1]) (in range [0,1]) Profiles may define additional output binding semantics with specific behaviors, and these definitions are expected to be consistent across commonly used profiles. If a program desires an output color alpha of 1.0, it should explicitly write a value of 1.0 to the W component of the COLOR output. The language does *not* define a default value for this output. Note: If the target hardware uses a default value for this output, the compiler may choose to optimize away an explicit write specified by the user if it matches the default hardware value. Such defaults are not exposed in the language.) In contrast, the language does define a default value for the DEPTH output. This default value is the interpolated depth obtained from the rasterizer. Semantically, this default value is copied to the output at the beginning of the execution of the fragment program. As discussed earlier, when a binding semantic is applied to an output, the type of the output variable is not required to match the type of the binding semantic. For example, the following is legal, although not recommended: struct myfragoutput { float2 mycolor : COLOR; } In such cases, the variable is implicitly copied (with a typecast) to the semantic upon program completion. If the variable’s vector size is shorter than the semantic’s vector size, the larger-numbered components of the semantic receive their default values if applicable, and otherwise are undefined. In the case above, the R and G components of the output color are obtained from mycolor, while the B and A components of the color are undefined. perl v5.10.0 Cg Toolkit 3.0 35 CGC(1) Cg Commands CGC(1) NAME cgc − cg compiler driver SYNOPSIS cgc [options] file ... DESCRIPTION cgc is the standalone Cg compiler which translates Cg or GLSL programs into OpenGL or DirectX shader assembly code, or OpenGL or DirectX shading language code. OPTIONS Basic options −entry name Sets the entry function for the shader to compile. Defaults to main. −o file Sets the output file to be written. Default outputs to stdout. −l file Sets the listing file, where error and warning messages are written. Defaults to stderr. −profile name Selects the target profile, specifying the shader language to be generated. −profileopts opt1,opt2,... −po opt1,opt2,... Sets one or more profile specific options. −noentry Sets check only mode, where no shader is compiled, but all the code in the input file is checked for syntactic correctness. Language options −oglsl Sets the source language to GLSL. −ogles Sets the source language to OpneGL/ES GLSL. −strict −nostrict Enable or disable strict typechecking, where most questionable constructs will be flagged as warnings. −glslWerror Like −strict but in addition, unportable GLSL constructs will be flagged as errors. −nowarn Disable all warnings. −nowarn=N,N,... Disable one or more specific numbered warnings. −fx −nofx Enables or disables FX parsing mode, where FX keywords are recognized. Defaults to on in Cg mode and off in GLSL mode. −nostdlib Disable the standard library. perl v5.10.0 Cg Toolkit 3.0 36 CGC(1) Cg Commands CGC(1) Code Generation Options −fastmath −nofastmath Enable or disable optimizations that may chage/lose precision in low order bits, such as assocative transforms like (a + b) + c instead of a + (b + c). Default is −fastmath. −fastprecision −nofastprecision Enable or disable optimzations doing operations at lower precision than is specified when the result is later converted to a lower precision or the operands were originally in lower precision. Default is −nofastprecision. −bestprecision Always do things in the best possible precision; only use lower precision operations if there is no possibility of difference. Implies −nofastmath and −nofastprecision. −unroll all|none|count=N Control loop unrolling. −unroll all will force unrolling of all loops that can be unrolled, while −unroll none will prevent unrolling except if code cannot otherwise be generated in the current profiles (so it will have no effect in profiles that don’t support looping). unroll count=N will unroll loops if the estimate of the resulting code is less than N instructions. The estimate does not take into account further optimizations that may be done after unrolling, so it might be quite inaccurate. −inline all|none|count=N Control function inlining. Setting −inline none will additionally disable inlining of functions with an explicit inline keyword, which are otherwise always inlined. Setting −inline count=0 will effectively disable inlining of all functions that do not have an explicit inline keyword. −ifcvt all|none|count=N control if conversion (replacement of small if/else blocks with conditional assignments). −ON Sets the optimization level of the compiler, from 0 (lowest) to 3 (highest). Higher values may produce better code and will cause compile time to increase. Default is −O1. −looplimit N Assume loops that the compiler cannot determine an upper bound on the number of iterations may loop as many as N iterations. This may require generating extra code for such loops in some profiles. −d3d Generate code compatable with the Direct3D specification. −MaxInstInBasicBlock N break basic blocks after N instructions. This has an effect on local optimizations that don’t cross basic block boundaries and may avoid bad compile time blowups in the presence of huge basic blocks due to algorithms that are non-linear in the basic block size. −maxunrollcount N Deprecated. Don’t unroll loops with more than N iterations. Use the −unroll option instead, which provides better fine-grained control. Preprocessor Options −DMACRO[=VALUE] Sets a preprocessor macro. If VALUE is not specified it defaults to 1. −Idirectory Adds a directory to the end of the search path for #include files. The default search path is empty. −E Don’t compile, just prepocess the input. perl v5.10.0 Cg Toolkit 3.0 37 CGC(1) Cg Commands CGC(1) −P With −E, supresses the generation of #line directives in the output. −C With −E, preserves comments in the output. −MG Ignore #include files that can’t be found, rather than issuing an error. −M −MM −MD −MMD −MP −MF file −MT target −MQ target Generate dependency information about #included files. These options are intended to be compatible with the options to gcc. Miscellaneous Options −quiet −q Supress all ’noise’ output (copyright notices, indications of which files are being compiled, etc). With −o and −l, should result in no output being produced. −nocode Supress final code generation. Will actually run all the way through the compiler (so any errors present should be diagnosed), but don’t produce any actual output code. −v −−version Print compiler version information to listing. −h Print short option help summary to stdout and exit. −help Print longer option help summary to stdout, including all supported profiles and profile options, and exit. −type type_definition Set an override type binding for a variable. −typefile file Read override type bindings for variables from a file. −dumpinputbind file Dump type bindings for all variables to a file. This file may be passed back to the compiler with −typefile. Debugging options −debug Enable the debug builtin function to abort operation of a shader and immedaitely output a value. −debuglast Like −debug, except the shader does not abort; instead it continues and outputs the value of the last debug function called. −debugdefault=value Like −debug, except if no debug call is reached, the output will be set to the specified value instead of what the shader normally computes. perl v5.10.0 Cg Toolkit 3.0 38 CGC(1) Cg Commands CGC(1) −deprecated Issue errors instead of warnings for any deprecated features used. PROFILES A profile specifies the output language of the cg compiler (either a shader assembly dialect, or a shading language). Each profile has its own set of profile options that can be set for it, though many related profiles have similar or identical options. Profiles can be grouped by program type, API, or GPU generation. DirectX profiles ds_5_0, gs_4_0, gs_5_0, hlslf, hlslv, hs_5_0, ps_1_1, ps_1_2, ps_1_3, ps_2_0, ps_2_x, ps_3_0, ps_4_0, ps_5_0, vs_1_1, vs_2_0, vs_2_x, vs_3_0, vs_4_0, vs_5_0 OpenGL profiles arbfp1, arbvp1, fp20, fp30, fp30unlimited, fp40, fp40unlimited, glslf, glslg, glslv, gp4fp, gp4gp, gp4vp, gp5fp, gp5gp, gp5tcp, gp5tep, gp5vp, vp20, vp30, vp40 Fragment profiles arbfp1, fp20, fp30, fp30unlimited, fp40, fp40unlimited, glslf, gp4fp, gp5fp, hlslf, ps_1_1, ps_1_2, ps_1_3, ps_2_0, ps_2_x, ps_3_0, ps_4_0, ps_5_0 Geometry profiles glslg, gp4gp, gp5gp, gs_4_0, gs_5_0 Vertex profiles arbvp1, glslv, gp4vp, gp5vp, hlslv, vp20, vp30, vp40, vs_1_1, vs_2_0, vs_2_x, vs_3_0, vs_4_0, vs_5_0 GeForce 3/4 Series profiles fp20, vp20 GeForce 5 Series profiles fp30, vp30 GeForce 6/7 Series profiles fp40, vp40 GeForce 8/9/100/200/300 Series, OpenGL 3.x Quadro profiles gp4fp, gp4gp, gp4vp GeForce 400 Series, OpenGL 4.x Quadro profiles gp5fp, gp5gp, gp5tcp, gp5tep, gp5vp Profile options Here is a complete list of all profiles and their corresponding profile options arbfp1 Targets the ARB_fragment_program OpenGL extension −po ARB_draw_buffers Use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default −po ATI_draw_buffers Use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). −po MaxDrawBuffers=N Set the maximum number of renderbuffer targets. Default is 1 −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 32 −po MaxTexIndirections=N Sets the maximum number of texture indirections allowed in the output program. Default is 1024 perl v5.10.0 Cg Toolkit 3.0 39 CGC(1) Cg Commands CGC(1) −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 1024 −po NumMathInstructionSlots=N Sets the maximum number of non-texture instructions in the output program. Default is 1024 −po NumTemps=N Sets the maximum number of TEMP registers in the output program. Default is 32 −po NumTexInstructionSlots=N Sets the maximum number of texture instructions in the output program. Default is 1024 arbvp1 Targets the ARB_vertex_program OpenGL extension −po MaxAddressRegs=N Sets the maximum number of ADDRESS registers in the output program. Default is 1 −po MaxInstructions=N Sets the maximum number of instructions in the output program. Default is 1024 −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 96 −po NumTemps=N Sets the maximum number of TEMP registers in the output program. Default is 32 −po PosInv Generate position invariant code (same as fixed-function) for POSITION output fp20 Targets the NV_register_combiners2 and NV_texture_shader OpenGL extensions fp30 Targets the NV_fragment_program OpenGL extension −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 256 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 32 fp30unlimited Same as fp30 with various hardware limits on registers and instructions lifted −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 4194304 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 512 fp40 Targets the NV_fragment_program2 OpenGL extension −po appleKilWAR Work around various bugs with KIL instructions in the OSX-tiger implementation of NV_fragment_program2 −po ARB_draw_buffers Use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default −po ATI_draw_buffers Use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is infinite perl v5.10.0 Cg Toolkit 3.0 40 CGC(1) Cg Commands CGC(1) −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is infinite −po NumTemps=N Sets the maximum number of TEMP registers in the output program. Default is infinite −po OutColorPrec=N If N is 3 or 4, force output to fp16 precision. If N is 2, force output to fp32 precision. fp40unlimited Same as fp40 with various hardware limits on registers and instructions lifted −po appleKilWAR Work around various bugs with KIL instructions in the OSX-tiger implementation of NV_fragment_program2 −po ARB_draw_buffers Use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default −po ATI_draw_buffers Use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 1024 −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 4194304 −po NumTemps=N Sets the maximum number of TEMP registers in the output program. Default is 512 −po OutColorPrec=N If N is 3 or 4, force output to fp16 precision. If N is 2, force output to fp32 precision. generic Produces a dump of the program in a non-executable format glslf, glslg and glslv Targets the OpenGL Shading language (GLSL) v1.10. glslf targets fragment programs while glslv targets vertex programs version=val GLSL version to target. Supported versions are 100, 110, 120, 130, 140 and 150. userTexCoord Use user-defined varying instead of gl_TexCoord. ATI_draw_buffers Use ATI_draw_buffers extension for MRT. EXT_gpu_shader4 Use EXT_gpu_shader4 extension where useful. gp4fp Targets the NV_gpu_program4 and NV_fragment_program4 OpenGL extensions. −po fastimul Assume integer multiply inputs have at most 24 significant bits. −po NV_shader_buffer_load Use the NV_shader_buffer_load OpenGL extension. −po NV_parameter_buffer_object2 Use the NV_parameter_buffer_object2 OpenGL extension. perl v5.10.0 Cg Toolkit 3.0 41 CGC(1) Cg Commands CGC(1) −po PaBO2 Use the NV_parameter_buffer_object2 OpenGL extension. −po ARB_draw_buffers Use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default −po ATI_draw_buffers Use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). −po pixel_center_integer Use integer pixel centers. −po origin_upper_left Use upper left pixel origin. gp4gp Targets the NV_gpu_program4 and NV_geometry_program4 OpenGL extensions. −po POINT −po LINE −po LINE_ADJ −po TRIANGLE −po TRIANGLE_ADJ Set the input primitive type for the geometry program −po POINT_OUT −po LINE_OUT −po TRIANGLE_OUT Set the output primitive type for the geometry program −po Vertices=N Set the number of vertices output by the geometry program gp4vp Targets the NV_gpu_program4 and NV_vertex_program4 OpenGL extensions. −po PosInv Generate position invariant code (same as fixed-function) for POSITION output gp5fp Targets the NV_gpu_program5 OpenGL extension. −po fastimul Assume integer multiply inputs have at most 24 significant bits. −po NV_shader_buffer_load Use the NV_shader_buffer_load OpenGL extension. −po NV_parameter_buffer_object2 Use the NV_parameter_buffer_object2 OpenGL extension. −po PaBO2 Use the NV_parameter_buffer_object2 OpenGL extension. −po ARB_draw_buffers Use the ARB_draw_buffers option for multiple renderbuffer targets (MRT). This is the default −po ATI_draw_buffers Use the ATI_draw_buffers option for multiple renderbuffer targets (MRT). −po pixel_center_integer Use the ARB_fragment_coord_conventions OpenGL extension to specify integer pixel centers. −po origin_upper_left Use the ARB_fragment_coord_conventions OpenGL extension to specify upper left pixel origin. perl v5.10.0 Cg Toolkit 3.0 42 CGC(1) Cg Commands CGC(1) −po NV_early_fragment_tests Perform depth and stencil tests prior to fragment program invocation. gp5gp Targets the NV_gpu_program5 OpenGL extension. −po POINT −po LINE −po LINE_ADJ −po TRIANGLE −po TRIANGLE_ADJ Set the input primitive type for the geometry program −po POINT_OUT −po LINE_OUT −po TRIANGLE_OUT Set the output primitive type for the geometry program −po Vertices=N Set the number of vertices output by the geometry program gp5tcp Targets the NV_tessellation_program and NV_gpu_program5 OpenGL extensions. gp5tep Targets the NV_tessellation_program and NV_gpu_program5 OpenGL extensions. gp5vp Targets the NV_gpu_program5 OpenGL extension. −po PosInv Generate position invariant code (same as fixed-function) for POSITION output hlslf hlslv Targets Microsoft High-Level Shading Language (HLSL). hlslf targets pixel programs while hlslv targets vertex programs ps_1_1 ps_1_2 ps_1_3 Targets DirectX pixel programs −po MaxPixelShaderValue=N Maximum absolute value representable in a pixel shader. Default is 1. ps_2_0 ps_2_x Targets DirectX pixel programs −po MaxDrawBuffers=N Set the maximum number of renderbuffer targets. Default is 1 −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 96 or 512 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 12 or 32 ps_3_0 Targets DirectX pixel programs −po MaxDrawBuffers=N Set the maximum number of renderbuffer targets. Default is 1 −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 224 perl v5.10.0 Cg Toolkit 3.0 43 CGC(1) Cg Commands CGC(1) −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 32768 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 32 −po OutColorPrec=N If N is 3 or 4, force output to fp16 precision. If N is 2, force output to fp32 precision. vp20 Targets the NV_vertex_program OpenGL extension −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 96 −po PosInv Generate position invariant code (same as fixed-function) for POSITION output vp30 Targets the NV_vertex_program2 OpenGL extension −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 256 −po PosInv Generate position invariant code (same as fixed-function) for POSITION output vp40 Targets the NV_vertex_program3 OpenGL extension −po MaxAddressRegs=N Sets the maximum number of ADDRESS registers in the output program. Default is 2 −po MaxInstructions=N Sets the maximum number of instructions in the output program. Default is 2048 −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 544 −po NumTemps=N Sets the maximum number of TEMP registers in the output program. Default is 32 −po PosInv Generate position invariant code (same as fixed-function) for POSITION output vs_1_1 Targets DirectX vertex programs −po dcls Output dx9−style dcls statements −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 96 −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 128 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 12 vs_2_0 vs_2_x Targets DirectX vertex programs −po dcls Output dx9−style dcls statements perl v5.10.0 Cg Toolkit 3.0 44 CGC(1) Cg Commands CGC(1) −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 256 −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 256 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 12 vs_3_0 Targets DirectX vertex programs −po dcls Output dx9−style dcls statements −po MaxLocalParams=N Set the maximum number of uniform parameter slots available. Default is 256 −po NumInstructionSlots=N Sets the maximum number of instructions in the output program. Default is 32768 −po NumTemps=N Sets the maximum number of temporaries in the output program. Default is 32 ENVIRONMENT SEE ALSO Cg_language, arbfp1, arbvp1, fp20, fp30, fp40, glslf, glslv, gp4fp, gp4gp, gp4vp, hlslf, hlslv, vp20, vp30, vp40 perl v5.10.0 Cg Toolkit 3.0 45 CGFXCAT(1) Cg Commands CGFXCAT(1) NAME cgfxcat − dump a Cg effect or program file to standard out SYNOPSIS cgfxcat.exe [−gl] [−effect] [−program] [−object] [−profile profile] [−entry entry] file DESCRIPTION cgfxcat loads an effect or program file and calls every query operation available in the core runtime on the resulting Cg object. The values returned by the queries are written to standard out. The source code for cgfxcat is found under examples/Tools/cgfxcat. OPTIONS file The effect or program file to be processed. cgfxcat can handle effect files, program files, or precompiled program files. Files with a .cgfx or .fx extension will be loaded using cgCreateEffectFromFile. Files with a .cg or .hlsl extension will be loaded using cgCreateProgramFromFile. Any other extension is passed to cgGetProfile and if a valid CGprofile is found the file is loaded using cgCreateProgramFromFile with the program_type set to CG_OBJECT. You can override these built-in file extension mappings with the −effect, −program, or <−object> options. −effect Treat file as an effect file, ignoring its extension. −program Treat file as a program file, ignoring its extension. −object Treat file as an precompiled program file, ignoring its extension. −profile profile Use the CGprofile returned by cgGetProfile for profile as the profile argument of cgCreateProgramFromFile when compiling file. −entry entry Use entry as the entry argument of cgCreateProgramFromFile when compiling file. −gl Register states with cgGLRegisterStates rather than using the generic state code built into cgfxcat. SEE ALSO cgCreateEffectFromFile, cgCreateProgramFromFile, cgGetProfile, cgGLRegisterStates perl v5.10.0 Cg Toolkit 3.0 46 CGINFO(1) Cg Commands CGINFO(1) NAME cginfo − print Cg library information SYNOPSIS cginfo [−help] [−profiles] [/path/to/library] DESCRIPTION cginfo will print a Cg library’s version string to the standard output along with the path to the library from which the version was retrieved. The list of supported profiles can also be displayed. The source code for cginfo is found under examples/Tools/cginfo. This example demonstrates how to load the Cg library and get the address of a symbol from the library for all of the platforms on which Cg is supported. OPTIONS −help Print a description of the command line options understood by cginfo on the standard output. −profiles Also print a list of profiles supported by this library on the standard output. Note that the APIs to enumerate supported profiles were introduced in Cg 2.2. If the library being queried is 2.1 or earlier then this option will have no effect. /path/to/library Platform specific path the library to be queried. If no explicit library path is given the platform specific rules for finding shared libraries will be used to locate a copy of the Cg library to query. SEE ALSO Cg_language perl v5.10.0 Cg Toolkit 3.0 47 cgAddStateEnumerant(3) Cg Core Runtime API cgAddStateEnumerant(3) NAME cgAddStateEnumerant − associates an integer enumerant value as a possible value for a state SYNOPSIS #include void cgAddStateEnumerant( CGstate state, const char * name, int value ); PARAMETERS state The state to which to associate the name and value. name The name of the enumerant. value The value of the enumerant. RETURN VALUES None. DESCRIPTION cgAddStateEnumerant associates a given named integer enumerant value with a state definition. When that state is later used in a pass in an effect file, the value of the state assignment can optionally be given by providing a named enumerant defined with cgAddStateEnumerant. The state assignment will then take on the value provided when the enumerant was defined. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state. HISTORY cgAddStateEnumerant was introduced in Cg 1.4. SEE ALSO cgCreateState, cgCreateArrayState, cgCreateSamplerState, cgCreateArraySamplerState, cgGetStateName perl v5.10.0 Cg Toolkit 3.0 48 cgCallStateResetCallback(3) Cg Core Runtime API cgCallStateResetCallback(3) NAME cgCallStateResetCallback − calls the state resetting callback function for a state assignment SYNOPSIS #include CGbool cgCallStateResetCallback( CGstateassignment sa ); PARAMETERS sa The state assignment handle. RETURN VALUES Returns the boolean value returned by the callback function. It should be CG_TRUE upon success. Returns CG_TRUE if no callback function was defined. DESCRIPTION cgCallStateResetCallback calls the graphics state resetting callback function for the given state assignment. The semantics of ‘‘resetting state’’ will depend on the particular graphics state manager that defined the valid state assignments; it will generally either mean that graphics state is reset to what it was before the pass, or that it is reset to the default value. The OpenGL state manager in the OpenGL Cg runtime implements the latter approach. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgCallStateResetCallback was introduced in Cg 1.4. SEE ALSO cgResetPassState, cgSetStateCallbacks, cgCallStateSetCallback, cgCallStateValidateCallback perl v5.10.0 Cg Toolkit 3.0 49 cgCallStateSetCallback(3) Cg Core Runtime API cgCallStateSetCallback(3) NAME cgCallStateSetCallback − calls the state setting callback function for a state assignment SYNOPSIS #include CGbool cgCallStateSetCallback( CGstateassignment sa ); PARAMETERS sa The state assignment handle. RETURN VALUES Returns the boolean value returned by the callback function. It should be CG_TRUE upon success. Returns CG_TRUE if no callback function was defined. DESCRIPTION cgCallStateSetCallback calls the graphics state setting callback function for the given state assignment. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgCallStateSetCallback was introduced in Cg 1.4. SEE ALSO cgSetPassState, cgSetStateCallbacks, cgCallStateResetCallback, cgCallStateValidateCallback perl v5.10.0 Cg Toolkit 3.0 50 cgCallStateValidateCallback(3) Cg Core Runtime API cgCallStateValidateCallback(3) NAME cgCallStateValidateCallback − calls the state validation callback function for a state assignment SYNOPSIS #include CGbool cgCallStateValidateCallback( CGstateassignment sa ); PARAMETERS sa The state assignment handle. RETURN VALUES Returns the boolean value returned by the validation function. It should be CG_TRUE upon success. Returns CG_TRUE if no callback function was defined. DESCRIPTION cgCallStateValidateCallback calls the state validation callback function for the given state assignment. The validation callback will return CG_TRUE or CG_FALSE depending on whether the current hardware and driver support the graphics state set by the state assignment. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgCallStateValidateCallback was introduced in Cg 1.4. SEE ALSO cgSetStateCallbacks, cgCallStateSetCallback, cgCallStateResetCallback perl v5.10.0 Cg Toolkit 3.0 51 cgCombinePrograms(3) Cg Core Runtime API cgCombinePrograms(3) NAME cgCombinePrograms − combine programs from different domains SYNOPSIS #include CGprogram cgCombinePrograms( int n, const CGprogram * exeList ); PARAMETERS n The number of program objects in exeList. exeList An array of two or more executable programs, each from a different domain. RETURN VALUES Returns a handle to the newly created program on success. Returns NULL if an error occurs. DESCRIPTION cgCombinePrograms will take a set of n programs and combine them into a single CGprogram. This allows a single call to BindProgram (instead of a BindProgram for each individual program) and provides optimizations between the combined set of program inputs and outputs. EXAMPLES CGprogram p1 = cgCreateProgram(context, CG_SOURCE, vSrc, vProfile, vEntryName, NULL); CGprogram p2 = cgCreateProgram(context, CG_SOURCE, fSrc, fProfile, fEntryName, NULL); CGprogram programs[] = {p1, p2}; CGprogram combined = cgCombinePrograms(2, programs); cgDestroyProgram(p1); cgDestroyProgram(p2); cgGLBindProgram(combined); /* Assuming cgGL runtime */ /* Render... */ ERRORS CG_INVALID_DIMENSION_ERROR is generated if n less than or equal to 1 or n is greater than 3. CG_INVALID_PARAMETER_ERROR is generated if exeList is NULL. CG_INVALID_PROGRAM_HANDLE_ERROR is generated if one of the programs in exeList is invalid. The errors listed in cgCreateProgram might also be generated. HISTORY cgCombinePrograms was introduced in Cg 1.5. SEE ALSO cgCombinePrograms2, cgCombinePrograms3, cgCombinePrograms4, cgCombinePrograms5, cgCreateProgram, cgGLBindProgram, cgD3D9BindProgram, cgD3D8BindProgram perl v5.10.0 Cg Toolkit 3.0 52 cgCombinePrograms2(3) Cg Core Runtime API cgCombinePrograms2(3) NAME cgCombinePrograms2 − combine programs from two different domains SYNOPSIS #include CGprogram cgCombinePrograms2( const CGprogram program1, const CGprogram program2 ); PARAMETERS program1 An executable program from one domain. program2 An executable program from a different domain. RETURN VALUES Returns a handle to the newly created program on success. Returns NULL if an error occurs. DESCRIPTION cgCombinePrograms2 takes two programs from different domains and combines them into a single CGprogram. This is a convenience function for cgCombinePrograms. EXAMPLES CGprogram p1 = cgCreateProgram(context, CG_SOURCE, vSrc, vProfile, vEntryName, NULL); CGprogram p2 = cgCreateProgram(context, CG_SOURCE, fSrc, fProfile, fEntryName, NULL); CGprogram combined = cgCombinePrograms2(p1, p2); cgDestroyProgram(p1); cgDestroyProgram(p2); cgGLBindProgram(combined); /* Assuming cgGL runtime */ /* Render... */ ERRORS The errors listed in cgCombinePrograms might be generated. HISTORY cgCombinePrograms2 was introduced in Cg 1.5. SEE ALSO cgCombinePrograms, cgCombinePrograms3, cgCombinePrograms4, cgCombinePrograms5 perl v5.10.0 Cg Toolkit 3.0 53 cgCombinePrograms3(3) Cg Core Runtime API cgCombinePrograms3(3) NAME cgCombinePrograms3 − combine programs from three different domains SYNOPSIS #include CGprogram cgCombinePrograms3( const CGprogram program1, const CGprogram program2, const CGprogram program3 ); PARAMETERS program1 An executable program from one domain. program2 An executable program from a second domain. program3 An executable program from a third domain. RETURN VALUES Returns a handle to the newly created program on success. Returns NULL if an error occurs. DESCRIPTION cgCombinePrograms3 takes three programs from different domains and combines them into a single CGprogram. This is a convenience function for cgCombinePrograms. EXAMPLES CGprogram p1 = cgCreateProgram(context, CG_SOURCE, vSrc, vProfile, vEntryName, NULL); CGprogram p2 = cgCreateProgram(context, CG_SOURCE, fSrc, fProfile, fEntryName, NULL); CGprogram p3 = cgCreateProgram(context, CG_SOURCE, gSrc, gProfile, gEntryName, NULL); CGprogram combined = cgCombinePrograms3(p1, p2, p3); cgDestroyProgram(p1); cgDestroyProgram(p2); cgDestroyProgram(p3); cgGLBindProgram(combined); /* Assuming cgGL runtime */ /* Render... */ ERRORS The errors listed in cgCombinePrograms might be generated. HISTORY cgCombinePrograms3 was introduced in Cg 1.5. SEE ALSO cgCombinePrograms, cgCombinePrograms2, cgCombinePrograms4, cgCombinePrograms5 perl v5.10.0 Cg Toolkit 3.0 54 cgCombinePrograms4(3) Cg Core Runtime API cgCombinePrograms4(3) NAME cgCombinePrograms4 − combine programs from three different domains SYNOPSIS #include CGprogram cgCombinePrograms4( const const const const CGprogram CGprogram CGprogram CGprogram program1, program2, program3, program4 ); PARAMETERS program1 An executable program from one domain. program2 An executable program from a second domain. program3 An executable program from a third domain. program4 An executable program from a fourth domain. RETURN VALUES Returns a handle to the newly created program on success. Returns NULL if an error occurs. DESCRIPTION cgCombinePrograms4 takes four programs from different domains and combines them into a single CGprogram. This is a convenience function for cgCombinePrograms. EXAMPLES CGprogram p1 = cgCreateProgram(context, CG_SOURCE, vEntryName, NULL); CGprogram p2 = cgCreateProgram(context, CG_SOURCE, fEntryName, NULL); CGprogram p3 = cgCreateProgram(context, CG_SOURCE, tcEntryName, NULL); CGprogram p4 = cgCreateProgram(context, CG_SOURCE, teEntryName, NULL); vSrc, vProfile, fSrc, fProfile, tcSrc, tcProfile, teSrc, teProfile, CGprogram combined = cgCombinePrograms4(p1, p2, p3, p4); cgDestroyProgram(p1); cgDestroyProgram(p2); cgDestroyProgram(p3); cgDestroyProgram(p4); cgGLBindProgram(combined); /* Assuming cgGL runtime */ /* Render... */ ERRORS The errors listed in cgCombinePrograms might be generated. HISTORY cgCombinePrograms4 was introduced in Cg 3.0. perl v5.10.0 Cg Toolkit 3.0 55 cgCombinePrograms4(3) Cg Core Runtime API cgCombinePrograms4(3) SEE ALSO cgCombinePrograms, cgCombinePrograms2, cgCombinePrograms3, cgCombinePrograms5 perl v5.10.0 Cg Toolkit 3.0 56 cgCombinePrograms5(3) Cg Core Runtime API cgCombinePrograms5(3) NAME cgCombinePrograms5 − combine programs from three different domains SYNOPSIS #include CGprogram cgCombinePrograms5( const const const const const CGprogram CGprogram CGprogram CGprogram CGprogram program1, program2, program3, program4, program5 ); PARAMETERS program1 An executable program from one domain. program2 An executable program from a second domain. program3 An executable program from a third domain. program4 An executable program from a fourth domain. program5 An executable program from a fifth domain. RETURN VALUES Returns a handle to the newly created program on success. Returns NULL if an error occurs. DESCRIPTION cgCombinePrograms5 takes five programs from different domains and combines them into a single CGprogram. This is a convenience function for cgCombinePrograms. EXAMPLES CGprogram p1 = cgCreateProgram(context, CG_SOURCE, vEntryName, NULL); CGprogram p2 = cgCreateProgram(context, CG_SOURCE, fEntryName, NULL); CGprogram p3 = cgCreateProgram(context, CG_SOURCE, gEntryName, NULL); CGprogram p4 = cgCreateProgram(context, CG_SOURCE, tcEntryName, NULL); CGprogram p5 = cgCreateProgram(context, CG_SOURCE, teEntryName, NULL); vSrc, vProfile, fSrc, fProfile, gSrc, gProfile, tcSrc, tcProfile, teSrc, teProfile, CGprogram combined = cgCombinePrograms5(p1, p2, p3, p4, p5); cgDestroyProgram(p1); cgDestroyProgram(p2); cgDestroyProgram(p3); cgDestroyProgram(p4); cgDestroyProgram(p5); cgGLBindProgram(combined); /* Assuming cgGL runtime */ /* Render... */ perl v5.10.0 Cg Toolkit 3.0 57 cgCombinePrograms5(3) Cg Core Runtime API cgCombinePrograms5(3) ERRORS The errors listed in cgCombinePrograms might be generated. HISTORY cgCombinePrograms5 was introduced in Cg 3.0. SEE ALSO cgCombinePrograms, cgCombinePrograms2, cgCombinePrograms3, cgCombinePrograms4 perl v5.10.0 Cg Toolkit 3.0 58 cgCompileProgram(3) Cg Core Runtime API cgCompileProgram(3) NAME cgCompileProgram − compile a program object SYNOPSIS #include void cgCompileProgram( CGprogram program ); PARAMETERS program The program object to compile. RETURN VALUES None. DESCRIPTION cgCompileProgram compiles the specified Cg program for its target profile. A program must be compiled before it can be loaded (by the API-specific part of the runtime). It must also be compiled before its parameters can be inspected. The compiled program can be retrieved as a text string by passing CG_COMPILED_PROGRAM to cgGetProgramString. Certain actions invalidate a compiled program and the current value of all of its parameters. If one of these actions is performed, the program must be recompiled before it can be used. A program is invalidated if the program source is modified, if the compile arguments are modified, or if the entry point is changed. If one of the parameter bindings for a program is changed, that action invalidates the compiled program, but does not invalidate the current value of the program’s parameters. EXAMPLES if(!cgIsProgramCompiled(program)) cgCompileProgram(program); ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_COMPILER_ERROR is generated if compilation fails. HISTORY cgCompileProgram was introduced in Cg 1.1. SEE ALSO cgIsProgramCompiled, cgCreateProgram, cgGetNextParameter, cgIsParameter, cgGetProgramString perl v5.10.0 Cg Toolkit 3.0 59 cgConnectParameter(3) Cg Core Runtime API cgConnectParameter(3) NAME cgConnectParameter − connect two parameters SYNOPSIS #include void cgConnectParameter( CGparameter from, CGparameter to ); PARAMETERS from The source parameter. to The destination parameter. RETURN VALUES None. DESCRIPTION cgConnectParameter connects a source (from) parameter to a destination (to) parameter. The resulting connection forces the value and variability of the destination parameter to be identical to the source parameter. A source parameter may be connected to multiple destination parameters but there may only be one source parameter per destination parameter. cgConnectParameter may be used to create an arbitrarily deep tree. A runtime error will be thrown if a cycle is inadvertently created. For example, the following code snipped would generate a CG_BIND_CREATES_CYCLE_ERROR : CGcontext context = cgCreateContext(); CGparameter Param1 = cgCreateParameter(context, CG_FLOAT); CGparameter Param2 = cgCreateParameter(context, CG_FLOAT); CGparameter Param3 = cgCreateParameter(context, CG_FLOAT); cgConnectParameter(Param1, Param2); cgConnectParameter(Param2, Param3); cgConnectParameter(Param3, Param1); /* This will generate the error */ If the source type is a complex type (e.g., struct, or array) the topology and member types of both parameters must be identical. Each correlating member parameter will be connected. Both parameters must be of the same type unless the source parameter is a struct type, the destination parameter is an interface type, and the struct type implements the interface type. In such a case, a copy of the parameter tree under the source parameter will be duplicated, linked to the orignal tree, and placed under the destination parameter. If an array parameter is connected to a resizable array parameter the destination parameter array will automatically be resized to match the source array. The source parameter may not be a program parameter. Also the variability of the parameters may not be CG_VARYING. EXAMPLES CGparameter TimeParam1 = cgGetNamedParameter(program1, "time"); CGparameter TimeParam2 = cgGetNamedParameter(program2, "time"); CGparameter SharedTime = cgCreateParameter(context, cgGetParameterType(TimeParam1)); cgConnectParameter(SharedTime, TimeParam1); cgConnectParameter(SharedTime, TimeParam2); cgSetParameter1f(SharedTime, 2.0); perl v5.10.0 Cg Toolkit 3.0 60 cgConnectParameter(3) Cg Core Runtime API cgConnectParameter(3) ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if either of the from or to parameters are invalid handles. CG_PARAMETER_IS_NOT_SHARED_ERROR is generated if the source parameter is a program parameter. CG_BIND_CREATES_CYCLE_ERROR is generated if the connection will result in a cycle. CG_PARAMETERS_DO_NOT_MATCH_ERROR is generated if the parameters do not have the same type or the topologies do not match. CG_ARRAY_TYPES_DO_NOT_MATCH_ERROR is generated if the type of two arrays being connected do not match. CG_ARRAY_DIMENSIONS_DO_NOT_MATCH_ERROR is generated if the dimensions of two arrays being connected do not match. HISTORY cgConnectParameter was introduced in Cg 1.2. SEE ALSO cgGetConnectedParameter, cgGetConnectedToParameter, cgDisconnectParameter perl v5.10.0 Cg Toolkit 3.0 61 cgCopyEffect(3) Cg Core Runtime API cgCopyEffect(3) NAME cgCopyEffect − make a copy of an effect SYNOPSIS #include CGeffect cgCopyEffect( CGeffect effect ); PARAMETERS effect The effect object to be copied. RETURN VALUES Returns a copy of effect on success. Returns NULL if effect is invalid or the copy fails. DESCRIPTION cgCopyEffect creates a new effect object that is a copy of effect and adds it to the same context as effect. Note: Currently cgCopyEffect does not work and therefore will always returns NULL. EXAMPLES CGeffect effectCopy = cgCopyEffect(effect); ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgCopyEffect was introduced in Cg 2.0. cgCopyEffect is not operational as of Cg 3.0. SEE ALSO cgCreateEffect, cgCreateEffectFromFile, cgDestroyEffect perl v5.10.0 Cg Toolkit 3.0 62 cgCopyProgram(3) Cg Core Runtime API cgCopyProgram(3) NAME cgCopyProgram − make a copy of a program object SYNOPSIS #include CGprogram cgCopyProgram( CGprogram program ); PARAMETERS program The program object to copy. RETURN VALUES Returns a copy of program on success. Returns NULL if program is invalid or the copy fails. DESCRIPTION cgCopyProgram creates a new program object that is a copy of program and adds it to the same context as program. cgCopyProgram is useful for creating a new instance of a program whose parameter properties have been modified by the run-time API. EXAMPLES CGprogram programCopy = cgCopyProgram(program); ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgCopyProgram was introduced in Cg 1.1. cgCopyProgram is operational as of Cg 3.0. SEE ALSO cgCreateProgram, cgDestroyProgram perl v5.10.0 Cg Toolkit 3.0 63 cgCreateArraySamplerState(3) Cg Core Runtime API cgCreateArraySamplerState(3) NAME cgCreateArraySamplerState − create an array-typed sampler state definition SYNOPSIS #include CGstate cgCreateArraySamplerState( CGcontext context, const char * name, CGtype type, int nelements ); PARAMETERS context The context in which to define the sampler state. name The name of the new sampler state. type The type of the new sampler state. nelements The number of elements in the array. RETURN VALUES Returns a handle to the newly created CGstate. Returns NULL if there is an error. DESCRIPTION cgCreateArraySamplerState adds a new array-typed sampler state definition to context. All state in sampler_state blocks must have been defined ahead of time via a call to cgCreateSamplerState or cgCreateArraySamplerState before adding an effect file to the context. Applications will typically call cgSetStateCallbacks shortly after creating a new state with cgCreateArraySamplerState. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_PARAMETER_ERROR is generated if name is NULL or not a valid identifier, if type is not a simple scalar, vector, or matrix-type, or if nelements is not a positive number. HISTORY cgCreateArraySamplerState was introduced in Cg 1.4. SEE ALSO cgCreateSamplerState, cgGLRegisterStates perl v5.10.0 cgGetStateName, cgGetStateType, Cg Toolkit 3.0 cgIsState, cgSetStateCallbacks, 64 cgCreateArrayState(3) Cg Core Runtime API cgCreateArrayState(3) NAME cgCreateArrayState − create an array-typed state definition SYNOPSIS #include CGstate cgCreateArrayState( CGcontext context, const char * name, CGtype type, int nelements ); PARAMETERS context The context in which to define the state. name The name of the new state. type The type of the new state. nelements The number of elements in the array. RETURN VALUES Returns a handle to the newly created CGstate. Returns NULL if there is an error. DESCRIPTION cgCreateArrayState adds a new array-typed state definition to context. Before a CgFX file is added to a context, all state assignments in the file must have previously been defined via a call to cgCreateState or cgCreateArrayState. Applications will typically call cgSetStateCallbacks shortly after creating a new state with cgCreateArrayState. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_PARAMETER_ERROR is generated if name is NULL or not a valid identifier, if type is not a simple scalar, vector, or matrix-type, or if nelements is not a positive number. HISTORY cgCreateArrayState was introduced in Cg 1.4. SEE ALSO cgGetStateContext, cgGetStateName, cgGetStateType, cgIsState, cgSetStateCallbacks, cgGLRegisterStates perl v5.10.0 Cg Toolkit 3.0 65 cgCreateBuffer(3) Cg Core Runtime API cgCreateBuffer(3) NAME cgCreateBuffer − create a buffer object managed by the runtime SYNOPSIS #include CGbuffer cgCreateBuffer( CGcontext context, int size, const void *data, CGbufferusage bufferUsage ); PARAMETERS context The context to which the new buffer will be added. size The length in bytes of the buffer to create. data Pointer to inital buffer data. NULL will fill the buffer with zero. bufferUsage Indicates the intended usage method of the buffer. Can be one of the following types: • CG_BUFFER_USAGE_STREAM_DRAW • CG_BUFFER_USAGE_STREAM_READ • CG_BUFFER_USAGE_STREAM_COPY • CG_BUFFER_USAGE_STATIC_DRAW • CG_BUFFER_USAGE_STATIC_READ • CG_BUFFER_USAGE_STATIC_COPY • CG_BUFFER_USAGE_DYNAMIC_DRAW • CG_BUFFER_USAGE_DYNAMIC_READ • CG_BUFFER_USAGE_DYNAMIC_COPY RETURN VALUES Returns a CGbuffer handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreateBuffer creates a runtime managed Cg buffer object. There is no way to query the 3D API-specific resource for a managed buffer. cgGLCreateBuffer should be used if the application wishes to later query the 3D API-specific resource for the buffer. EXAMPLES CGbuffer myBuffer = cgCreateBuffer( myCgContext, sizeof( float ) * 16, initalData, CG_BUFFER_USAGE_STATIC_DRAW ); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgCreateBuffer was introduced in Cg 2.0. SEE ALSO cgGLCreateBuffer, cgDestroyBuffer perl v5.10.0 Cg Toolkit 3.0 66 cgCreateContext(3) Cg Core Runtime API cgCreateContext(3) NAME cgCreateContext − create a context SYNOPSIS #include CGcontext cgCreateContext( void ); PARAMETERS None. RETURN VALUES Returns a valid CGcontext on success. Returns NULL if context creation fails. DESCRIPTION cgCreateContext creates a Cg context object and returns its handle. A Cg context is a container for Cg programs. All Cg programs must be added to a Cg context. EXAMPLES CGcontext context = cgCreateContext(); ERRORS CG_MEMORY_ALLOC_ERROR is generated if a context couldn’t be created. HISTORY cgCreateContext was introduced in Cg 1.1. SEE ALSO cgDestroyContext, cgSetContextBehavior, cgGetContextBehavior, cgCreateProgram, cgCreateEffect, cgCreateState perl v5.10.0 Cg Toolkit 3.0 67 cgCreateEffect(3) Cg Core Runtime API cgCreateEffect(3) NAME cgCreateEffect − create an effect object from a source string SYNOPSIS #include 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 perl v5.10.0 Cg Toolkit 3.0 68 cgCreateEffectAnnotation(3) Cg Core Runtime API cgCreateEffectAnnotation(3) NAME cgCreateEffectAnnotation − create an effect annotation SYNOPSIS #include CGannotation cgCreateEffectAnnotation( CGeffect effect, const char * name, CGtype type ); PARAMETERS effect The effect to which the new annotation will be added. name The name of the new annotation. type The type of the new annotation. RETURN VALUES Returns the new CGannotation handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreateEffectAnnotation adds a new annotation to the effect. EXAMPLES /* create a float annotation named "Apple" for CGeffect effect */ CGannotation ann = cgCreateEffectAnnotation( effect, "Apple", CG_FLOAT ); ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_DUPLICATE_NAME_ERROR is generated if name is already used by an annotation for this effect. CG_INVALID_ENUMERANT_ERROR is generated if type is not CG_INT, CG_FLOAT, CG_BOOL, or CG_STRING. HISTORY cgCreateEffectAnnotation was introduced in Cg 1.5. SEE ALSO cgGetNamedEffectAnnotation, cgGetFirstEffectAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 69 cgCreateEffectFromFile(3) Cg Core Runtime API cgCreateEffectFromFile(3) NAME cgCreateEffectFromFile − create an effect object from a file SYNOPSIS #include CGeffect cgCreateEffectFromFile( CGcontext context, const char * filename, const char ** args ); PARAMETERS context The context to which the new effect will be added. filename Name of a file that contains 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 cgCreateEffectFromFile 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 CGcontext context = cgCreateContext(); CGeffect effect = cgCreateEffectFromFile(context, "filename.cgfx", NULL); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_FILE_READ_ERROR is generated if the given filename cannot be read. CG_COMPILER_ERROR is generated if compilation fails. HISTORY cgCreateEffectFromFile was introduced in Cg 1.4. SEE ALSO cgCreateContext, cgCreateEffect, cgGetLastListing, cgGetTechniqueEffect, cgSetEffectName, cgCreateEffectAnnotation, cgDestroyEffect, cgGetFirstEffect perl v5.10.0 Cg Toolkit 3.0 cgGetEffectName, 70 cgCreateEffectParameter(3) Cg Core Runtime API cgCreateEffectParameter(3) NAME cgCreateEffectParameter − create a parameter in an effect SYNOPSIS #include CGparameter cgCreateEffectParameter( CGeffect effect, const char * name, CGtype type ); PARAMETERS effect The effect to which the new parameter will be added. name The name of the new parameter. type The type of the new parameter. RETURN VALUES Returns the handle to the new parameter. DESCRIPTION cgCreateEffectParameter adds a new parameter to the specified effect. EXAMPLES CGeffect effect = cgCreateEffect( ... ); CGparameter param = cgCreateEffectParameter( effect, "myFloatParam", CG_FLOAT ); ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_INVALID_VALUE_TYPE_ERROR is generated if type is invalid. HISTORY cgCreateEffectParameter was introduced in Cg 1.5. SEE ALSO cgIsParameter, cgCreateEffectParameterArray, cgCreateTechnique, cgCreatePass, cgConnectParameter perl v5.10.0 Cg Toolkit 3.0 cgCreateEffectParameterMultiDimArray, 71 cgCreateEffectParameterArray(3) Cg Core Runtime API cgCreateEffectParameterArray(3) NAME cgCreateEffectParameterArray − create an array parameter in an effect SYNOPSIS #include CGparameter cgCreateEffectParameterArray( CGeffect effect, const char * name, CGtype type, int length ); PARAMETERS effect The effect to which the new parameter will be added. name The name of the new parameter. type The type of the new parameter. length The size of the array. RETURN VALUES Returns the handle to the new array parameter on success. Returns NULL if an error occurs. DESCRIPTION cgCreateEffectParameterArray adds a new array parameter to the specificed effect. EXAMPLES CGeffect effect = cgCreateEffect( ... ); CGparameter array = cgCreateEffectParameterArray( effect, "myFloatArray", CG_FLOAT, 2 ); ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_INVALID_VALUE_TYPE_ERROR is generated if type is invalid. HISTORY cgCreateEffectParameterArray was introduced in Cg 1.5. SEE ALSO cgCreateEffectParameter, cgCreateEffectParameterMultiDimArray perl v5.10.0 Cg Toolkit 3.0 72 cgCreateEffectParameterMultiDimArray(3) Cg Core Runtime API cgCreateEffectParameterMultiDimArray(3) NAME cgCreateEffectParameterMultiDimArray − create a multi-dimensional array in an effect SYNOPSIS #include CGparameter cgCreateEffectParameterMultiDimArray( CGeffect effect, const char * name, CGtype type, int dim, const int * lengths ); PARAMETERS effect The effect to which the new parameter will be added. name The name of the new parameter. type The type of the new parameter. dim The dimension of the array. lengths The sizes for each dimension of the array. RETURN VALUES Returns the handle of the new parameter on success. Returns NULL if an error occurs. DESCRIPTION cgCreateEffectParameterMultiDimArray adds a new multidimensional array parameter to the specified effect. EXAMPLES CGeffect effect = cgCreateEffect( ... ); int lengths[] = {2,2}; CGparameter array = cgCreateEffectParameterMultiDimArray(effect, "myFloatMultiArray", CG_FLOAT, 2, lengths); ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_INVALID_VALUE_TYPE_ERROR is generated if type is invalid. HISTORY cgCreateEffectParameterMultiDimArray was introduced in Cg 1.5. SEE ALSO cgCreateEffectParameter, cgCreateEffectParameterArray perl v5.10.0 Cg Toolkit 3.0 73 cgCreateObj(3) Cg Core Runtime API cgCreateObj(3) NAME cgCreateObj − create a cg object type from a shader string SYNOPSIS #include CGobj cgCreateObj( CGcontext context, CGenum program_type, const char * source, CGprofile profile, const char ** args ); PARAMETERS context The context to which the new object will be added. program_type An enumerant describing the contents of the source string. The following enumerants are allowed: CG_SOURCE source contains Cg source code. CG_OBJECT 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 program_type for more information. profile The profile enumerant for the program. 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 CGobj handle on success. Returns NULL 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: 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, CG_SOURCE, src, CG_PROFILE_ARBVP1, NULL); // Now we can get the CGtype: CGtype userDefinedMyType = cgGetNamedUserType(structObj, "MyType"); // We could also iterate through all the types in the CGobj printing their perl v5.10.0 Cg Toolkit 3.0 74 cgCreateObj(3) Cg Core Runtime API cgCreateObj(3) // names like this: int numTypes = cgGetNumUserTypes(structObj); for (int i=0; i CGobj cgCreateObjFromFile( CGcontext context, CGenum program_type, const char * source_file, CGprofile profile, const char ** args ); PARAMETERS context The context to which the new object will be added. program_type An enumerant describing the contents of the source string. The following enumerants are allowed: CG_SOURCE source contains Cg source code. CG_OBJECT source contains object code that resulted from the precompilation of some Cg source code. source_file Name of a file containing source or object code. See program_type for more information. profile The profile enumerant for the program. 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 CGobj handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreateObjFromFile 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 // To create a Cg obj: CGcontext ctx = cgCreateContext(); CGobj structObj = cgCreateObjFromFile(ctx, CG_SOURCE, source_file, CG_PROFILE_ARBVP1, NULL); // 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 CGparameter cgCreateParameter( CGcontext context, CGtype type ); PARAMETERS context The context to which the new parameter will be added. type The type of the new parameter. RETURN VALUES Returns the handle to the new parameter. DESCRIPTION cgCreateParameter creates context level shared parameters. These parameters are primarily used by connecting them to one or more program parameters with cgConnectParameter. EXAMPLES CGcontext context = cgCreateContext(); CGparameter param = cgCreateParameter(context, CG_FLOAT); ERRORS CG_INVALID_VALUE_TYPE_ERROR is generated if type is invalid. CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgCreateParameter was introduced in Cg 1.2. SEE ALSO cgCreateParameterArray, cgCreateParameterMultiDimArray, cgDestroyParameter, cgConnectParameter perl v5.10.0 Cg Toolkit 3.0 cgCreateEffectParameter, 78 cgCreateParameterAnnotation(3) Cg Core Runtime API cgCreateParameterAnnotation(3) NAME cgCreateParameterAnnotation − create an annotation in a parameter SYNOPSIS #include CGannotation cgCreateParameterAnnotation( CGparameter param, const char * name, CGtype type ); PARAMETERS parm The parameter to which the new annotation will be added. name The name of the new annotation. type The type of the new annotation. RETURN VALUES Returns the new CGannotation handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreateParameterAnnotation adds a new annotation to the specified parameter. EXAMPLES CGannotation ann = cgCreateParameterAnnotation( param, "Apple", CG_FLOAT ); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_DUPLICATE_NAME_ERROR is generated if name is already used by an annotation for this parameter. CG_INVALID_ENUMERANT_ERROR is generated if type is not CG_INT, CG_FLOAT, CG_BOOL, or CG_STRING. HISTORY cgCreateParameterAnnotation was introduced in Cg 1.5. SEE ALSO cgGetNamedParameterAnnotation, cgGetFirstParameterAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 79 cgCreateParameterArray(3) Cg Core Runtime API cgCreateParameterArray(3) NAME cgCreateParameterArray − creates a parameter array SYNOPSIS #include CGparameter cgCreateParameterArray( CGcontext context, CGtype type, int length ); PARAMETERS context The context to which the new parameter will be added. type The type of the new parameter. length The length of the array being created. RETURN VALUES Returns the handle to the new parameter array. DESCRIPTION cgCreateParameterArray creates context level shared parameter arrays. These parameters are primarily used by connecting them to one or more program parameter arrays with cgConnectParameter. cgCreateParameterArray works similarly to cgCreateParameter, but creates an array of parameters rather than a single parameter. EXAMPLES CGcontext context = cgCreateContext(); CGparameter param = cgCreateParameterArray(context, CG_FLOAT, 5); ERRORS CG_INVALID_VALUE_TYPE_ERROR is generated if type is invalid. CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgCreateParameterArray was introduced in Cg 1.2. SEE ALSO cgCreateParameter, cgCreateParameterMultiDimArray, cgDestroyParameter perl v5.10.0 Cg Toolkit 3.0 80 cgCreateParameterMultiDimArray(3) Cg Core Runtime API cgCreateParameterMultiDimArray(3) NAME cgCreateParameterMultiDimArray − creates a multi-dimensional parameter array SYNOPSIS #include CGparameter cgCreateParameterMultiDimArray( CGcontext context, CGtype type, int dim, const int * lengths ); PARAMETERS context The context to which the new parameter will be added. type The type of the new parameter. dim The dimension of the multi-dimensional array. lengths An array of length values, one for each dimension of the array to be created. RETURN VALUES Returns the handle to the new parameter array. DESCRIPTION cgCreateParameterMultiDimArray creates context level shared multi-dimensional parameter arrays. These parameters are primarily used by connecting them to one or more program parameter arrays with cgConnectParameter. cgCreateParameterMultiDimArray works similarly to cgCreateParameterArray. Instead of taking a single length parameter it takes an array of lengths, one per dimension. The dimension of the array is defined by the dim parameter. EXAMPLES /* Creates a three dimensional float array similar to */ /* the C declaration : float param[5][3][4]; */ int lengths[] = { 5, 3, 4 }; CGcontext context = cgCreateContext(); CGparameter param = cgCreateParameterMultiDimArray(context, CG_FLOAT, 3, lengths); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_VALUE_TYPE_ERROR is generated if type is invalid. HISTORY cgCreateParameterMultiDimArray was introduced in Cg 1.2. SEE ALSO cgCreateParameter, cgCreateParameterArray, cgDestroyParameter, cgConnectParameter perl v5.10.0 Cg Toolkit 3.0 81 cgCreatePass(3) Cg Core Runtime API cgCreatePass(3) NAME cgCreatePass − create a pass in a technique SYNOPSIS #include CGpass cgCreatePass( CGtechnique tech, const char * name ); PARAMETERS tech The technique to which the new pass will be added. name The name of the new pass. RETURN VALUES Returns the handle to the new pass on success. Returns NULL if an error occurs. DESCRIPTION cgCreatePass adds a new pass to the specified technique. EXAMPLES to-be-written ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. HISTORY cgCreatePass was introduced in Cg 1.5. SEE ALSO cgCreateTechnique perl v5.10.0 Cg Toolkit 3.0 82 cgCreatePassAnnotation(3) Cg Core Runtime API cgCreatePassAnnotation(3) NAME cgCreatePassAnnotation − create an annotation in a pass SYNOPSIS #include CGannotation cgCreatePassAnnotation( CGpass pass, const char * name, CGtype type ); PARAMETERS pass The pass to which the new annotation will be added. name The name of the new annotation. type The type of the new annotation. RETURN VALUES Returns the new CGannotation handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreatePassAnnotation adds a new annotation to a pass. EXAMPLES /* create a float annotation named "Apple" for CGpass pass */ CGannotation ann = cgCreatePassAnnotation( pass, "Apple", CG_FLOAT ); ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. CG_DUPLICATE_NAME_ERROR is generated if name is already used by an annotation for this pass. CG_INVALID_ENUMERANT_ERROR is generated if type is not CG_INT, CG_FLOAT, CG_BOOL, or CG_STRING. HISTORY cgCreatePassAnnotation was introduced in Cg 1.5. SEE ALSO cgGetNamedPassAnnotation, cgGetFirstPassAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 83 cgCreateProgram(3) Cg Core Runtime API cgCreateProgram(3) NAME cgCreateProgram − create a program object from a string SYNOPSIS #include 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. perl v5.10.0 Cg Toolkit 3.0 84 cgCreateProgram(3) Cg Core Runtime API cgCreateProgram(3) HISTORY cgCreateProgram was introduced in Cg 1.1. SEE ALSO cgCreateContext, cgCreateProgramFromFile, cgDestroyProgram, cgGetProgramString perl v5.10.0 Cg Toolkit 3.0 85 cgCreateProgramAnnotation(3) Cg Core Runtime API cgCreateProgramAnnotation(3) NAME cgCreateProgramAnnotation − create an annotation in a program SYNOPSIS #include CGannotation cgCreateProgramAnnotation( CGprogram program, const char * name, CGtype type ); PARAMETERS program The program to which the new annotation will be added. name The name of the new annotation. type The type of the new annotation. RETURN VALUES Returns the new CGannotation handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreateProgramAnnotation adds a new annotation to a program. EXAMPLES /* create a float annotation named "Apple" for CGprogram prog */ CGannotation ann = cgCreateProgramAnnotation( prog, "Apple", CG_FLOAT ); ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_DUPLICATE_NAME_ERROR is generated if name is already used by an annotation for this program. CG_INVALID_ENUMERANT_ERROR is generated if type is not CG_INT, CG_FLOAT, CG_BOOL, or CG_STRING. HISTORY cgCreateProgramAnnotation was introduced in Cg 1.5. SEE ALSO cgGetNamedProgramAnnotation, cgGetFirstProgramAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 86 cgCreateProgramFromEffect(3) Cg Core Runtime API cgCreateProgramFromEffect(3) NAME cgCreateProgramFromEffect − create a program object from an effect SYNOPSIS #include CGprogram cgCreateProgramFromEffect( CGeffect effect, CGprofile profile, const char * entry, const char ** args ); PARAMETERS effect The effect containing the program source code from which to create the program. 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 cgCreateProgramFromEffect generates a new CGprogram object and adds it to the effect’s Cg context. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_UNKNOWN_PROFILE_ERROR is generated if profile is not a supported profile. CG_COMPILER_ERROR is generated if compilation fails. HISTORY cgCreateProgramFromEffect was introduced in Cg 1.4. SEE ALSO cgCreateProgram, cgCreateProgramFromFile perl v5.10.0 Cg Toolkit 3.0 87 cgCreateProgramFromFile(3) Cg Core Runtime API cgCreateProgramFromFile(3) NAME cgCreateProgramFromFile − create a program object from a file SYNOPSIS #include 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 containing 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 cgCreateProgramFromFile generates a new CGprogram object and adds it to the specified Cg context. EXAMPLES CGcontext context = cgCreateContext(); CGprogram program = cgCreateProgramFromFile(context, CG_SOURCE, mysourcefilename, 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. perl v5.10.0 Cg Toolkit 3.0 88 cgCreateProgramFromFile(3) Cg Core Runtime API cgCreateProgramFromFile(3) HISTORY cgCreateProgramFromFile was introduced in Cg 1.1. SEE ALSO cgCreateContext, cgCreateProgram, cgCreateProgramFromEffect, cgGetProgramString perl v5.10.0 Cg Toolkit 3.0 89 cgCreateSamplerState(3) Cg Core Runtime API cgCreateSamplerState(3) NAME cgCreateSamplerState − create a sampler state definition SYNOPSIS #include CGstate cgCreateSamplerState( CGcontext context, const char * name, CGtype type ); PARAMETERS context The context in which to define the new sampler state. name The name of the new sampler state. type The type of the new sampler state. RETURN VALUES Returns a handle to the newly created CGstate. Returns NULL if there is an error. DESCRIPTION cgCreateSamplerState adds a new sampler state definition to the context. When an effect file is added to the context, all state in sampler_state blocks must have already been defined via a call to cgCreateSamplerState or cgCreateArraySamplerState. Applications will typically call cgSetStateCallbacks shortly after creating a new state with cgCreateSamplerState. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_PARAMETER_ERROR is generated if name is NULL or not a valid identifier, or if type is not a simple scalar, vector, or matrix-type. Array-typed state should be created with cgCreateArrayState. HISTORY cgCreateSamplerState was introduced in Cg 1.4. SEE ALSO cgCreateArraySamplerState, cgGetStateName, cgCreateSamplerStateAssignment, cgGLRegisterStates perl v5.10.0 Cg Toolkit 3.0 cgGetStateType, cgIsState, 90 cgCreateSamplerStateAssignment(3) Cg Core Runtime API cgCreateSamplerStateAssignment(3) NAME cgCreateSamplerStateAssignment − create a sampler state assignment SYNOPSIS #include CGstateassignment cgCreateSamplerStateAssignment( CGparameter param, CGstate state ); PARAMETERS param The sampler parameter to which the new state assignment will be associated. state The state for which to create the new state assignment. RETURN VALUES Returns the handle to the created sampler state assignment. DESCRIPTION cgCreateSamplerStateAssignment creates a new state assignment for the given state and sampler parameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state. HISTORY cgCreateSamplerStateAssignment was introduced in Cg 1.5. SEE ALSO cgCreateTechnique, cgCreateStateAssignment, cgCreateSamplerState perl v5.10.0 Cg Toolkit 3.0 91 cgCreateState(3) Cg Core Runtime API cgCreateState(3) NAME cgCreateState − create a state definition SYNOPSIS #include CGstate cgCreateState( CGcontext context, const char * name, CGtype type ); PARAMETERS context The context in which to define the new state. name The name of the new state. type The type of the new state. RETURN VALUES Returns a handle to the newly created CGstate. Returns NULL if there is an error. DESCRIPTION cgCreateState adds a new state definition to the context. When a CgFX file is added to the context, all state assignments in the file must have already been defined via a call to cgCreateState or cgCreateArrayState. Applications will typically call cgSetStateCallbacks shortly after creating a new state with cgCreateState. EXAMPLES Example callback functions for a state to register: CGbool foo_set( CGstateassignment sa ) { int nVals = 0; const CGbool *val = cgGetBoolStateAssignmentValues( sa, &nVals ); printf( "\nFooState set called with value %d.\n", *val ); return CG_TRUE; } CGbool foo_reset( CGstateassignment sa ) { printf( "\nFooState reset called.\n" ); return CG_TRUE; } CGbool foo_validate( CGstateassignment sa ) { printf( "FooState validate called.\n" ); return CG_TRUE; } Registering the state: // Create and register new state FooState CGstate fooState = cgCreateState( myCgContext, "FooState", CG_BOOL ); cgSetStateCallbacks( fooState, foo_set, foo_reset, foo_validate ); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_PARAMETER_ERROR is generated if name is NULL or not a valid identifier, or if type is not a simple scalar, vector, or matrix-type. Array-typed state should be created with cgCreateArrayState. perl v5.10.0 Cg Toolkit 3.0 92 cgCreateState(3) Cg Core Runtime API cgCreateState(3) HISTORY cgCreateState was introduced in Cg 1.4. SEE ALSO cgCreateArrayState, cgGetStateContext, cgGetStateName, cgGetStateType, cgIsState, cgSetStateCallbacks, cgGLRegisterStates, cgD3D9RegisterStates, cgCreateContext perl v5.10.0 Cg Toolkit 3.0 93 cgCreateStateAssignment(3) Cg Core Runtime API cgCreateStateAssignment(3) NAME cgCreateStateAssignment − create a state assignment SYNOPSIS #include CGstateassignment cgCreateStateAssignment( CGpass pass, CGstate state ); PARAMETERS pass The pass in which to create the state assignment. state The state used to create the state assignment. RETURN VALUES Returns the handle to the created state assignment. Returns NULL if an error occurs. DESCRIPTION cgCreateStateAssignment creates a state assignment for the specified pass. The new state assignment is appended to the pass’ existing list of state assignments. If the state is actually a state array, the created state assignment is created for array index zero. Use cgCreateStateAssignmentIndex to create state assignments for other indices of an array state. EXAMPLES /* Procedurally create state assignment equivalent to */ /* "BlendFunc = { SrcAlpha, OneMinusSrcAlpha };" */ CGstate blendFuncState = cgGetNamedState(context, "BlendFunc"); CGstateassignment blendFuncSA = cgCreateStateAssignment(pass, blendFuncState); static const int blendFuncConfig[2] = { GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; cgSetIntArrayStateAssignment(blendFuncSA, blendFuncConfig); /* Procedurally create state assignment equivalent to */ /* "BlendEnable = true;" */ CGstate blendEnableState = cgGetNamedState(context, "BlendEnable"); CGstateassignment blendEnableSA = cgCreateStateAssignment(pass, blendEnableState); cgSetBoolStateAssignment(blendEnableSA, CG_TRUE); ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state. HISTORY cgCreateStateAssignment was introduced in Cg 1.5. SEE ALSO cgCreateTechnique, cgCreateSamplerStateAssignment, cgCreateState, cgCreateStateAssignmentIndex perl v5.10.0 Cg Toolkit 3.0 94 cgCreateStateAssignmentIndex(3) Cg Core Runtime API cgCreateStateAssignmentIndex(3) NAME cgCreateStateAssignmentIndex − create a state assignment for a state array SYNOPSIS #include CGstateassignment cgCreateStateAssignmentIndex( CGpass pass, CGstate state, int index ); PARAMETERS pass The pass in which to create the state assignment. state The state array used to create the state assignment. index The index for the state array. RETURN VALUES Returns the new state assignment handle. Returns NULL if an error occurs. DESCRIPTION cgCreateStateAssignmentIndex creates a state assignment for the specified pass. The new state assignment is appended to the pass’s existing list of state assignments. The state assignment is for the given index of for the specified array state. EXAMPLES This example shows how to create a state assignment for enabling light 5: /* Procedurally create state assignment equivalent to */ /* "LightEnable[5] = 1;" */ CGstate lightEnableState = cgGetNamedState(context, "LightEnable"); CGstateassignment light5sa = cgCreateStateAssignmentIndex(pass, lightEnableState , 5); cgSetBoolStateAssignment(light5sa, CG_TRUE); ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state. If the index is negative or index is greater than or equal the number of elements for the state array, no error is generated but NULL is returned. HISTORY cgCreateStateAssignmentIndex was introduced in Cg 1.5. SEE ALSO cgGetStateAssignmentIndex, cgCreateStateAssignment perl v5.10.0 cgCreateTechnique, cgCreateSamplerStateAssignment, Cg Toolkit 3.0 cgCreateState, 95 cgCreateTechnique(3) Cg Core Runtime API cgCreateTechnique(3) NAME cgCreateTechnique − create a technique in an effect SYNOPSIS #include CGtechnique cgCreateTechnique( CGeffect effect, const char * name ); PARAMETERS effect The effect to which the new technique will be added. name The name for the new technique. RETURN VALUES Returns the handle to the new technique on success. Returns NULL if an error occurs. DESCRIPTION cgCreateTechnique adds a new technique to the specified effect. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgCreateTechnique was introduced in Cg 1.5. SEE ALSO cgIsTechnique, cgCreatePass, cgCreateEffectParameterMultiDimArray perl v5.10.0 cgCreateEffectParameter, Cg Toolkit 3.0 cgCreateEffectParameterArray, 96 cgCreateTechniqueAnnotation(3) Cg Core Runtime API cgCreateTechniqueAnnotation(3) NAME cgCreateTechniqueAnnotation − create a technique annotation SYNOPSIS #include CGannotation cgCreateTechniqueAnnotation( CGtechnique tech, const char * name, CGtype type ); PARAMETERS tech The technique to which the new annotation will be added. name The name of the new annotation. type The type of the new annotation. RETURN VALUES Returns the new CGannotation handle on success. Returns NULL if an error occurs. DESCRIPTION cgCreateTechniqueAnnotation adds a new annotation to the technique. EXAMPLES /* create a float annotation named "Apple" for CGtechnique technique */ CGannotation ann = cgCreateTechniqueAnnotation( tech, "Apple", CG_FLOAT ); ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. CG_DUPLICATE_NAME_ERROR is generated if name is already used by an annotation for this technique. CG_INVALID_ENUMERANT_ERROR is generated if type is not CG_INT, CG_FLOAT, CG_BOOL, or CG_STRING. HISTORY cgCreateTechniqueAnnotation was introduced in Cg 1.5. SEE ALSO cgGetNamedTechniqueAnnotation, cgGetFirstTechniqueAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 97 cgDestroyBuffer(3) Cg Core Runtime API cgDestroyBuffer(3) NAME cgDestroyBuffer − delete a buffer SYNOPSIS #include void cgDestroyBuffer( CGbuffer buffer ); PARAMETERS buffer The buffer to delete. RETURN VALUES None. DESCRIPTION cgDestroyBuffer deletes a buffer. The buffer object is not actually destroyed until no more programs are bound to the buffer object and any pending use of the buffer has completed. However, the handle buffer no longer refers to the buffer object (although it may be subsequently allocated to a different created resource). EXAMPLES cgDestroyBuffer( myBuffer ); ERRORS CG_INVALID_BUFFER_HANDLE_ERROR is generated if buffer is not a valid buffer. HISTORY cgDestroyBuffer was introduced in Cg 2.0. SEE ALSO cgCreateBuffer, cgGLCreateBuffer perl v5.10.0 Cg Toolkit 3.0 98 cgDestroyContext(3) Cg Core Runtime API cgDestroyContext(3) NAME cgDestroyContext − destroy a context SYNOPSIS #include void cgDestroyContext( CGcontext context ); PARAMETERS context The context to be deleted. RETURN VALUES None. DESCRIPTION cgDestroyContext deletes a Cg context object and all the programs it contains. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgDestroyContext was introduced in Cg 1.1. SEE ALSO cgCreateContext perl v5.10.0 Cg Toolkit 3.0 99 cgDestroyEffect(3) Cg Core Runtime API cgDestroyEffect(3) NAME cgDestroyEffect − destroy an effect SYNOPSIS #include void cgDestroyEffect( CGeffect effect ); PARAMETERS effect The effect object to delete. RETURN VALUES None. DESCRIPTION cgDestroyEffect removes the specified effect object and all its associated data. Any CGeffect handles that reference this effect will become invalid after the effect is deleted. Likewise, all techniques, passes, and parameters contained in the effect also become invalid after the effect is destroyed. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgDestroyEffect was introduced in Cg 1.4. SEE ALSO cgCreateEffect, cgCreateEffectFromFile perl v5.10.0 Cg Toolkit 3.0 100 cgDestroyObj(3) Cg Core Runtime API cgDestroyObj(3) NAME cgDestroyObj − destroy an obj SYNOPSIS #include void cgDestroyObj( CGobj obj ); PARAMETERS obj The object to delete. RETURN VALUES None. DESCRIPTION cgDestroyObj removed the specified object and all its associated data. EXAMPLES CGcontext ctx = cgCreateContext(); CGobj structObj = cgCreateObj(ctx, CG_SOURCE, src, CG_PROFILE_ARBVP1, NULL); // Use obj, then ... cgDestroyObj( structObj ); ERRORS CG_INVALID_OBJ_HANDLE_ERROR is generated if obj is not a valid object handle. HISTORY cgDestroyObj was introduced in Cg 2.0. SEE ALSO cgCreateObj, cgCreateObjFromFile perl v5.10.0 Cg Toolkit 3.0 101 cgDestroyParameter(3) Cg Core Runtime API cgDestroyParameter(3) NAME cgDestroyParameter − destroy a parameter SYNOPSIS #include void cgDestroyParameter( CGparameter param ); PARAMETERS param The parameter to destroy. RETURN VALUES None. DESCRIPTION cgDestroyParameter destroys parameters created with cgCreateParameter, cgCreateParameterArray, or cgCreateParameterMultiDimArray. Upon destruction, param will become invalid. Any connections (see cgConnectParameter) in which param is the destination parameter will be disconnected. An error will be thrown if param is a source parameter in any connections. The parameter being destroyed may not be one of the children parameters of a struct or array parameter. In other words it must be a CGparameter returned by one of the cgCreateParameter family of entry points. EXAMPLES CGcontext context = cgCreateContext(); CGparameter floatParam = cgCreateParameter(context, CG_FLOAT); CGparameter floatParamArray = cgCreateParameterArray(context, CG_FLOAT, 5); /* ... */ cgDestroyParameter(floatParam); cgDestroyParameter(floatParamArray); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_NOT_ROOT_PARAMETER_ERROR is generated if the param isn’t the top-level parameter of a struct or array that was created. CG_PARAMETER_IS_NOT_SHARED_ERROR is generated if param does not refer to a parameter created by one of the cgCreateParameter family of entry points. CG_CANNOT_DESTROY_PARAMETER_ERROR is generated if param is a source parameter in a connection made by cgConnectParameter. cgDisconnectParameter should be used before calling cgDestroyParameter in such a case. HISTORY cgDestroyParameter was introduced in Cg 1.2. SEE ALSO cgCreateParameter, cgCreateParameterArray, cgCreateParameterMultiDimArray perl v5.10.0 Cg Toolkit 3.0 102 cgDestroyProgram(3) Cg Core Runtime API cgDestroyProgram(3) NAME cgDestroyProgram − destroy a program SYNOPSIS #include void cgDestroyProgram( CGprogram program ); PARAMETERS program The program object to delete. RETURN VALUES None. DESCRIPTION cgDestroyProgram removes the specified program object and all its associated data. Any CGprogram variables that reference this program will become invalid after the program is deleted. Likewise, any objects contained by this program (e.g. CGparameter objects) will also become invalid after the program is deleted. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgDestroyProgram was introduced in Cg 1.1. SEE ALSO cgCreateProgram, cgCreateProgramFromFile perl v5.10.0 Cg Toolkit 3.0 103 cgDisconnectParameter(3) Cg Core Runtime API cgDisconnectParameter(3) NAME cgDisconnectParameter − disconnects two parameters SYNOPSIS #include void cgDisconnectParameter( CGparameter param ); PARAMETERS param The destination parameter in the connection that will be disconnected. RETURN VALUES None. DESCRIPTION cgDisconnectParameter disconnects an existing connection made with cgConnectParameter between two parameters. Since a given parameter can only be connected to one source parameter, only the destination parameter is required as an argument to cgDisconnectParameter. If the type of param is an interface and the struct connected to it implements the interface, any subparameters created by the connection will also be destroyed. See cgConnectParameter for more information. EXAMPLES CGparameter timeParam = cgGetNamedParameter(program, "time"); CGparameter sharedTime = cgCreateParameter(context, cgGetParameterType(timeParam)); cgConnectParameter(sharedTime, timeParam); /* ... */ cgDisconnectParameter(timeParam); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgDisconnectParameter was introduced in Cg 1.2. SEE ALSO cgGetConnectedParameter, cgGetConnectedToParameter, cgConnectParameter perl v5.10.0 Cg Toolkit 3.0 104 cgEvaluateProgram(3) Cg Core Runtime API cgEvaluateProgram(3) NAME cgEvaluateProgram − evaluates a Cg program on the CPU SYNOPSIS #include void cgEvaluateProgram( CGprogram program, float * buf, int ncomps, int nx, int ny, int nz ); PARAMETERS program The program to be evalutated. buf Buffer in which to store the results of program evaluation. ncomps Number of components to store for each returned program value. nx Number of points at which to evaluate the program in the x direction. ny Number of points at which to evaluate the program in the y direction. nz Number of points at which to evaluate the program in the z direction. RETURN VALUES None. DESCRIPTION cgEvaluateProgram evaluates a Cg program at a set of regularly spaced points in one, two, or three dimensions. The program must have been compiled with the CG_PROFILE_GENERIC profile. The value returned from the program via the COLOR semantic is stored in the given buffer for each evaluation point, and any varying parameters to the program with POSITION semantic take on the (x,y,z) position over the range zero to one at which the program is evaluated at each point. The PSIZE semantic can be used to find the spacing between evaluating points. The total size of buf should be equal to ncomps*nx*ny*nz. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_PROFILE_ERROR is generated if program’s profile is not CG_PROFILE_GENERIC. CG_INVALID_PARAMETER_ERROR is generated if buf is NULL, any of nx, ny, or nz is less than zero, or ncomps is not 0, 1, 2, or 3. HISTORY cgEvaluateProgram was introduced in Cg 1.4. SEE ALSO cgCreateProgram, cgCreateProgramFromFile, cgCreateProgramFromEffect, cgGetProgramProfile perl v5.10.0 Cg Toolkit 3.0 105 cgGetAnnotationName(3) Cg Core Runtime API cgGetAnnotationName(3) NAME cgGetAnnotationName − get an annotation’s name SYNOPSIS #include const char * cgGetAnnotationName( CGannotation ann ); PARAMETERS ann The annotation from which to get the name. RETURN VALUES Returns the NULL-terminated name string for the annotation. Returns NULL if ann is invalid. DESCRIPTION cgGetAnnotationName allows the application to retrieve the name of a annotation. This name can be used later to retrieve the annotation using cgGetNamedPassAnnotation, cgGetNamedParameterAnnotation, cgGetNamedTechniqueAnnotation, or cgGetNamedProgramAnnotation. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. HISTORY cgGetAnnotationName was introduced in Cg 1.4. SEE ALSO cgGetNamedPassAnnotation, cgGetNamedParameterAnnotation, cgGetNamedProgramAnnotation perl v5.10.0 Cg Toolkit 3.0 cgGetNamedTechniqueAnnotation, 106 cgGetAnnotationType(3) Cg Core Runtime API cgGetAnnotationType(3) NAME cgGetAnnotationType − get an annotation’s type SYNOPSIS #include CGtype cgGetAnnotationType( CGannotation ann ); PARAMETERS ann The annotation from which to get the type. RETURN VALUES Returns the type enumerant of ann. Returns CG_UNKNOWN_TYPE if an error occurs. DESCRIPTION cgGetAnnotationType allows the application to retrieve the type of an annotation in a Cg effect. cgGetAnnotationType will return CG_STRUCT if the annotation is a struct and CG_ARRAY if the annotation is an array. Otherwise it will return the data type associated with the annotation. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. HISTORY cgGetAnnotationType was introduced in Cg 1.4. SEE ALSO cgGetType, cgGetTypeString perl v5.10.0 Cg Toolkit 3.0 107 cgGetArrayDimension(3) Cg Core Runtime API cgGetArrayDimension(3) NAME cgGetArrayDimension − get the dimension of an array parameter SYNOPSIS #include int cgGetArrayDimension( CGparameter param ); PARAMETERS param The array parameter handle. RETURN VALUES Returns the dimension of param if param references an array. Returns 0 otherwise. DESCRIPTION cgGetArrayDimension returns the dimension of the array specified by param. cgGetArrayDimension is used when inspecting an array parameter in a program. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_ARRAY_PARAM_ERROR is generated if param is not an array parameter. HISTORY cgGetArrayDimension was introduced in Cg 1.1. SEE ALSO cgGetArraySize, cgCreateParameterArray, cgCreateParameterMultiDimArray perl v5.10.0 Cg Toolkit 3.0 108 cgGetArrayParameter(3) Cg Core Runtime API cgGetArrayParameter(3) NAME cgGetArrayParameter − get a parameter from an array SYNOPSIS #include CGparameter cgGetArrayParameter( CGparameter param, int index ); PARAMETERS param The array parameter handle. index The index into the array. RETURN VALUES Returns the parameter at the specified index of param if param references an array, and the index is valid. Returns NULL otherwise. DESCRIPTION cgGetArrayParameter returns the parameter of array param specified by index. cgGetArrayParameter is used when inspecting elements of an array parameter in a program. EXAMPLES CGparameter array = ...; /* some array parameter */ int array_size = cgGetArraySize( array ); for(i=0; i < array_size; ++i) { CGparameter element = cgGetArrayParameter(array, i); /* Do stuff with element */ } ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_ARRAY_PARAM_ERROR is generated if param is not an array parameter. CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is outside the bounds of param. HISTORY cgGetArrayParameter was introduced in Cg 1.1. SEE ALSO cgGetArrayDimension, cgGetArraySize, cgGetParameterType perl v5.10.0 Cg Toolkit 3.0 109 cgGetArraySize(3) Cg Core Runtime API cgGetArraySize(3) NAME cgGetArraySize − get the size of one dimension of an array parameter SYNOPSIS #include int cgGetArraySize( CGparameter param, int dimension ); PARAMETERS param The array parameter handle. dimension The array dimension whose size will be returned. RETURN VALUES Returns the size of param if param is an array. Returns 0 if param is not an array, or an error occurs. DESCRIPTION cgGetArraySize returns the size of the given dimension of the array specified by param. cgGetArraySize is used when inspecting an array parameter in a program. EXAMPLES /* Compute the number of elements in an array, in the */ /* style of cgGetArrayTotalSize(param) */ int elements = cgGetArraySize(param, 0); if (elements>0) { int dim = cgGetArrayDimension(param); for (int i = 1; i < dim; i++) { elements *= cgGetArraySize(param, i); } } ERRORS CG_INVALID_DIMENSION_ERROR is generated if dimension is less than 0. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetArraySize was introduced in Cg 1.1. SEE ALSO cgGetArrayTotalSize, cgGetArrayDimension, cgGetArrayParameter, cgGetMatrixSize, cgGetTypeSizes perl v5.10.0 Cg Toolkit 3.0 110 cgGetArrayTotalSize(3) Cg Core Runtime API cgGetArrayTotalSize(3) NAME cgGetArrayTotalSize − get the total size of an array parameter SYNOPSIS #include int cgGetArrayTotalSize( CGparameter param ); PARAMETERS param The array parameter handle. RETURN VALUES Returns the total size of param if pararm is an array. Returns 0 if param is not an array, or if an error occurs. DESCRIPTION cgGetArrayTotalSize returns the total number of elements of the array specified by param. The total number of elements is equal to the product of the size of each dimension of the array. EXAMPLES Given a handle to a parameter declared as: float2x3 array[6][1][4]; cgGetArrayTotalSize will return 24. ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetArrayTotalSize was introduced in Cg 1.4. SEE ALSO cgGetArraySize, cgGetArrayDimension, cgGetArrayParameter perl v5.10.0 Cg Toolkit 3.0 111 cgGetArrayType(3) Cg Core Runtime API cgGetArrayType(3) NAME cgGetArrayType − get the type of an array parameter SYNOPSIS #include CGtype cgGetArrayType( CGparameter param ); PARAMETERS param The array parameter handle. RETURN VALUES Returns the the type of the inner most array. Returns CG_UNKNOWN_TYPE if an error occurs. DESCRIPTION cgGetArrayType returns the type of the members of an array. If the given array is multi-dimensional, it will return the type of the members of the inner most array. EXAMPLES CGcontext context = cgCreateContext(); CGparameter array = cgCreateParameterArray(context, CG_FLOAT, 5); CGtype arrayType = cgGetArrayType(array); /* This will return CG_FLOAT */ ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_ARRAY_PARAM_ERROR is generated if param is not an array parameter. HISTORY cgGetArrayType was introduced in Cg 1.2. SEE ALSO cgGetArraySize, cgGetArrayDimension perl v5.10.0 Cg Toolkit 3.0 112 cgGetAutoCompile(3) Cg Core Runtime API cgGetAutoCompile(3) NAME cgGetAutoCompile − get the auto-compile enumerant for a context SYNOPSIS #include CGenum cgGetAutoCompile( CGcontext context ); PARAMETERS context The context. RETURN VALUES Returns the auto-compile enumerant for context. Returns CG_UNKNOWN if context is not a valid context. DESCRIPTION cgGetAutoCompile returns the auto-compile enumerant for context. See cgSetAutoCompile for more information. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetAutoCompile was introduced in Cg 1.4. SEE ALSO cgSetAutoCompile perl v5.10.0 Cg Toolkit 3.0 113 cgGetBehavior(3) Cg Core Runtime API cgGetBehavior(3) NAME cgGetBehavior − get the behavior enumerant from a behavior name SYNOPSIS #include CGbehavior cgGetBehavior( const char * behavior_string ); PARAMETERS behavior_string A string containing the case-sensitive behavior name. RETURN VALUES Returns the behavior enumerant associated with behavior_string. Returns CG_BEHAVIOR_UNKNOWN if behavior_string is NULL or if no CGbehavior is associated with the given string. DESCRIPTION cgGetBehavior returns the enumerant assigned to a behavior name. EXAMPLES CGbehavior b = cgGetBehavior("latest"); /* b == CG_BEHAVIOR_LATEST */ ERRORS CG_INVALID_PARAMETER_ERROR is generated if behavior_string is NULL. HISTORY cgGetBehavior was introduced in Cg 3.0. SEE ALSO cgGetBehaviorString, cgGetContextBehavior, cgSetContextBehavior perl v5.10.0 Cg Toolkit 3.0 114 cgGetBehaviorString(3) Cg Core Runtime API cgGetBehaviorString(3) NAME cgGetBehaviorString − get the behavior name associated with a behavior enumerant SYNOPSIS #include const char * cgGetBehaviorString( CGbehavior behavior ); PARAMETERS behavior The behavior enumerant. RETURN VALUES Returns the behavior string associated with behavior. Returns NULL if behavior is not a valid CGbehavior. DESCRIPTION cgGetBehaviorString returns the behavior name associated with a given behavior enumerant. EXAMPLES static void dumpCgContextInfo(CGcontext context) { const char* p = cgGetBehaviorString(cgGetContextBehavior(context)); if ( p ) { printf(" Behavior: %s\n", p ); } /* ... */ } ERRORS None. HISTORY cgGetBehaviorString was introduced in Cg 3.0. SEE ALSO cgGetBehavior, cgGetContextBehavior, cgSetContextBehavior perl v5.10.0 Cg Toolkit 3.0 115 cgGetBoolAnnotationValues(3) Cg Core Runtime API cgGetBoolAnnotationValues(3) NAME cgGetBoolAnnotationValues − get the values from a boolean-valued annotation SYNOPSIS #include const CGbool * cgGetBoolAnnotationValues( CGannotation ann, int * nvalues ); PARAMETERS ann The annotation. nvalues Pointer to integer where the number of returned values will be stored. RETURN VALUES Returns a pointer to an array of CGbool values. The number of values in the array is returned via the nvalues parameter. Returns NULL if no values are available. nvalues will be 0. DESCRIPTION cgGetBoolAnnotationValues allows the application to retrieve the value(s) of a boolean typed annotation. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. CG_INVALID_PARAMETER_ERROR is generated if nvalues is NULL. HISTORY cgGetBoolAnnotationValues was introduced in Cg 1.5. SEE ALSO cgGetAnnotationType, cgGetStringAnnotationValue perl v5.10.0 cgGetFloatAnnotationValues, Cg Toolkit 3.0 cgGetIntAnnotationValues, 116 cgGetBoolStateAssignmentValues(3) Cg Core Runtime API cgGetBoolStateAssignmentValues(3) NAME cgGetBoolStateAssignmentValues − get the values from a bool-valued state assignment SYNOPSIS #include const CGbool * cgGetBoolStateAssignmentValues( CGstateassignment sa, int * nvalues ); PARAMETERS sa The state assignment. nvalues Pointer to integer where the number of returned values will be stored. RETURN VALUES Returns a pointer to an array of CGbool values. The number of values in the array is returned via the nvalues parameter. Returns NULL if an error occurs or if no values are available. nvalues will be 0 in the latter case. DESCRIPTION cgGetBoolStateAssignmentValues allows the application to retrieve the value(s) of a boolean typed state assignment. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_INVALID_PARAMETER_ERROR is generated if nvalues is NULL. CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR is generated if sa is not a state assignment of a bool type. HISTORY cgGetBoolStateAssignmentValues was introduced in Cg 1.4. SEE ALSO cgGetStateAssignmentState, cgGetStateType, cgGetFloatStateAssignmentValues, cgGetIntStateAssignmentValues, cgGetStringStateAssignmentValue, cgGetProgramStateAssignmentValue, cgGetSamplerStateAssignmentValue, cgGetTextureStateAssignmentValue perl v5.10.0 Cg Toolkit 3.0 117 cgGetBooleanAnnotationValues(3) Cg Core Runtime API cgGetBooleanAnnotationValues(3) NAME cgGetBooleanAnnotationValues − deprecated DESCRIPTION cgGetBooleanAnnotationValues is deprecated. Use cgGetBoolAnnotationValues instead. SEE ALSO cgGetBoolAnnotationValues perl v5.10.0 Cg Toolkit 3.0 118 cgGetBufferSize(3) Cg Core Runtime API cgGetBufferSize(3) NAME cgGetBufferSize − get the size of a buffer SYNOPSIS #include int cgGetBufferSize( CGbuffer buffer ); PARAMETERS buffer The buffer for which the size will be retrieved. RETURN VALUES Returns the size in bytes of buffer. Returns −1 if an error occurs. DESCRIPTION cgGetBufferSize returns the size in bytes of buffer. EXAMPLES int size = cgGetBufferSize( myBuffer ); ERRORS CG_INVALID_BUFFER_HANDLE_ERROR is generated if buffer is not a valid buffer. HISTORY cgGetBufferSize was introduced in Cg 2.0. SEE ALSO cgCreateBuffer, cgGLCreateBuffer, cgSetBufferData, cgSetBufferSubData perl v5.10.0 Cg Toolkit 3.0 119 cgGetCompilerIncludeCallback(3) Cg Core Runtime API cgGetCompilerIncludeCallback(3) NAME cgGetCompilerIncludeCallback − get the include callback function SYNOPSIS #include typedef void (*CGIncludeCallbackFunc)( CGcontext context, const char *filename ) CGIncludeCallbackFunc cgGetCompilerIncludeCallback( CGcontext context ); PARAMETERS context The context of the desired include callback function. RETURN VALUES Returns the current include callback function. Returns NULL if no callback function is set. DESCRIPTION cgGetCompilerIncludeCallback returns the current callback function used for handing include statements. EXAMPLES CGIncludeCallbackFunc includeCB = cgGetCompilerIncludeCallback(context); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetCompilerIncludeCallback was introduced in Cg 2.1. SEE ALSO cgSetCompilerIncludeCallback, cgSetCompilerIncludeString, cgSetCompilerIncludeFile perl v5.10.0 Cg Toolkit 3.0 120 cgGetConnectedParameter(3) Cg Core Runtime API cgGetConnectedParameter(3) NAME cgGetConnectedParameter − gets the connected source parameter SYNOPSIS #include CGparameter cgGetConnectedParameter( CGparameter param ); PARAMETERS param The destination parameter. RETURN VALUES Returns the connected source parameter if param is connected to one. Returns NULL otherwise. DESCRIPTION Returns the source parameter to which param is connected. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetConnectedParameter was introduced in Cg 1.2. SEE ALSO cgConnectParameter, cgDisconnectParameter, cgGetConnectedToParameter perl v5.10.0 Cg Toolkit 3.0 121 cgGetConnectedStateAssignmentParameter(3) Cg Core Runtime API cgGetConnectedStateAssignmentParameter(3) NAME cgGetConnectedStateAssignmentParameter − get effect parameter which determines a state assignment’s value SYNOPSIS #include CGparameter cgGetConnectedStateAssignmentParameter( CGstateassignment sa ); PARAMETERS sa A state assignment whose value is determined using an effect parameter. RETURN VALUES Returns the effect parameter used by sa. Returns 0 if sa is not using a parameter for its value, if the state assignment is set to an expression, or if an error occurs. DESCRIPTION cgGetConnectedStateAssignmentParameter returns the effect parameter from which a given state assignment’s value is determined. EXAMPLES /* in Effect.cgfx file */ int MyMinFilter; sampler2D Samp = sampler_state { MinFilter = MyMinFilter; }; /* in .c/.cpp file */ CGparameter sampParam = cgGetNamedEffectParameter( myEffect, "Samp" ); CGstateassignment sa = cgGetNamedSamplerStateAssignment( sampParam, "MinFilter" ); CGparameter connected = cgGetConnectedStateAssignmentParameter( sa ); ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgGetConnectedStateAssignmentParameter was introduced in Cg 2.0. SEE ALSO cgGetNamedEffectParameter, cgGetNamedSamplerStateAssignment perl v5.10.0 Cg Toolkit 3.0 122 cgGetConnectedToParameter(3) Cg Core Runtime API cgGetConnectedToParameter(3) NAME cgGetConnectedToParameter − gets a connected destination parameter SYNOPSIS #include CGparameter cgGetConnectedToParameter( CGparameter param, int index ); PARAMETERS param The source parameter. index Since there may be multiple destination (to) parameters connected to param, index is need to specify which one is returned. index must be within the range of 0 to N − 1 where N is the number of connected destination parameters. RETURN VALUES Returns one of the destination parameters connected to param. Returns NULL if an error occurs. DESCRIPTION Returns one of the destination parameters connected to param. cgGetNumConnectedToParameters should be used to determine the number of destination parameters connected to param. EXAMPLES int nParams = cgGetNumConnectedToParameters( sourceParam ); for ( int i=0; i < nParams; ++i ) { CGparameter toParam = cgGetConnectedToParameter( sourceParam, i ); /* Do stuff with toParam ... */ } ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is less than 0 or greater than or equal to the number of parameters connected to param. HISTORY cgGetConnectedToParameter was introduced in Cg 1.2. SEE ALSO cgConnectParameter, cgGetNumConnectedToParameters perl v5.10.0 Cg Toolkit 3.0 123 cgGetContextBehavior(3) Cg Core Runtime API cgGetContextBehavior(3) NAME cgGetContextBehavior − get the behavior enumerant for a context SYNOPSIS #include CGbehavior cgGetContextBehavior( CGcontext context ); PARAMETERS context The context for which the behavior enumerant will be returned. RETURN VALUES Returns the behavior enumerant for context. Returns CG_BEHAVIOR_UNKNOWN if an error occurs. DESCRIPTION cgGetContextBehavior allows the application to retrieve the behavior enumerant for a context. The valid enumerants and their meanings are described in cgSetContextBehavior. EXAMPLES /* create a context and get the default context behavior enum */ CGcontext context = cgCreateContext(); CGbehavior cb = cgGetContextBehavior(context); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetContextBehavior was introduced in Cg 3.0. SEE ALSO cgCreateContext, cgSetContextBehavior, cgGetBehavior, cgGetBehaviorString perl v5.10.0 Cg Toolkit 3.0 124 cgGetDependentAnnotationParameter(3) Cg Core Runtime API cgGetDependentAnnotationParameter(3) NAME cgGetDependentAnnotationParameter − get one of the parameters that an annotation’s value depends on SYNOPSIS #include CGparameter cgGetDependentAnnotationParameter( CGannotation ann, int index ); PARAMETERS ann The annotation handle. index The index of the parameter to return. RETURN VALUES Returns a handle to the selected dependent annotation on success. Returns NULL if an error occurs. DESCRIPTION Annotations in CgFX files may include references to one or more effect parameters on the right hand side of the annotation that are used for computing the annotation’s value. cgGetDependentAnnotationParameter returns one of these parameters, as indicated by the given index. cgGetNumDependentAnnotationParameters can be used to determine the total number of such parameters. This information can be useful for applications that wish to cache the values of annotations so that they can determine which annotations may change as the result of changing a particular parameter’s value. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is less than zero or greater than or equal to the number of dependent parameters, as returned by cgGetNumDependentAnnotationParameters. HISTORY cgGetDependentAnnotationParameter was introduced in Cg 1.4. SEE ALSO cgGetDependentStateAssignmentParameter, cgGetNumDependentAnnotationParameters perl v5.10.0 Cg Toolkit 3.0 125 cgGetDependentProgramArrayStateAssignmentParameter(3) Cg CorecgGetDependentProgramArrayStateAssignmentParameter(3) Runtime API NAME cgGetDependentProgramArrayStateAssignmentParameter − get one of the parameters that a state assignment’s value depends on SYNOPSIS #include CGparameter cgGetDependentProgramArrayStateAssignmentParameter( CGstateassignmen int index ); PARAMETERS sa The state assignment handle. index The index of the parameter to return. RETURN VALUES Returns a handle to the selected dependent parameter on success. Returns NULL if sa is not a program state assignment or an error occurs. DESCRIPTION State assignments in CgFX files may include references to an array indexed by an effect parameter (or expression) on the right hand side of the state assignment that is used for computing the state assignment’s value. Usually this array holds the compile statements of shader programs and by changing the index of the shader array, it’s possible to switch to a different program or profile on-the-fly. Each compile statement in the array can depend on one or more effect parameters which are passed to the program in its parameter list. It is sometimes necessary for the application to query what those parameters are so values can be properly set to them. cgGetDependentProgramArrayStateAssignmentParameter returns one of these parameters, as indicated by the given index. EXAMPLES /* In CgFX file */ vertexshader Torus[4] = { compile vp40 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ), compile vp30 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ), compile arbvp1 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ), compile vp20 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ) }; pixelshader SpecSurf[4] = { compile fp40 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ), compile fp30 perl v5.10.0 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ), Cg Toolkit 3.0 126 cgGetDependentProgramArrayStateAssignmentParameter(3) Cg CorecgGetDependentProgramArrayStateAssignmentParameter(3) Runtime API compile arbfp1 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ), compile fp20 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ) }; int select = 0; technique bumpdemo { pass { VertexProgram = (Torus[select]); FragmentProgram = (SpecSurf[select]); } } /* In application */ int numParameters = cgGetNumDependentProgramArrayStateAssignmentParameters(state for(int i = 0; i < numParameters; ++i) { CGparameter param = cgGetDependentProgramArrayStateAssignmentParameter(state /* Set value for 'param' */ } In the above example, assuming select = 0 and stateAssignment is for VertexProgram, the list of parameters returned from cgGetDependentProgramArrayStateAssignmentParameter would be: LightPosition, EyePosition, ModelViewProj, OuterRadius, InnerRadius. If stateAssignment was for FragmentProgram, then the list of parameters returned from cgGetDependentProgramArrayStateAssignmentParameter would be: Ambient, DiffuseMaterial, LightColor, SpecularMaterial, LightColor, normalMap, normalizeCube, normalizeCube. ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is less than zero or greater than or equal to the number of dependent parameters, as returned by cgGetNumDependentProgramArrayStateAssignmentParameters. HISTORY cgGetDependentProgramArrayStateAssignmentParameter was introduced in Cg 3.0. SEE ALSO cgGetNumDependentProgramArrayStateAssignmentParameters perl v5.10.0 Cg Toolkit 3.0 127 cgGetDependentStateAssignmentParameter(3) Cg Core Runtime API cgGetDependentStateAssignmentParameter(3) NAME cgGetDependentStateAssignmentParameter − get one of the parameters that a state assignment’s value depends on SYNOPSIS #include CGparameter cgGetDependentStateAssignmentParameter( CGstateassignment sa, int index ); PARAMETERS sa The state assignment handle. index The index of the parameter to return. RETURN VALUES Returns a handle to the selected dependent parameter on success. Returns NULL if an error occurs. DESCRIPTION State assignments in CgFX files may include references to one or more effect parameters on the right hand side of the state assignment that are used for computing the state assignment’s value. cgGetDependentStateAssignmentParameter returns one of these parameters, as indicated by the given index. cgGetNumDependentStateAssignmentParameters can be used to determine the total number of such parameters. This information can be useful for applications that wish to cache the values of annotations so that they can determine which annotations may change as the result of changing a particular parameter’s value. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is less than zero or greater than or equal to the number of dependent parameters, as returned by cgGetNumDependentStateAssignmentParameters. HISTORY cgGetDependentStateAssignmentParameter was introduced in Cg 1.4. SEE ALSO cgGetDependentAnnotationParameter, cgGetNumDependentStateAssignmentParameters perl v5.10.0 Cg Toolkit 3.0 128 cgGetDomain(3) Cg Core Runtime API cgGetDomain(3) NAME cgGetDomain − get the domain enumerant from a domain name SYNOPSIS #include CGdomain cgGetDomain( const char * domain_string ); PARAMETERS domain_string A string containing the case-sensitive domain name. RETURN VALUES Returns the domain enumerant of domain_string. Returns CG_UNKNOWN if the given domain does not exist. DESCRIPTION cgGetDomain returns the enumerant assigned to a domain name. EXAMPLES CGdomain ARBVP1domain = cgGetDomain("arbvp1"); if(cgGetProgramDomain(myprog) == ARBVP1Domain) { /* Do stuff */ } ERRORS CG_INVALID_PARAMETER_ERROR is generated if domain_string is NULL. HISTORY cgGetDomain was introduced in Cg 2.2. SEE ALSO cgGetDomainString, cgGetProgramDomain perl v5.10.0 Cg Toolkit 3.0 129 cgGetDomainString(3) Cg Core Runtime API cgGetDomainString(3) NAME cgGetDomainString − get the domain name associated with a domain enumerant SYNOPSIS #include const char * cgGetDomainString( CGdomain domain ); PARAMETERS domain The domain enumerant. RETURN VALUES Returns the domain string of the enumerant domain. Returns NULL if domain is not a valid domain. DESCRIPTION cgGetDomainString returns the domain name associated with a domain enumerant. EXAMPLES static void dumpCgProgramInfo(CGprogram program) { const char* p = cgGetDomainString(cgGetProgramDomain(program)); if ( p ) { printf(" Domain: %s\n", cgGetDomainString(cgGetProgramDomain(program))); } /* ... */ } ERRORS None. HISTORY cgGetDomainString was introduced in Cg 2.2. SEE ALSO cgGetDomain, cgGetProgramDomain perl v5.10.0 Cg Toolkit 3.0 130 cgGetEffectContext(3) Cg Core Runtime API cgGetEffectContext(3) NAME cgGetEffectContext − get a effect’s context SYNOPSIS #include CGcontext cgGetEffectContext( CGeffect effect ); PARAMETERS effect The effect. RETURN VALUES Returns the context to which effect belongs. Returns NULL if an error occurs. DESCRIPTION cgGetEffectContext allows the application to retrieve a handle to the context to which a given effect belongs. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetEffectContext was introduced in Cg 1.4. SEE ALSO cgCreateEffect, cgCreateEffectFromFile, cgCreateContext perl v5.10.0 Cg Toolkit 3.0 131 cgGetEffectName(3) Cg Core Runtime API cgGetEffectName(3) NAME cgGetEffectName − get an effect’s name SYNOPSIS #include const char * cgGetEffectName( CGeffect effect ); PARAMETERS effect The effect from which the name will be retrieved. RETURN VALUES Returns the name from the specified effect. Returns NULL if the effect doesn’t have a valid name or an error occurs. DESCRIPTION cgGetEffectName returns the name from the specified effect. EXAMPLES char *effectSource = ...; CGcontext context = cgCreateContext(); CGeffect effect = cgCreateEffect(context, effectSource, NULL); const char* myEffectName = "myEffectName"; CGbool okay = cgSetEffectName(effect, myEffectName); if (!okay) { /* handle error */ } const char* testName = cgGetEffectName(effect); if (strcmp(testName, myEffectName)) { /* shouldn't be here */ } ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetEffectName was introduced in Cg 1.5. SEE ALSO cgSetEffectName perl v5.10.0 Cg Toolkit 3.0 132 cgGetEffectParameterBuffer(3) Cg Core Runtime API cgGetEffectParameterBuffer(3) NAME cgGetEffectParameterBuffer − get the Cg buffer associated to the passed effect parameter. SYNOPSIS #include CGbuffer cgGetEffectParameterBuffer(CGparameter param) PARAMETERS param The effect parameter associated with a Cg buffer (using the BUFFER semantic) set by cgSetEffectParameterBuffer. RETURN VALUES Returns the CGbuffer object set by cgSetEffectParameterBuffer. Returns NULL if param is invalid or does not have a CGbuffer set by cgSetEffectParameterBuffer. DESCRIPTION cgGetEffectParameterBuffer returns the CGbuffer object set by cgSetEffectParameterBuffer. EXAMPLES In effect: struct Material { float4 ambient; float4 diffuse; float4 specular; float4 shine; } cbuffer0_Material : BUFFER[0]; In C/C++: CGbuffer myCgBuffer = cgCreateBuffer(...); cgSetEffectParameterBuffer(cgGetNamedEffectParameter(myCgEffect, myCgBuffer); ‘‘cbuffer0_Material’’), // ... CGbuffer buffer ‘‘cbuffer0_Material’’)); = cgGetEffectParameterBuffer(cgGetNamedEffectParameter(myCgEffect, // Now buffer == myCgBuffer ERRORS CG_INVALID_PARAMETER_ERROR is generated if param is not a valid parameter. HISTORY cgGetEffectParameterBuffer was introduced in Cg 3.0. SEE ALSO cgSetEffectParameterBuffer perl v5.10.0 Cg Toolkit 3.0 133 cgGetEffectParameterBySemantic(3) Cg Core Runtime API cgGetEffectParameterBySemantic(3) NAME cgGetEffectParameterBySemantic − get the a parameter in an effect via its semantic SYNOPSIS #include CGparameter cgGetEffectParameterBySemantic( CGeffect effect, const char * semantic ); PARAMETERS effect The effect from which to retrieve the parameter. semantic The name of the semantic. RETURN VALUES Returns the CGparameter object in effect that has the given semantic. Returns NULL if effect is invalid or does not have any parameters with the given semantic. DESCRIPTION cgGetEffectParameterBySemantic returns the parameter in an effect which is associated with the given semantic. It multiple parameters in the effect have this semantic, an arbitrary one of them will be returned. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_INVALID_PARAMETER_ERROR is generated if semantic is NULL or the empty string. HISTORY cgGetEffectParameterBySemantic was introduced in Cg 1.4. SEE ALSO cgGetNamedEffectParameter perl v5.10.0 Cg Toolkit 3.0 134 cgGetEnum(3) Cg Core Runtime API cgGetEnum(3) NAME cgGetEnum − get the enumerant assigned with the given string name SYNOPSIS #include CGenum cgGetEnum( const char * enum_string ); PARAMETERS enum_string A string containing the case-sensitive enum name. RETURN VALUES Returns the enumerant for enum_string. Returns CG_UNKNOWN if no such enumerant exists DESCRIPTION cgGetEnum returns the enumerant assigned to an enum name. EXAMPLES CGenum VaryingEnum = cgGetEnum("CG_VARYING"); ERRORS CG_INVALID_PARAMETER_ERROR is generated if enum_string is NULL. HISTORY cgGetEnum was introduced in Cg 1.2. SEE ALSO cgGetEnumString perl v5.10.0 Cg Toolkit 3.0 135 cgGetEnumString(3) Cg Core Runtime API cgGetEnumString(3) NAME cgGetEnumString − get the name string associated with an enumerant SYNOPSIS #include const char * cgGetEnumString( CGenum enum ); PARAMETERS enum The enumerant. RETURN VALUES Returns the string representation of the enumerant enum. Returns NULL if enum is not a valid Cg enumerant. DESCRIPTION cgGetEnumString returns the name string associated with an enumerant. It’s primary use to print debugging information. EXAMPLES /* This prints "CG_UNIFORM" to stdout */ const char *EnumString = cgGetEnumString(CG_UNIFORM); printf("%s\n", EnumString); ERRORS None. HISTORY cgGetEnumString was introduced in Cg 1.2. SEE ALSO cgGetEnum perl v5.10.0 Cg Toolkit 3.0 136 cgGetError(3) Cg Core Runtime API cgGetError(3) NAME cgGetError − get error condition SYNOPSIS #include CGerror cgGetError( void ); PARAMETERS None. RETURN VALUES Returns the last error condition that has occured. Returns CG_NO_ERROR if no error has occurred. DESCRIPTION cgGetError returns the last error condition that has occured. The error condition is reset after cgGetError is called. EXAMPLES CGerror err = cgGetError(); ERRORS None. HISTORY cgGetError was introduced in Cg 1.1. SEE ALSO cgSetErrorCallback, cgSetErrorHandler perl v5.10.0 Cg Toolkit 3.0 137 cgGetErrorCallback(3) Cg Core Runtime API cgGetErrorCallback(3) NAME cgGetErrorCallback − get the error callback function SYNOPSIS #include typedef void (*CGerrorCallbackFunc)( void ); CGerrorCallbackFunc cgGetErrorCallback( void ); PARAMETERS None. RETURN VALUES Returns the currently set error callback function. Returns NULL if no callback function has been set. DESCRIPTION cgGetErrorCallback returns the current error callback function. EXAMPLES CGerrorCallbackFunc errorCB = cgGetErrorCallback(); ERRORS None. HISTORY cgGetErrorCallback was introduced in Cg 1.1. SEE ALSO cgSetErrorCallback perl v5.10.0 Cg Toolkit 3.0 138 cgGetErrorHandler(3) Cg Core Runtime API cgGetErrorHandler(3) NAME cgGetErrorHandler − get the error handler callback function SYNOPSIS #include typedef void (*CGerrorHandlerFunc)( CGcontext context, CGerror error, void * appdata ); CGerrorHandlerFunc cgGetErrorHandler( void ** appdataptr ); PARAMETERS appdataptr A pointer for an application provided data pointer. RETURN VALUES Returns the current error handler callback function. Returns NULL if no callback function is set. If appdataptr is not NULL then the current appdata pointer will be copied into the location pointed to by appdataptr. DESCRIPTION cgGetErrorHandler returns the current error handler callback function and application provided data pointer. EXAMPLES void * appdata = NULL; CGerrorHandlerFunc errorHandler = cgGetErrorHandler( &appdata ); ERRORS None. HISTORY cgGetErrorHandler was introduced in Cg 1.4. SEE ALSO cgSetErrorHandler perl v5.10.0 Cg Toolkit 3.0 139 cgGetErrorString(3) Cg Core Runtime API cgGetErrorString(3) NAME cgGetErrorString − get a human readable error string SYNOPSIS #include const char * cgGetErrorString( CGerror error ); PARAMETERS error The error condition. RETURN VALUES Returns a human readable error string for the given error condition. DESCRIPTION cgGetErrorString returns a human readable error string for the given error condition. EXAMPLES const char * pCompilerError = cgGetErrorString( CG_COMPILER_ERROR ); ERRORS None. HISTORY cgGetErrorString was introduced in Cg 1.1. SEE ALSO cgGetError perl v5.10.0 Cg Toolkit 3.0 140 cgGetFirstDependentParameter(3) Cg Core Runtime API cgGetFirstDependentParameter(3) NAME cgGetFirstDependentParameter − get the first dependent parameter from a parameter SYNOPSIS #include CGparameter cgGetFirstDependentParameter( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns a handle to the first member parameter. Returns NULL if param is not a struct or if some other error occurs. DESCRIPTION cgGetFirstDependentParameter returns the first member dependent parameter associated with a given parameter. The rest of the members may be retrieved from the first member by iterating with cgGetNextParameter. Dependent parameters are parameters that have the same name as a given parameter but different resources. They only exist in profiles that have multiple resources associated with one parameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetFirstDependentParameter was introduced in Cg 1.1. SEE ALSO cgGetNextParameter, cgGetFirstParameter perl v5.10.0 Cg Toolkit 3.0 141 cgGetFirstEffect(3) Cg Core Runtime API cgGetFirstEffect(3) NAME cgGetFirstEffect − get the first effect in a context SYNOPSIS #include CGeffect cgGetFirstEffect( CGcontext context ); PARAMETERS context The context from which to retrieve the first effect. RETURN VALUES Returns the first CGeffect object in context. Returns NULL if context contains no effects. DESCRIPTION cgGetFirstEffect is used to begin iteration over all of the effects contained by a context. See cgGetNextEffect for more information. EXAMPLES /* one or more effects have previously been loaded into context */ CGeffect effect = cgGetFirstEffect( context ); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetFirstEffect was introduced in Cg 1.4. SEE ALSO cgGetNextEffect, cgCreateEffect, cgCreateEffectFromFile, cgDestroyEffect, cgIsEffect, cgGetFirstProgram perl v5.10.0 Cg Toolkit 3.0 142 cgGetFirstEffectAnnotation(3) Cg Core Runtime API cgGetFirstEffectAnnotation(3) NAME cgGetFirstEffectAnnotation − get the first annotation in an effect SYNOPSIS #include CGannotation cgGetFirstEffectAnnotation( CGeffect effect ); PARAMETERS effect The effect from which to retrieve the first annotation. RETURN VALUES Returns the first annotation in an effect. Returns NULL if the effect has no annotations. DESCRIPTION The first annotation associated with an effect can be retrieved using cgGetFirstEffectAnnotation. The rest of the effect’s annotations can be discovered by iterating through them using cgGetNextAnnotation. EXAMPLES CGannotation ann = cgGetFirstEffectAnnotation( effect ); while( ann ) { /* do something with ann */ ann = cgGetNextAnnotation( ann ); } ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetFirstEffectAnnotation was introduced in Cg 1.5. SEE ALSO cgGetNamedEffectAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 143 cgGetFirstEffectParameter(3) Cg Core Runtime API cgGetFirstEffectParameter(3) NAME cgGetFirstEffectParameter − get the first parameter in an effect SYNOPSIS #include CGparameter cgGetFirstEffectParameter( CGeffect effect ); PARAMETERS effect The effect from which to retrieve the first parameter. RETURN VALUES Returns the first CGparameter object in effect. Returns NULL if effect is invalid or if effect does not have any parameters. DESCRIPTION The first top-level parameter in an effect can be retrieved using cgGetFirstEffectParameter. The rest of the effect’s parameters can be discovered by iterating through them using cgGetNextParameter. EXAMPLES CGparameter param = cgGetFirstEffectParameter( effect ); while( param ) { /* do something with param */ param = cgGetNextParameter( param ); } ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetFirstEffectParameter was introduced in Cg 1.4. SEE ALSO cgGetNextParameter, cgGetNamedEffectParameter perl v5.10.0 Cg Toolkit 3.0 144 cgGetFirstError(3) Cg Core Runtime API cgGetFirstError(3) NAME cgGetFirstError − get the first error condition SYNOPSIS #include CGerror cgGetFirstError( void ); PARAMETERS None. RETURN VALUES Returns the first error condition that has occured since cgGetFirstError was last called. Returns CG_NO_ERROR if no error has occurred. DESCRIPTION cgGetFirstError returns the first error condition that has occured since cgGetFirstError was previously called. EXAMPLES CGerror firstError = cgGetFirstError(); ERRORS None. HISTORY cgGetFirstError was introduced in Cg 1.4. SEE ALSO cgSetErrorHandler, cgGetError perl v5.10.0 Cg Toolkit 3.0 145 cgGetFirstLeafEffectParameter(3) Cg Core Runtime API cgGetFirstLeafEffectParameter(3) NAME cgGetFirstLeafEffectParameter − get the first leaf parameter in an effect SYNOPSIS #include CGparameter cgGetFirstLeafEffectParameter( CGeffect effect ); PARAMETERS effect The effect from which to retrieve the first leaf parameter. RETURN VALUES Returns the first leaf CGparameter object in effect. Returns NULL if effect is invalid or if effect does not have any parameters. DESCRIPTION cgGetFirstLeafEffectParameter returns the first leaf parameter in an effect. The combination of cgGetFirstLeafEffectParameter and cgGetNextLeafParameter allows the iteration through all of the parameters of basic data types (not structs or arrays) without recursion. See cgGetNextLeafParameter for more information. EXAMPLES CGparameter leaf = cgGetFirstLeafEffectParameter( effect ); while(leaf) { /* Do stuff with leaf */ leaf = cgGetNextLeafParameter( leaf ); } ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetFirstLeafEffectParameter was introduced in Cg 1.4. SEE ALSO cgGetNextLeafParameter, cgGetFirstLeafParameter perl v5.10.0 Cg Toolkit 3.0 146 cgGetFirstLeafParameter(3) Cg Core Runtime API cgGetFirstLeafParameter(3) NAME cgGetFirstLeafParameter − get the first leaf parameter in a program SYNOPSIS #include CGparameter cgGetFirstLeafParameter( CGprogram program, CGenum name_space ); PARAMETERS program name_space The program from which to retrieve the first leaf parameter. Specifies the parameter namespace through which to iterate. Currently CG_PROGRAM and CG_GLOBAL are supported. RETURN VALUES Returns the first leaf CGparameter object in program. Returns NULL if program is invalid or if program does not have any parameters. DESCRIPTION cgGetFirstLeafParameter returns the first leaf parameter in a program. The combination of cgGetFirstLeafParameter and cgGetNextLeafParameter allow the iteration through all of the parameters of basic data types (not structs or arrays) without recursion. See cgGetNextLeafParameter for more information. EXAMPLES CGparameter leaf = cgGetFirstLeafParameter( program ); while ( leaf ) { /* Do stuff with leaf */ leaf = cgGetNextLeafParameter( leaf ); } ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_ENUMERANT_ERROR CG_GLOBAL. is generated if name_space is not CG_PROGRAM or HISTORY cgGetFirstLeafParameter was introduced in Cg 1.1. SEE ALSO cgGetNextLeafParameter perl v5.10.0 Cg Toolkit 3.0 147 cgGetFirstParameter(3) Cg Core Runtime API cgGetFirstParameter(3) NAME cgGetFirstParameter − get the first parameter in a program SYNOPSIS #include CGparameter cgGetFirstParameter( CGprogram program, CGenum name_space ); PARAMETERS program The program from which to retrieve the first parameter. name_space Specifies the parameter namespace through which to iterate. Currently CG_PROGRAM and CG_GLOBAL are supported. RETURN VALUES Returns the first CGparameter object in program. Returns zero if program is invalid or if program does not have any parameters. Also returns zero if program is a combined program. To access the parameters of a combined program, use cgGetProgramDomainProgram to get each domain program and then call cgGetFirstParameter on each domain program. DESCRIPTION cgGetFirstParameter returns the first top-level parameter in a program. cgGetFirstParameter is used for recursing through all parameters in a program. See cgGetNextParameter for more information on parameter traversal. EXAMPLES CGparameter param = cgGetFirstParameter( program, CG_GLOBAL ); while ( param ) { /* Do stuff with leaf */ param = cgGetNextParameter( param ); } ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_ENUMERANT_ERROR CG_GLOBAL. is generated if name_space is not CG_PROGRAM or HISTORY cgGetFirstParameter was introduced in Cg 1.1. SEE ALSO cgGetNextParameter, cgGetProgramDomainProgram, cgGetFirstEffectParameter, cgGetFirstParameterAnnotation perl v5.10.0 Cg Toolkit 3.0 cgGetFirstDependentParameter, 148 cgGetFirstParameterAnnotation(3) Cg Core Runtime API cgGetFirstParameterAnnotation(3) NAME cgGetFirstParameterAnnotation − get the first annotation of a parameter SYNOPSIS #include CGannotation cgGetFirstParameterAnnotation( CGparameter param ); PARAMETERS param The parameter from which to retrieve the annotation. RETURN VALUES Returns the first annotation for the given parameter. Returns NULL if the parameter has no annotations or an error occurs. DESCRIPTION The annotations associated with a parameter can be retrieved with cgGetFirstParameterAnnotation. Use cgGetNextAnnotation to iterate through the remainder of the parameter’s annotations. EXAMPLES CGannotation ann = cgGetFirstParameterAnnotation( param ); while( ann ) { /* do something with ann */ ann = cgGetNextAnnotation( ann ); } ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetFirstParameterAnnotation was introduced in Cg 1.4. SEE ALSO cgGetNamedParameterAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 149 cgGetFirstPass(3) Cg Core Runtime API cgGetFirstPass(3) NAME cgGetFirstPass − get the first pass in a technique SYNOPSIS #include CGpass cgGetFirstPass( CGtechnique tech ); PARAMETERS tech The technique from which to retrieve the first pass. RETURN VALUES Returns the first CGpass object in tech. Returns NULL if tech contains no passes. DESCRIPTION cgGetFirstPass is used to begin iteration over all of the passes contained within a technique. See cgGetNextPass for more information. EXAMPLES CGpass pass = cgGetFirstPass( tech ); while ( pass ) { /* Do stuff with pass */ leaf = cgGetNextPass( pass ); } ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. HISTORY cgGetFirstPass was introduced in Cg 1.4. SEE ALSO cgGetNextPass, cgGetNamedPass, cgIsPass, cgGetFirstPassAnnotation perl v5.10.0 Cg Toolkit 3.0 150 cgGetFirstPassAnnotation(3) Cg Core Runtime API cgGetFirstPassAnnotation(3) NAME cgGetFirstPassAnnotation − get the first annotation of a pass SYNOPSIS #include CGannotation cgGetFirstPassAnnotation( CGpass pass ); PARAMETERS pass The pass from which to retrieve the annotation. RETURN VALUES Returns the first annotation from the given pass. Returns NULL if the pass has no annotations or an error occurs. DESCRIPTION The annotations associated with a pass can be retrieved using cgGetFirstPassAnnotation. The remainder of the pass’s annotations can be discovered by iterating through the parameters, calling cgGetNextAnnotation to get to the next one. EXAMPLES CGannotation ann = cgGetFirstPassAnnotation( pass ); while( ann ) { /* do something with ann */ ann = cgGetNextAnnotation( ann ); } ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetFirstPassAnnotation was introduced in Cg 1.4. SEE ALSO cgGetNamedPassAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 151 cgGetFirstProgram(3) Cg Core Runtime API cgGetFirstProgram(3) NAME cgGetFirstProgram − get the first program in a context SYNOPSIS #include CGprogram cgGetFirstProgram( CGcontext context ); PARAMETERS context The context from which to retrieve the first program. RETURN VALUES Returns the first CGprogram object in context. Returns NULL if context contains no programs or an error occurs. DESCRIPTION cgGetFirstProgram is used to begin iteration over all of the programs contained within a context. See cgGetNextProgram for more information. EXAMPLES CGprogram program = cgGetFirstProgram( context ); while ( program ) { /* do something with program */ program = cgGetNextProgram( program ); } ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetFirstProgram was introduced in Cg 1.1. SEE ALSO cgGetNextProgram, cgCreateProgram, cgDestroyProgram, cgIsProgram, cgGetFirstEffect perl v5.10.0 Cg Toolkit 3.0 152 cgGetFirstProgramAnnotation(3) Cg Core Runtime API cgGetFirstProgramAnnotation(3) NAME cgGetFirstProgramAnnotation − get the first annotation of a program SYNOPSIS #include CGannotation cgGetFirstProgramAnnotation( CGprogram program ); PARAMETERS program The program from which to retrieve the annotation. RETURN VALUES Returns the first annotation from the given program. Returns NULL if the program has no annotations. DESCRIPTION The annotations associated with a program can be retrieved using cgGetFirstProgramAnnotation. The remainder of the program’s annotations can be discovered by iterating through the parameters, calling cgGetNextAnnotation to get to the next one. EXAMPLES CGannotation ann = cgGetFirstProgramAnnotation( program ); while( ann ) { /* do something with ann */ ann = cgGetNextAnnotation( ann ); } ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetFirstProgramAnnotation was introduced in Cg 1.4. SEE ALSO cgGetNamedProgramAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 153 cgGetFirstSamplerState(3) Cg Core Runtime API cgGetFirstSamplerState(3) NAME cgGetFirstSamplerState − get the first sampler state definition in a context SYNOPSIS #include CGstate cgGetFirstSamplerState( CGcontext context ); PARAMETERS context The context from which to retrieve the first sampler state definition. RETURN VALUES Returns the first CGstate object in context. Returns NULL if context contains no programs or an error occurs. DESCRIPTION cgGetFirstSamplerState is used to begin iteration over all of the sampler state definitions contained within a context. See cgGetNextState for more information. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetFirstSamplerState was introduced in Cg 1.4. SEE ALSO cgGetNextState, cgGetNamedSamplerState perl v5.10.0 Cg Toolkit 3.0 154 cgGetFirstSamplerStateAssignment(3) Cg Core Runtime API cgGetFirstSamplerStateAssignment(3) NAME cgGetFirstSamplerStateAssignment − get the first state assignment in a sampler_state block SYNOPSIS #include CGstateassignment cgGetFirstSamplerStateAssignment( CGparameter param ); PARAMETERS param The sampler parameter from which to retrieve the first state assignment. RETURN VALUES Returns the first CGstateassignment object assigned to param. Returns NULL if param has no sampler_state block or an error occurs. DESCRIPTION cgGetFirstSamplerStateAssignment is used to begin iteration over all of the state assignments contained within a sampler_state block assigned to a parameter in an effect file. See cgGetNextStateAssignment for more information. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetFirstSamplerStateAssignment was introduced in Cg 1.4. SEE ALSO cgGetNextStateAssignment, cgIsStateAssignment perl v5.10.0 Cg Toolkit 3.0 155 cgGetFirstState(3) Cg Core Runtime API cgGetFirstState(3) NAME cgGetFirstState − get the first state definition in a context SYNOPSIS #include CGstate cgGetFirstState( CGcontext context ); PARAMETERS context The context from which to retrieve the first state definition. RETURN VALUES Returns the first CGstate object in context. Returns NULL if context contains no state definitions or an error occurs. DESCRIPTION cgGetFirstState is used to begin iteration over all of the state definitions contained within a context. See cgGetNextState for more information. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetFirstState was introduced in Cg 1.4. SEE ALSO cgGetNextState, cgGetNamedState, cgIsState perl v5.10.0 Cg Toolkit 3.0 156 cgGetFirstStateAssignment(3) Cg Core Runtime API cgGetFirstStateAssignment(3) NAME cgGetFirstStateAssignment − get the first state assignment in a pass SYNOPSIS #include CGstateassignment cgGetFirstStateAssignment( CGpass pass ); PARAMETERS pass The pass from which to retrieve the first state assignment. RETURN VALUES Returns the first CGstateassignment object in pass. Returns NULL if pass contains no state assignments or an error occurs. DESCRIPTION cgGetFirstStateAssignment is used to begin iteration over all of the state assignment contained within a pass. See cgGetNextStateAssignment for more information. EXAMPLES to-be-written ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetFirstStateAssignment was introduced in Cg 1.4. SEE ALSO cgGetNextStateAssignment, cgIsStateAssignment perl v5.10.0 Cg Toolkit 3.0 157 cgGetFirstStructParameter(3) Cg Core Runtime API cgGetFirstStructParameter(3) NAME cgGetFirstStructParameter − get the first child parameter from a struct parameter SYNOPSIS #include CGparameter cgGetFirstStructParameter( CGparameter param ); PARAMETERS param Specifies the struct parameter. This parameter must be of type CG_STRUCT (returned by cgGetParameterType). RETURN VALUES Returns a handle to the first member parameter. Returns NULL if param is not a struct or if some other error occurs. DESCRIPTION cgGetFirstStructParameter returns the first member parameter of a struct parameter. The rest of the members may be retrieved from the first member by iterating with cgGetNextParameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_PARAMETER_TYPE_ERROR is generated if param is not a struct parameter. HISTORY cgGetFirstStructParameter was introduced in Cg 1.1. SEE ALSO cgGetNextParameter, cgGetFirstParameter perl v5.10.0 Cg Toolkit 3.0 158 cgGetFirstTechnique(3) Cg Core Runtime API cgGetFirstTechnique(3) NAME cgGetFirstTechnique − get the first technique in an effect SYNOPSIS #include CGtechnique cgGetFirstTechnique( CGeffect effect ); PARAMETERS effect The effect from which to retrieve the first technique. RETURN VALUES Returns the first CGtechnique object in effect. Returns NULL if effect contains no techniques or an error occurs. DESCRIPTION cgGetFirstTechnique is used to begin iteration over all of the techniques contained within a effect. See cgGetNextTechnique for more information. EXAMPLES Iterating through the techniques in an effect: CGeffect effect = cgCreateEffectFromFile(context, cgfx_filename, NULL); CGtechnique technique = cgGetFirstTechnique(effect); while (technique) { // Do something with each technique technique = cgGetNextTechnique(technique); } ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetFirstTechnique was introduced in Cg 1.4. SEE ALSO cgGetFirstTechniqueAnnotation, cgGetNamedTechniqueAnnotation, cgGetNamedTechnique, cgValidateTechnique, cgGetPassTechnique, cgGetTechniqueName, cgIsTechnique perl v5.10.0 Cg Toolkit 3.0 cgGetNextTechnique, cgGetTechniqueEffect, 159 cgGetFirstTechniqueAnnotation(3) Cg Core Runtime API cgGetFirstTechniqueAnnotation(3) NAME cgGetFirstTechniqueAnnotation − get the first annotation of a technique SYNOPSIS #include CGannotation cgGetFirstTechniqueAnnotation( CGtechnique tech ); PARAMETERS tech The technique from which to retrieve the annotation. RETURN VALUES Returns the first annotation in the given technique. Returns NULL if the technique has no annotations or an error occurs. DESCRIPTION The annotations associated with a technique can be retrieved using cgGetFirstTechniqueAnnotation. The remainder of the technique’s annotations can be discovered by iterating through the parameters, calling cgGetNextAnnotation to get to the next one. EXAMPLES CGannotation ann = cgGetFirstTechniqueAnnotation( technique ); while( ann ) { /* do something with ann */ ann = cgGetNextAnnotation( ann ); } ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. HISTORY cgGetFirstTechniqueAnnotation was introduced in Cg 1.4. SEE ALSO cgGetNamedTechniqueAnnotation, cgGetNextAnnotation perl v5.10.0 Cg Toolkit 3.0 160 cgGetFloatAnnotationValues(3) Cg Core Runtime API cgGetFloatAnnotationValues(3) NAME cgGetFloatAnnotationValues − get a float-valued annotation’s values SYNOPSIS #include const float * cgGetFloatAnnotationValues( CGannotation ann, int * nvalues ); PARAMETERS ann The annotation from which the values will be retrieved. nvalues Pointer to integer where the number of returned values will be stored. RETURN VALUES Returns a pointer to an array of float values. The number of values in the array is returned via the nvalues parameter. Returns NULL if no values are available. nvalues will be 0. DESCRIPTION cgGetFloatAnnotationValues allows the application to retrieve the value(s) of a floating-point typed annotation. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. CG_INVALID_PARAMETER_ERROR is generated if nvalues is NULL. HISTORY cgGetFloatAnnotationValues was introduced in Cg 1.4. SEE ALSO cgGetAnnotationType, cgGetBoolAnnotationValues perl v5.10.0 cgGetIntAnnotationValues, Cg Toolkit 3.0 cgGetStringAnnotationValue, 161 cgGetFloatStateAssignmentValues(3) Cg Core Runtime API cgGetFloatStateAssignmentValues(3) NAME cgGetFloatStateAssignmentValues − get a float-valued state assignment’s values SYNOPSIS #include const float * cgGetFloatStateAssignmentValues( CGstateassignment sa, int * nvalues ); PARAMETERS sa The state assignment from which the values will be retrieved. nvalues Pointer to integer where the number of returned values will be stored. RETURN VALUES Returns a pointer to an array of float values. The number of values in the array is returned via the nvalues parameter. Returns NULL if an error occurs or if no values are available. nvalues will be 0 in the latter case. DESCRIPTION cgGetFloatStateAssignmentValues allows the application to retrieve the value(s) of a floating-point typed state assignment. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_INVALID_PARAMETER_ERROR is generated if nvalues is NULL. CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR is generated if sa is not a state assignment of a float type. HISTORY cgGetFloatStateAssignmentValues was introduced in Cg 1.4. SEE ALSO cgGetStateAssignmentState, cgGetBoolStateAssignmentValues, cgGetProgramStateAssignmentValue, cgGetTextureStateAssignmentValue perl v5.10.0 cgGetStateType, Cg Toolkit 3.0 cgGetIntStateAssignmentValues, cgGetStringStateAssignmentValue, cgGetSamplerStateAssignmentValue, 162 cgGetIntAnnotationValues(3) Cg Core Runtime API cgGetIntAnnotationValues(3) NAME cgGetIntAnnotationValues − get an integer-valued annotation’s values SYNOPSIS #include const int * cgGetIntAnnotationValues( CGannotation ann, int * nvalues ); PARAMETERS ann The annotation from which the values will be retrieved. nvalues Pointer to integer where the number of returned values will be stored. RETURN VALUES Returns a pointer to an array of int values. The number of values in the array is returned via the nvalues parameter. Returns NULL if no values are available. nvalues will be 0. DESCRIPTION cgGetIntAnnotationValues allows the application to retrieve the value(s) of an int typed annotation. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. CG_INVALID_PARAMETER_ERROR is generated if nvalues is NULL. HISTORY cgGetIntAnnotationValues was introduced in Cg 1.4. SEE ALSO cgGetAnnotationType, cgGetBoolAnnotationValues perl v5.10.0 cgGetFloatAnnotationValues, Cg Toolkit 3.0 cgGetStringAnnotationValue, 163 cgGetIntStateAssignmentValues(3) Cg Core Runtime API cgGetIntStateAssignmentValues(3) NAME cgGetIntStateAssignmentValues − get an int-valued state assignment’s values SYNOPSIS #include const int * cgGetIntStateAssignmentValues( CGstateassignment sa, int * nvalues ); PARAMETERS sa The state assignment from which the values will be retrieved. nvalues Pointer to integer where the number of values returned will be stored. RETURN VALUES Returns a pointer to an array of int values. The number of values in the array is returned via the nvalues parameter. Returns NULL if an error occurs or if no values are available. nvalues will be 0 in the latter case. DESCRIPTION cgGetIntStateAssignmentValues allows the application to retrieve the value(s) of an integer typed state assignment. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_INVALID_PARAMETER_ERROR is generated if nvalues is NULL. CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR is generated if sa is not a state assignment of an integer type. HISTORY cgGetIntStateAssignmentValues was introduced in Cg 1.4. SEE ALSO cgGetStateAssignmentState, cgGetBoolStateAssignmentValues, cgGetProgramStateAssignmentValue, cgGetTextureStateAssignmentValue perl v5.10.0 cgGetStateType, Cg Toolkit 3.0 cgGetFloatStateAssignmentValues, cgGetStringStateAssignmentValue, cgGetSamplerStateAssignmentValue, 164 cgGetLastErrorString(3) Cg Core Runtime API cgGetLastErrorString(3) NAME cgGetLastErrorString − get the current error condition SYNOPSIS #include const char * cgGetLastErrorString( CGerror * error ); PARAMETERS error A pointer to a CGerror variable for returning the last error code. RETURN VALUES Returns the last error string. Returns NULL if there was no error. If error is not NULL, the last error code will be returned in the location specified by error. This is the same value that would be returned by cgGetError. DESCRIPTION cgGetLastErrorString returns the current error condition and error condition string. It’s similar to calling cgGetErrorString with the result of cgGetError. However in certain cases the error string may contain more information about the specific error that last ocurred than what cgGetErrorString would return. EXAMPLES CGerror error; const char* errorString = cgGetLastErrorString( &error ); ERRORS None. HISTORY cgGetLastErrorString was introduced in Cg 1.2. SEE ALSO cgGetError, cgGetErrorString perl v5.10.0 Cg Toolkit 3.0 165 cgGetLastListing(3) Cg Core Runtime API cgGetLastListing(3) NAME cgGetLastListing − get the current listing text SYNOPSIS #include const char * cgGetLastListing( CGcontext context ); PARAMETERS context The context handle. RETURN VALUES Returns a NULL-terminated string containing the current listing text. Returns NULL if no listing text is available, or the listing text string is empty. In all cases, the pointer returned by cgGetLastListing is only guaranteed to be valid until the next Cg entry point not related to error reporting is called. For example, calls to cgCreateProgram, cgCompileProgram, cgCreateEffect, or cgValidateTechnique will invalidate any previously-returned listing pointer. DESCRIPTION Each Cg context maintains a NULL-terminated string containing warning and error messages generated by the Cg compiler, state managers and the like. cgGetLastListing allows applications and custom state managers to query the listing text. cgGetLastListing returns the currrent listing string for the given CGcontext. When a Cg runtime error occurs, applications can use the listing text from the appropriate context to provide the user with detailed information about the error. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetLastListing was introduced in Cg 1.1. SEE ALSO cgSetLastListing, cgCreateContext, cgSetErrorHandler perl v5.10.0 Cg Toolkit 3.0 166 cgGetLockingPolicy(3) Cg Core Runtime API cgGetLockingPolicy(3) NAME cgGetLockingPolicy − get locking policy SYNOPSIS #include CGenum cgGetLockingPolicy( void ); PARAMETERS None. RETURN VALUES Returns an enumerant indicating the current locking policy. DESCRIPTION cgGetLockingPolicy returns an enumerant indicating the current locking policy for the library. See cgSetLockingPolicy for more information. EXAMPLES CGenum currentLockingPolicy = cgGetLockingPolicy(); ERRORS None. HISTORY cgGetLockingPolicy was introduced in Cg 2.0. SEE ALSO cgSetLockingPolicy perl v5.10.0 Cg Toolkit 3.0 167 cgGetMatrixParameter(3) Cg Core Runtime API cgGetMatrixParameter(3) NAME cgGetMatrixParameter − gets the values from a matrix parameter SYNOPSIS #include /* TYPE is int, float, or double */ void cgGetMatrixParameter{ifd}{rc}( CGparameter param, TYPE * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of values into which the parameter’s value will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION The cgGetMatrixParameter functions retrieve the value of a given matrix parameter. The functions are available in various combinations. There are versions of each function that take int, float or double values signified by the i, f or d in the function name. There are versions of each function that specify the order in which matrix values should be written to the array. Row-major copying is indicated by r, while column-major is indicated by c. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY The cgGetMatrixParameter functions were introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameterOrder, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 168 cgGetMatrixParameterOrder(3) Cg Core Runtime API cgGetMatrixParameterOrder(3) NAME cgGetMatrixParameterOrder − get the row or column order of a matrix parameter SYNOPSIS #include CGenum cgGetMatrixParameterOrder( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns CG_ROW_MAJOR for a row-major matrix parameter. Returns CG_COLUMN_MAJOR for a column-major matrix parameter. Returns CG_UNKNOWN for a parameter that is not a matrix. DESCRIPTION cgGetMatrixParameterOrder returns the row or column order of a matrix parameter. The Cg compiler supports #pragma pack_matrix(row_major) or #pragma pack_matrix(column_major) for specifying the order of matrix parameters. Row-major order is the Cg default. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter or param is not a matrix parameter. HISTORY cgGetMatrixParameterOrder was introduced in Cg 2.2. SEE ALSO cgGetMatrixParameter, cgGetMatrixSize perl v5.10.0 Cg Toolkit 3.0 169 cgGetMatrixParameterdc(3) Cg Core Runtime API cgGetMatrixParameterdc(3) NAME cgGetMatrixParameterdc − get the values from a matrix parameter SYNOPSIS #include void cgGetMatrixParameterdc( CGparameter param, double * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of doubles into which the matrix values will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION cgGetMatrixParameterdc retrieves the values of the given matrix parameter using column-major ordering. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetMatrixParameterdc was introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameter, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 170 cgGetMatrixParameterdr(3) Cg Core Runtime API cgGetMatrixParameterdr(3) NAME cgGetMatrixParameterdr − get the values from a matrix parameter SYNOPSIS #include void cgGetMatrixParameterdr( CGparameter param, double * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of doubles into which the matrix values will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION cgGetMatrixParameterdr retrieves the values of the given matrix parameter using row-major ordering. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetMatrixParameterdr was introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameter, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 171 cgGetMatrixParameterfc(3) Cg Core Runtime API cgGetMatrixParameterfc(3) NAME cgGetMatrixParameterfc − get the values from a matrix parameter SYNOPSIS #include void cgGetMatrixParameterfc( CGparameter param, float * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of floats into which the matrix values will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION cgGetMatrixParameterfc retrieves the values of the given matrix parameter using column-major ordering. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetMatrixParameterfc was introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameter, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 172 cgGetMatrixParameterfr(3) Cg Core Runtime API cgGetMatrixParameterfr(3) NAME cgGetMatrixParameterfr − get the values from a matrix parameter SYNOPSIS #include void cgGetMatrixParameterfr( CGparameter param, float * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of floats into which the matrix values will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION cgGetMatrixParameterfr retrieves the values of the given matrix parameter using row-major ordering. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetMatrixParameterfr was introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameter, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 173 cgGetMatrixParameteric(3) Cg Core Runtime API cgGetMatrixParameteric(3) NAME cgGetMatrixParameteric − get the values from a matrix parameter SYNOPSIS #include void cgGetMatrixParameteric( CGparameter param, int * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of ints into which the matrix values will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION cgGetMatrixParameteric retrieves the values of the given matrix parameter using column-major ordering. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetMatrixParameteric was introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameter, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 174 cgGetMatrixParameterir(3) Cg Core Runtime API cgGetMatrixParameterir(3) NAME cgGetMatrixParameterir − get the values from a matrix parameter SYNOPSIS #include void cgGetMatrixParameterir( CGparameter param, int * matrix ); PARAMETERS param The parameter from which the values will be returned. matrix An array of ints into which the matrix values will be written. The array must have size equal to the number of rows in the matrix times the number of columns in the matrix. RETURN VALUES None. DESCRIPTION cgGetMatrixParameterir retrieves the values of the given matrix parameter using row-major ordering. EXAMPLES to-be-written ERRORS CG_NOT_MATRIX_PARAM_ERROR is generated if param is not a matrix parameter. CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetMatrixParameterir was introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetMatrixParameter, cgGetParameterValues perl v5.10.0 Cg Toolkit 3.0 175 cgGetMatrixSize(3) Cg Core Runtime API cgGetMatrixSize(3) NAME cgGetMatrixSize − get the size of one dimension of an array parameter SYNOPSIS #include void cgGetMatrixSize( CGtype type, int * nrows, int * ncols ); PARAMETERS type The type enumerant. nrows A pointer to the location where the number of rows that type has will be written. ncols A pointer to the location where the number of columns that type has will be written. RETURN VALUES None. DESCRIPTION cgGetMatrixSize writes the number of rows and columns contained by the specified matrix type into nrows and ncols locations respectively. If type is not a matrix enumerant type, 0 is written as both the rows and columns size. Contrast this routine with cgGetTypeSizes where the number of rows and columns will be set to 1 row and 1 column for both scalar and non-numeric types but for vector types, the number of rows and columns will be set to 1 row and N columns where N is the number of components in the vector. EXAMPLES to-be-written ERRORS None. HISTORY cgGetMatrixSize was introduced in Cg 1.5. SEE ALSO cgGetMatrixParameterOrder, cgGetTypeSizes perl v5.10.0 cgGetArrayTotalSize, Cg Toolkit 3.0 cgGetArrayDimension, cgGetArrayParameter, 176 cgGetNamedEffect(3) Cg Core Runtime API cgGetNamedEffect(3) NAME cgGetNamedEffect − get an effect from a context by name SYNOPSIS #include CGeffect cgGetNamedEffect( CGcontext context, const char * name ); PARAMETERS context The context from which to retrieve the effect. name The name of the effect to retrieve. RETURN VALUES Returns the named effect if found. Returns NULL if context has no effect corresponding to name or if an error occurs. DESCRIPTION The effects in a context can be retrieved directly by name using cgGetNamedEffect. The effect names can be discovered by iterating through the context’s effects (see cgGetFirstEffect and cgGetNextEffect) and calling cgGetEffectName for each. EXAMPLES /* get "simpleEffect" from context */ CGeffect effect = cgGetNamedEffect( context, "simpleEffect" ); ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetNamedEffect was introduced in Cg 1.5. SEE ALSO cgGetEffectName, cgSetEffectName, cgGetFirstEffect, cgGetNextEffect perl v5.10.0 Cg Toolkit 3.0 177 cgGetNamedEffectAnnotation(3) Cg Core Runtime API cgGetNamedEffectAnnotation(3) NAME cgGetNamedEffectAnnotation − get an effect annotation by name SYNOPSIS #include CGannotation cgGetNamedEffectAnnotation( CGeffect effect, const char * name ); PARAMETERS effect The effect from which to retrieve the annotation. name The name of the annotation to retrieve. RETURN VALUES Returns the named annotation. Returns NULL if the effect has no annotation corresponding to name. DESCRIPTION The annotations associated with an effect can be retrieved directly by name using cgGetNamedEffectAnnotation. The names of a effect’s annotations can be discovered by iterating through the annotations (see cgGetFirstEffectAnnotation and cgGetNextAnnotation), calling cgGetAnnotationName for each one in turn. EXAMPLES /* fetch annotation "Apple" from CGeffect effect */ CGannotation ann = cgGetNamedEffectAnnotation( effect, "Apple" ); ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_INVALID_POINTER_ERROR is generated if name is NULL. HISTORY cgGetNamedEffectAnnotation was introduced in Cg 1.5. SEE ALSO cgGetFirstEffectAnnotation, cgGetNextAnnotation, cgGetAnnotationName perl v5.10.0 Cg Toolkit 3.0 178 cgGetNamedEffectParameter(3) Cg Core Runtime API cgGetNamedEffectParameter(3) NAME cgGetNamedEffectParameter − get an effect parameter by name SYNOPSIS #include CGparameter cgGetNamedEffectParameter( CGeffect effect, const char * name ); PARAMETERS effect The effect from which to retrieve the parameter. name The name of the parameter to retrieve. RETURN VALUES Returns the named parameter from the effect. Returns NULL if the effect has no parameter corresponding to name. DESCRIPTION The parameters of a effect can be retrieved directly by name using cgGetNamedEffectParameter. The names of the parameters in a effect can be discovered by iterating through the effect’s parameters (see cgGetFirstEffectParameter and cgGetNextParameter), calling cgGetParameterName for each one in turn. The given name may be of the form ‘‘foo.bar[2]’’, which retrieves the second element of the array ‘‘bar’’ in a structure named ‘‘foo’’. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetNamedEffectParameter was introduced in Cg 1.4. SEE ALSO cgGetFirstEffectParameter, cgGetNextParameter, cgGetParameterName, cgGetNamedParameter perl v5.10.0 Cg Toolkit 3.0 179 cgGetNamedParameter(3) Cg Core Runtime API cgGetNamedParameter(3) NAME cgGetNamedParameter − get a program parameter by name SYNOPSIS #include CGparameter cgGetNamedParameter( CGprogram program, const char * name ); PARAMETERS program The program from which to retrieve the parameter. name The name of the parameter to retrieve. RETURN VALUES Returns the named parameter from the program. Returns NULL if the program has no parameter corresponding to name. DESCRIPTION The parameters of a program can be retrieved directly by name using cgGetNamedParameter. The names of the parameters in a program can be discovered by iterating through the program’s parameters (see cgGetNextParameter), calling cgGetParameterName for each one in turn. The parameter name does not have to be complete name for a leaf node parameter. For example, if you have Cg program with the following parameters : struct FooStruct { float4 A; float4 B; }; struct BarStruct { FooStruct Foo[2]; }; void main(BarStruct Bar[3]) { /* ... */ } The following leaf-node parameters will be generated : Bar[0].Foo[0].A Bar[0].Foo[0].B Bar[0].Foo[1].A Bar[0].Foo[1].B Bar[1].Foo[0].A Bar[1].Foo[0].B Bar[1].Foo[1].A Bar[1].Foo[1].B Bar[2].Foo[0].A Bar[2].Foo[0].B Bar[2].Foo[1].A Bar[2].Foo[1].B A handle to any of the non-leaf arrays or structs can be directly obtained by using the appropriate name. The following are a few examples of names valid names that may be used with cgGetNamedParameter given the above Cg program : perl v5.10.0 Cg Toolkit 3.0 180 cgGetNamedParameter(3) Cg Core Runtime API cgGetNamedParameter(3) "Bar" "Bar[1]" "Bar[1].Foo" "Bar[1].Foo[0]" "Bar[1].Foo[0].B" ... EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetNamedParameter was introduced in Cg 1.1. SEE ALSO cgIsParameter, cgGetFirstParameter, cgGetNextParameter, cgGetArrayParameter, cgGetParameterName perl v5.10.0 Cg Toolkit 3.0 181 cgGetNamedParameterAnnotation(3) Cg Core Runtime API cgGetNamedParameterAnnotation(3) NAME cgGetNamedParameterAnnotation − get a parameter annotation by name SYNOPSIS #include CGannotation cgGetNamedParameterAnnotation( CGparameter param, const char * name ); PARAMETERS param The parameter from which to retrieve the annotation. name The name of the annotation to retrieve. RETURN VALUES Returns the named annotation. Returns NULL if the parameter has no annotation corresponding to name. DESCRIPTION The annotations associated with a parameter can be retrieved directly by name using cgGetNamedParameterAnnotation. The names of a parameter’s annotations can be discovered by iterating through the annotations (see cgGetFirstParameterAnnotation and cgGetNextAnnotation), calling cgGetAnnotationName for each one in turn. EXAMPLES /* fetch annotation "Apple" from CGparameter param */ CGannotation ann = cgGetNamedParameterAnnotation( param, "Apple" ); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetNamedParameterAnnotation was introduced in Cg 1.4. SEE ALSO cgGetFirstParameterAnnotation, cgGetNextAnnotation, cgGetAnnotationName perl v5.10.0 Cg Toolkit 3.0 182 cgGetNamedPass(3) Cg Core Runtime API cgGetNamedPass(3) NAME cgGetNamedPass − get a technique pass by name SYNOPSIS #include CGpass cgGetNamedPass( CGtechnique tech, const char * name ); PARAMETERS tech The technique from which to retrieve the pass. name The name of the pass to retrieve. RETURN VALUES Returns the named pass from the technique. Returns NULL if the technique has no pass corresponding to name. DESCRIPTION The passes of a technique can be retrieved directly by name using cgGetNamedPass. The names of the passes in a technique can be discovered by iterating through the technique’s passes (see cgGetFirstPass and cgGetNextPass), calling cgGetPassName for each one in turn. EXAMPLES to-be-written ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. HISTORY cgGetNamedPass was introduced in Cg 1.4. SEE ALSO cgGetFirstPass, cgGetNextPass, cgGetPassName perl v5.10.0 Cg Toolkit 3.0 183 cgGetNamedPassAnnotation(3) Cg Core Runtime API cgGetNamedPassAnnotation(3) NAME cgGetNamedPassAnnotation − get a pass annotation by name SYNOPSIS #include CGannotation cgGetNamedPassAnnotation( CGpass pass, const char * name ); PARAMETERS pass The pass from which to retrieve the annotation. name The name of the annotation to retrieve. RETURN VALUES Returns the named annotation. Returns NULL if the pass has no annotation corresponding to name. DESCRIPTION The annotations associated with a pass can be retrieved directly by name using cgGetNamedPassAnnotation. The names of a pass’s annotations can be discovered by iterating through the annotations (see cgGetFirstPassAnnotation and cgGetNextAnnotation), calling cgGetAnnotationName for each one in turn. EXAMPLES /* fetch annotation "Apple" from CGpass pass */ CGannotation ann = cgGetNamedPassAnnotation( pass, "Apple" ); ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetNamedPassAnnotation was introduced in Cg 1.4. SEE ALSO cgGetFirstPassAnnotation, cgGetNextAnnotation, cgGetAnnotationName perl v5.10.0 Cg Toolkit 3.0 184 cgGetNamedProgramAnnotation(3) Cg Core Runtime API cgGetNamedProgramAnnotation(3) NAME cgGetNamedProgramAnnotation − get a program annotation by name SYNOPSIS #include CGannotation cgGetNamedProgramAnnotation( CGprogram program, const char * name ); PARAMETERS program The program from which to retrieve the annotation. name The name of the annotation to retrieve. RETURN VALUES Returns the named annotation. Returns NULL if the program has no annotation corresponding to name. DESCRIPTION The annotations associated with a program can be retrieved directly by name using cgGetNamedProgramAnnotation. The names of a program’s annotations can be discovered by iterating through the annotations (see cgGetFirstProgramAnnotation and cgGetNextAnnotation), calling cgGetAnnotationName for each one in turn. EXAMPLES /* fetch annotation "Apple" from CGprogram program */ CGannotation ann = cgGetNamedProgramAnnotation( program, "Apple" ); ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetNamedProgramAnnotation was introduced in Cg 1.4. SEE ALSO cgGetFirstProgramAnnotation, cgGetNextAnnotation, cgGetAnnotationName perl v5.10.0 Cg Toolkit 3.0 185 cgGetNamedProgramParameter(3) Cg Core Runtime API cgGetNamedProgramParameter(3) NAME cgGetNamedProgramParameter − get a program parameter by name SYNOPSIS #include CGparameter cgGetNamedProgramParameter( CGprogram program, CGenum name_space, const char * name ); PARAMETERS program name_space The program from which to retrieve the parameter. Specifies the namespace of the parameter to iterate through. Currently CG_PROGRAM and CG_GLOBAL are supported. name Specifies the name of the parameter to retrieve. RETURN VALUES Returns the named parameter from the program. Returns NULL if the program has no parameter corresponding to name. DESCRIPTION cgGetNamedProgramParameter is essentially identical to cgGetNamedParameter except it limits the search of the parameter to the name space specified by name_space. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetNamedProgramParameter was introduced in Cg 1.2. SEE ALSO cgGetNamedParameter perl v5.10.0 Cg Toolkit 3.0 186 cgGetNamedSamplerState(3) Cg Core Runtime API cgGetNamedSamplerState(3) NAME cgGetNamedSamplerState − get a sampler state by name SYNOPSIS #include CGstate cgGetNamedSamplerState( CGcontext context, const char * name ); PARAMETERS context The context from which to retrieve the named sampler state. name The name of the state to retrieve. RETURN VALUES Returns the named sampler state. Returns NULL if context is invalid or if context has no sampler states corresponding to name. DESCRIPTION The sampler states associated with a context, as specified with a sampler_state block in an effect file, can be retrieved directly by name using cgGetNamedSamplerState. EXAMPLES to-be-written ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_PARAMETER_ERROR is generated if name is NULL. HISTORY cgGetNamedSamplerState was introduced in Cg 1.4. SEE ALSO cgCreateArraySamplerState, cgCreateSamplerState, cgGetFirstSamplerState, cgSetSamplerState perl v5.10.0 Cg Toolkit 3.0 187 cgGetNamedSamplerStateAssignment(3) Cg Core Runtime API cgGetNamedSamplerStateAssignment(3) NAME cgGetNamedSamplerStateAssignment − get a sampler state assignment by name SYNOPSIS #include CGstateassignment cgGetNamedSamplerStateAssignment( CGparameter param, const char * name ); PARAMETERS param The sampler parameter from which to retrieve the sampler state assignment. name The name of the state assignment to retrieve. RETURN VALUES Returns the named sampler state assignment. Returns NULL if the pass has no sampler state assignment corresponding to name. DESCRIPTION The sampler state assignments associated with a sampler parameter, as specified with a sampler_state block in an effect file, can be retrieved directly by name using cgGetNamedSamplerStateAssignment. The names of the sampler state assignments can be discovered by iterating through the sampler’s state assignments (see cgGetFirstSamplerStateAssignment and cgGetNextStateAssignment), calling cgGetSamplerStateAssignmentState then cgGetStateName for each one in turn. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetNamedSamplerStateAssignment was introduced in Cg 1.4. SEE ALSO cgIsStateAssignment, cgGetFirstSamplerStateAssignment, cgGetNextStateAssignment, cgGetStateName perl v5.10.0 Cg Toolkit 3.0 188 cgGetNamedState(3) Cg Core Runtime API cgGetNamedState(3) NAME cgGetNamedState − get a context state by name SYNOPSIS #include CGstate cgGetNamedState( CGcontext context, const char * name ); PARAMETERS context The context from which to retrieve the state. name The name of the state to retrieve. RETURN VALUES Returns the named state from the context. Returns NULL if the context has no state corresponding to name. DESCRIPTION The states of a context can be retrieved directly by name using cgGetNamedState. The names of the states in a context can be discovered by iterating through the context’s states (see cgGetFirstState and cgGetNextState), calling cgGetStateName for each one in turn. EXAMPLES to-be-written ERRORS CG_INVALID_PARAMETER_ERROR is generated if name is NULL. HISTORY cgGetNamedState was introduced in Cg 1.4. SEE ALSO cgCreateState, cgGetFirstState, cgGetNextState, cgGetStateEnumerantName, cgGetStateEnumerantValue, cgGetStateName, cgGetStateType, cgIsState perl v5.10.0 Cg Toolkit 3.0 189 cgGetNamedStateAssignment(3) Cg Core Runtime API cgGetNamedStateAssignment(3) NAME cgGetNamedStateAssignment − get a pass state assignment by name SYNOPSIS #include CGstateassignment cgGetNamedStateAssignment( CGpass pass, const char * name ); PARAMETERS pass The pass from which to retrieve the state assignment. name The name of the state assignment to retrieve. RETURN VALUES Returns the named state assignment from the pass. Returns NULL if the pass has no state assignment corresponding to name. DESCRIPTION The state assignments of a pass can be retrieved directly by name using cgGetNamedStateAssignment. The names of the state assignments in a pass can be discovered by iterating through the pass’s state assignments (see cgGetFirstStateAssignment and cgGetNextStateAssignment), calling cgGetStateAssignmentState then cgGetStateName for each one in turn. EXAMPLES to-be-written ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetNamedStateAssignment was introduced in Cg 1.4. SEE ALSO cgIsStateAssignment, cgGetFirstStateAssignment, cgGetStateAssignmentState, cgGetStateName perl v5.10.0 Cg Toolkit 3.0 cgGetNextStateAssignment, 190 cgGetNamedStructParameter(3) Cg Core Runtime API cgGetNamedStructParameter(3) NAME cgGetNamedStructParameter − get a struct parameter by name SYNOPSIS #include CGparameter cgGetNamedStructParameter( CGparameter param, const char * name ); PARAMETERS param The struct parameter from which to retrieve the member parameter. name The name of the member parameter to retrieve. RETURN VALUES Returns the member parameter from the given struct. Returns NULL if the struct has no member parameter corresponding to name. DESCRIPTION The member parameters of a struct parameter may be retrieved directly by name using cgGetNamedStructParameter. The names of the parameters in a struct may be discovered by iterating through the struct’s member parameters (see cgGetFirstStructParameter and cgGetNextParameter), and calling cgGetParameterName for each one in turn. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_PARAMETER_TYPE_ERROR is generated if param is not a struct parameter. HISTORY cgGetNamedStructParameter was introduced in Cg 1.2. SEE ALSO cgGetFirstStructParameter, cgGetNextParameter, cgGetParameterName perl v5.10.0 Cg Toolkit 3.0 191 cgGetNamedSubParameter(3) Cg Core Runtime API cgGetNamedSubParameter(3) NAME cgGetNamedSubParameter − gets a ‘‘shallow’’ or ‘‘deep’’ parameter from an aggregate parameter (ie struct, array, etc.) SYNOPSIS #include CGparameter cgGetNamedSubParameter( CGparameter param, const char * name ); PARAMETERS param Aggregate parameter. name Name of the parameter inside the aggregate parameter (param) being requested. RETURN VALUES Returns the named parameter. Returns NULL if param has no parameter corresponding to name. DESCRIPTION cgGetNamedSubParameter is a generalized parameter getter function that will retrieve parameters, including deep parameters, of an aggregate parameter type such as a structure or an array. EXAMPLES CGparameter parent = cgGetNamedParameter( program, "someParameter" ); CGparameter deepChild = cgGetNamedSubParameter( parent, "foo.list[3].item" ); /* Note: 'deepChild' is the same parameter returned by: cgGetNamedParameter( program, "someParameter.foo.list[3].item" ); */ ERRORS None. HISTORY cgGetNamedSubParameter was introduced in Cg 1.5. SEE ALSO cgGetNamedParameter, cgGetNamedStructParameter, cgGetArrayParameter perl v5.10.0 Cg Toolkit 3.0 192 cgGetNamedTechnique(3) Cg Core Runtime API cgGetNamedTechnique(3) NAME cgGetNamedTechnique − get an effect’s technique by name SYNOPSIS #include CGtechnique cgGetNamedTechnique( CGeffect effect, const char * name ); PARAMETERS effect The effect from which to retrieve the technique. name The name of the technique to retrieve. RETURN VALUES Returns the named technique from the effect. Returns NULL if the effect has no technique corresponding to name. DESCRIPTION The techniques of an effect can be retrieved directly by name using cgGetNamedTechnique. The names of the techniques in a effect can be discovered by iterating through the effect’s techniques (see cgGetFirstTechnique and cgGetNextTechnique), calling cgGetTechniqueName for each one in turn. EXAMPLES to-be-written ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetNamedTechnique was introduced in Cg 1.4. SEE ALSO cgGetFirstTechnique, cgGetNextTechnique, cgGetTechniqueName perl v5.10.0 Cg Toolkit 3.0 193 cgGetNamedTechniqueAnnotation(3) Cg Core Runtime API cgGetNamedTechniqueAnnotation(3) NAME cgGetNamedTechniqueAnnotation − get a technique annotation by name SYNOPSIS #include CGannotation cgGetNamedTechniqueAnnotation( CGtechnique tech, const char * name ); PARAMETERS tech The technique from which to retrieve the annotation. name The name of the annotation to retrieve. RETURN VALUES Returns the named annotation. Returns NULL if the technique has no annotation corresponding to name. DESCRIPTION The annotations associated with a technique can be retrieved directly by name using cgGetNamedTechniqueAnnotation. The names of a technique’s annotations can be discovered by iterating through the annotations (see cgGetFirstTechniqueAnnotation and cgGetNextAnnotation), calling cgGetAnnotationName for each one in turn. EXAMPLES /* fetch annotation "Apple" from CGtechnique technique */ CGannotation ann = cgGetNamedTechniqueAnnotation( technique, "Apple" ); ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. HISTORY cgGetNamedTechniqueAnnotation was introduced in Cg 1.4. SEE ALSO cgGetFirstTechniqueAnnotation, cgGetNextAnnotation, cgGetAnnotationName perl v5.10.0 Cg Toolkit 3.0 194 cgGetNamedUserType(3) Cg Core Runtime API cgGetNamedUserType(3) NAME cgGetNamedUserType − get enumerant associated with type name SYNOPSIS #include CGtype cgGetNamedUserType( CGhandle handle, const char * name ); PARAMETERS handle The CGprogram or CGeffect in which the type is defined. name A string containing the case-sensitive type name. RETURN VALUES Returns the type enumerant associated with name. Returns CG_UNKNOWN_TYPE if no such type exists. DESCRIPTION cgGetNamedUserType returns the enumerant associated with the named type defined in the constuct associated with handle, which may be a CGprogram or CGeffect. For a given type name, the enumerant returned by this entry point is guaranteed to be identical if called with either an CGeffect handle, or a CGprogram that is defined within that effect. If two programs in the same context define a type using identical names and definitions, the associated enumerants are also guaranteed to be identical. EXAMPLES to-be-written ERRORS CG_INVALID_PARAMETER_ERROR is generated if handle is not a valid program or effect. HISTORY cgGetNamedUserType was introduced in Cg 1.2. SEE ALSO cgGetUserType, cgGetType perl v5.10.0 Cg Toolkit 3.0 195 cgGetNextAnnotation(3) Cg Core Runtime API cgGetNextAnnotation(3) NAME cgGetNextAnnotation − iterate through annotations SYNOPSIS #include CGannotation cgGetNextAnnotation( CGannotation ann ); PARAMETERS ann The current annotation. RETURN VALUES Returns the next annotation in the sequence of annotations associated with the annotated object. Returns NULL when ann is the last annotation. DESCRIPTION The annotations associated with a parameter, pass, technique, or program can be iterated over by using cgGetNextAnnotation. Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each annotation will be visited exactly once. EXAMPLES CGannotation ann = cgGetFirstParameterAnnotation( param ); while( ann ) { /* do something with ann */ ann = cgGetNextAnnotation( ann ); } ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. HISTORY cgGetNextAnnotation was introduced in Cg 1.4. SEE ALSO cgGetFirstParameterAnnotation, cgGetFirstPassAnnotation, cgGetFirstTechniqueAnnotation, cgGetFirstProgramAnnotation, cgGetNamedParameterAnnotation, cgGetNamedPassAnnotation, cgGetNamedTechniqueAnnotation, cgGetNamedProgramAnnotation, cgIsAnnotation perl v5.10.0 Cg Toolkit 3.0 196 cgGetNextEffect(3) Cg Core Runtime API cgGetNextEffect(3) NAME cgGetNextEffect − iterate through effects in a context SYNOPSIS #include CGeffect cgGetNextEffect( CGeffect effect ); PARAMETERS effect The current effect. RETURN VALUES Returns the next effect in the context’s internal sequence of effects. Returns NULL when effect is the last effect in the context. DESCRIPTION The effects within a context can be iterated over with cgGetNextEffect. Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each effect will be visited exactly once. No guarantees can be made if effects are created or deleted during iteration. EXAMPLES CGeffect effect = cgGetFirstEffect( context ); while( effect ) { /* do something with effect */ effect = cgGetNextEffect( effect ); } ERRORS CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. HISTORY cgGetNextEffect was introduced in Cg 1.4. SEE ALSO cgGetFirstEffect perl v5.10.0 Cg Toolkit 3.0 197 cgGetNextLeafParameter(3) Cg Core Runtime API cgGetNextLeafParameter(3) NAME cgGetNextLeafParameter − get the next leaf parameter in a program or effect SYNOPSIS #include CGparameter cgGetNextLeafParameter( CGparameter param ); PARAMETERS param The current leaf parameter. RETURN VALUES Returns the next leaf CGparameter object. Returns NULL if param is invalid or if the program or effect from which the iteration started does not have any more leaf parameters. DESCRIPTION cgGetNextLeafParameter returns the next leaf parameter (not struct or array parameters) following a given leaf parameter. In a similar manner, the leaf parameters in an effect can be iterated over starting with a call to cgGetFirstLeafEffectParameter. EXAMPLES CGparameter leaf = cgGetFirstLeafParameter( program ); while(leaf) { /* Do stuff with leaf */ leaf = cgGetNextLeafParameter( leaf ); } ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetNextLeafParameter was introduced in Cg 1.1. SEE ALSO cgGetFirstLeafParameter, cgGetFirstLeafEffectParameter perl v5.10.0 Cg Toolkit 3.0 198 cgGetNextParameter(3) Cg Core Runtime API cgGetNextParameter(3) NAME cgGetNextParameter − iterate through a program’s or effect’s parameters SYNOPSIS #include CGparameter cgGetNextParameter( CGparameter current ); PARAMETERS current The current parameter. RETURN VALUES Returns the next parameter in the program or effect’s internal sequence of parameters. Returns NULL when current is the last parameter in the program or effect. DESCRIPTION The parameters of a program or effect can be iterated over using cgGetNextParameter with cgGetFirstParameter, or cgGetArrayParameter. Similarly, the parameters in an effect can be iterated over starting with a call to cgGetFirstEffectParameter. Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each parameter will be visited exactly once. EXAMPLES void RecurseParams( CGparameter param ) { if(!param) return; do { switch(cgGetParameterType(param)) { case CG_STRUCT : RecurseParams(cgGetFirstStructParameter(param)); break; case CG_ARRAY : { int ArraySize = cgGetArraySize(param, 0); int i; for(i=0; i < ArraySize; ++i) RecurseParams(cgGetArrayParameter(param, i)); } break; default : /* Do stuff to param */ } } while((param = cgGetNextParameter(param)) != 0); } void RecurseParamsInProgram( CGprogram program ) { RecurseParams( cgGetFirstParameter( program ) ); } perl v5.10.0 Cg Toolkit 3.0 199 cgGetNextParameter(3) Cg Core Runtime API cgGetNextParameter(3) ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetNextParameter was introduced in Cg 1.1. SEE ALSO cgGetFirstParameter, cgGetParameterType perl v5.10.0 cgGetFirstEffectParameter, cgGetFirstStructParameter, Cg Toolkit 3.0 cgGetArrayParameter, 200 cgGetNextPass(3) Cg Core Runtime API cgGetNextPass(3) NAME cgGetNextPass − iterate through the passes in a technique SYNOPSIS #include CGpass cgGetNextPass( CGpass pass ); PARAMETERS pass The current pass. RETURN VALUES Returns the next pass in the technique’s internal sequence of passes. Returns NULL when pass is the last pass in the technique. DESCRIPTION The passes within a technique can be iterated over using cgGetNextPass. Passes are returned in the order defined in the technique. EXAMPLES CGpass pass = cgGetFirstPass( technique ); while( pass ) { /* do something with pass */ pass = cgGetNextPass( pass ) } ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetNextPass was introduced in Cg 1.4. SEE ALSO cgGetFirstPass, cgGetNamedPass, cgIsPass perl v5.10.0 Cg Toolkit 3.0 201 cgGetNextProgram(3) Cg Core Runtime API cgGetNextProgram(3) NAME cgGetNextProgram − iterate through programs in a context SYNOPSIS #include CGprogram cgGetNextProgram( CGprogram program ); PARAMETERS program The current program. RETURN VALUES Returns the next program in the context’s internal sequence of programs. Returns NULL when program is the last program in the context. DESCRIPTION The programs within a context can be iterated over by using cgGetNextProgram. Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each program will be visited exactly once. No guarantees can be made if programs are generated or deleted during iteration. EXAMPLES CGprogram program = cgGetFirstProgram( context ); while( program ) { /* do something with program */ program = cgGetNextProgram( program ) } ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetNextProgram was introduced in Cg 1.1. SEE ALSO cgGetFirstProgram, cgCreateProgram, cgDestroyProgram, cgIsProgram perl v5.10.0 Cg Toolkit 3.0 202 cgGetNextState(3) Cg Core Runtime API cgGetNextState(3) NAME cgGetNextState − iterate through states in a context SYNOPSIS #include CGstate cgGetNextState( CGstate state ); PARAMETERS state The current state. RETURN VALUES Returns the next state in the context’s internal sequence of states. Returns NULL when state is the last state in the context. DESCRIPTION The states within a context can be iterated over using cgGetNextState. Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each state will be visited exactly once. No guarantees can be made if states are created or deleted during iteration. EXAMPLES CGstate state = cgGetFirstState( context ); while( state ) { /* do something with state */ state = cgGetNextState( state ) } ERRORS CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state. HISTORY cgGetNextState was introduced in Cg 1.4. SEE ALSO cgGetFirstState, cgGetNamedState, cgCreateState, cgIsState perl v5.10.0 Cg Toolkit 3.0 203 cgGetNextStateAssignment(3) Cg Core Runtime API cgGetNextStateAssignment(3) NAME cgGetNextStateAssignment − iterate through state assignments in a pass SYNOPSIS #include CGstateassignment cgGetNextStateAssignment( CGstateassignment sa ); PARAMETERS sa The current state assignment. RETURN VALUES Returns the next state assignment in the pass’ internal sequence of state assignments. Returns NULL when prog is the last state assignment in the pass. DESCRIPTION The state assignments within a pass can be iterated over by using cgGetNextStateAssignment. State assignments are returned in the same order specified in the pass in the effect. EXAMPLES CGstateassignment sa = cgGetFirstStateAssignment( pass ); while( sa ) { /* do something with sa */ sa = cgGetNextStateAssignment( sa ) } ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgGetNextStateAssignment was introduced in Cg 1.4. SEE ALSO cgGetFirstStateAssignment, cgGetNamedStateAssignment, cgIsStateAssignment perl v5.10.0 Cg Toolkit 3.0 204 cgGetNextTechnique(3) Cg Core Runtime API cgGetNextTechnique(3) NAME cgGetNextTechnique − iterate through techniques in a effect SYNOPSIS #include CGtechnique cgGetNextTechnique( CGtechnique tech ); PARAMETERS tech The current technique. RETURN VALUES Returns the next technique in the effect’s internal sequence of techniques. Returns NULL when tech is the last technique in the effect. DESCRIPTION The techniques within a effect can be iterated over using cgGetNextTechnique. Note that no specific order of traversal is defined by this mechanism. The only guarantee is that each technique will be visited exactly once. EXAMPLES CGtechnique tech = cgGetFirstTechnique( effect ); while( tech ) { /* do something with tech */ tech = cgGetNextTechnique( tech ) } ERRORS CG_INVALID_TECHNIQUE_HANDLE_ERROR is generated if tech is not a valid technique. HISTORY cgGetNextTechnique was introduced in Cg 1.4. SEE ALSO cgGetFirstTechnique, cgGetNamedTechnique perl v5.10.0 Cg Toolkit 3.0 205 cgGetNumConnectedToParameters(3) Cg Core Runtime API cgGetNumConnectedToParameters(3) NAME cgGetNumConnectedToParameters − gets the number of connected destination parameters SYNOPSIS #include int cgGetNumConnectedToParameters( CGparameter param ); PARAMETERS param The source parameter. RETURN VALUES Returns the number of destination parameters connected to param. Returns 0 if an error occurs. DESCRIPTION cgGetNumConnectedToParameters returns the number of destination parameters connected to the source parameter param. It’s primarily used with cgGetConnectedToParameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetNumConnectedToParameters was introduced in Cg 1.2. SEE ALSO cgConnectParameter, cgGetConnectedParameter, cgGetConnectedToParameter perl v5.10.0 Cg Toolkit 3.0 206 cgGetNumDependentAnnotationParameters(3) Cg Core Runtime API cgGetNumDependentAnnotationParameters(3) NAME cgGetNumDependentAnnotationParameters − get the number of effect parameters on which an annotation depends SYNOPSIS #include int cgGetNumDependentAnnotationParameters( CGannotation ann ); PARAMETERS ann The annotation handle. RETURN VALUES Returns the number of parameters on which ann depends. DESCRIPTION Annotations in CgFX files may include references to one or more effect parameters on the right hand side of the annotation that are used for computing the annotation’s value. cgGetNumDependentAnnotationParameters returns the total number of such parameters. cgGetDependentAnnotationParameter can then be used to iterate over these parameters. This information can be useful for applications that wish to cache the values of annotations so that they can determine which annotations may change as the result of changing a particular parameter’s value. EXAMPLES to-be-written ERRORS CG_INVALID_ANNOTATION_HANDLE_ERROR is generated if ann is not a valid annotation. HISTORY cgGetNumDependentAnnotationParameters was introduced in Cg 1.4. SEE ALSO cgGetDependentAnnotationParameter, cgGetNumDependentStateAssignmentParameters perl v5.10.0 Cg Toolkit 3.0 207 cgGetNumDependentProgramArrayStateAssignmentParameters(3) CgcgGetNumDependentProgramArrayStateAssignmentParameters(3) Core Runtime API NAME cgGetNumDependentProgramArrayStateAssignmentParameters − get the number of parameters on which a state assignment’s value depends SYNOPSIS #include int cgGetNumDependentProgramArrayStateAssignmentParameters( CGstateassignment sa PARAMETERS sa The state assignment handle. RETURN VALUES Returns the number of parameters on which sa depends. Returns 0 if sa is not a program state assignment or an error occurs. DESCRIPTION State assignments in CgFX files may include references to an array indexed by an effect parameter (or expression) on the right hand side of the state assignment that is used for computing the state assignment’s value. Usually this array holds the compile statements of shader programs and by changing the index of the shader array, it’s possible to switch to a different program or profile on-the-fly. Each compile statement in the array can depend on one or more effect parameters which are passed to the program in its parameter list. It is sometimes necessary for the application to query what those parameters are so values can be properly set to them. Before you can query these parameters, you must know how many cgGetNumDependentProgramArrayStateAssignmentParameters will return this number. there are. EXAMPLES /* In CgFX file */ vertexshader Torus[4] = { compile vp40 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ), compile vp30 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ), compile arbvp1 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ), compile vp20 C8E6v_torus( LightPosition, EyePosition, ModelViewProj, float2( OuterRadius, InnerRadius ) ) }; pixelshader SpecSurf[4] = { compile fp40 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ), compile fp30 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ), compile arbfp1 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), perl v5.10.0 Cg Toolkit 3.0 208 cgGetNumDependentProgramArrayStateAssignmentParameters(3) CgcgGetNumDependentProgramArrayStateAssignmentParameters(3) Core Runtime API normalMap, normalizeCube, normalizeCube ), compile fp20 C8E4f_specSurf( Ambient, float4(DiffuseMaterial * LightColor, float4(SpecularMaterial * LightColor, 1), normalMap, normalizeCube, normalizeCube ) }; int select = 0; technique bumpdemo { pass { VertexProgram = (Torus[select]); FragmentProgram = (SpecSurf[select]); } } /* In application */ int numParameters = cgGetNumDependentProgramArrayStateAssignmentParameters(state for(int i = 0; i < numParameters; ++i) { CGparameter param = cgGetDependentProgramArrayStateAssignmentParameter(state /* Set value for 'param' */ } For this example when select = 0 cgGetNumDependentProgramArrayStateAssignmentParameters will return 5 for VertexProgram and 8 for FragmentProgram. ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgGetNumDependentProgramArrayStateAssignmentParameters was introduced in Cg 3.0. SEE ALSO cgGetDependentProgramArrayStateAssignmentParameter perl v5.10.0 Cg Toolkit 3.0 209 cgGetNumDependentStateAssignmentParameters(3) Cg Core RuntimecgGetNumDependentStateAssignmentParameters(3) API NAME cgGetNumDependentStateAssignmentParameters − get the number of effect parameters on which a state assignment depends SYNOPSIS #include int cgGetNumDependentStateAssignmentParameters( CGstateassignment sa ); PARAMETERS sa The state assignment handle. RETURN VALUES Returns the number of parameters on which sa depends. DESCRIPTION State assignments in CgFX passes may include references to one or more effect parameters on the right hand side of the state assignment that are used for computing the state assignment’s value. cgGetNumDependentStateAssignmentParameters returns the total number of such parameters. cgGetDependentStateAssignmentParameter can then be used to iterate over these parameters. This information can be useful for applications that wish to cache the values of state assignments for customized state mangement so that they can determine which state assignments may change as the result of changing a parameter’s value. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. HISTORY cgGetNumDependentStateAssignmentParameters was introduced in Cg 1.4. SEE ALSO cgGetDependentStateAssignmentParameter, cgGetFirstStateAssignment, cgGetNamedStateAssignment, cgGetNumDependentAnnotationParameters perl v5.10.0 Cg Toolkit 3.0 210 cgGetNumParentTypes(3) Cg Core Runtime API cgGetNumParentTypes(3) NAME cgGetNumParentTypes − gets the number of parent types of a given type SYNOPSIS #include int cgGetNumParentTypes( CGtype type ); PARAMETERS type The child type. RETURN VALUES Returns the number of parent types. Returns 0 if there are no parents. DESCRIPTION cgGetNumParentTypes returns the number of parents from which type inherits. A parent type is one from which the given type inherits, or an interface type that the given type implements. Note that the current Cg language specification implies that a type may only have a single parent type — an interface implemented by the given type. EXAMPLES Given the type definitions: interface myiface { float4 eval(void); }; struct mystruct : myiface { float4 value; float4 eval(void ) { return value; } }; mystruct has a single parent type, myiface. ERRORS None. HISTORY cgGetNumParentTypes was introduced in Cg 1.2. SEE ALSO cgGetParentType perl v5.10.0 Cg Toolkit 3.0 211 cgGetNumProgramDomains(3) Cg Core Runtime API cgGetNumProgramDomains(3) NAME cgGetNumProgramDomains − get the number of domains in a combined program SYNOPSIS #include int cgGetNumProgramDomains( CGprogram program ); PARAMETERS program The combined program object to be queried. RETURN VALUES Returns the number of domains in the combined program program. Returns 0 if an error occurs. DESCRIPTION cgGetNumProgramDomains returns the number of domains in a combined program. For example, if the combined program contained a vertex program and a fragment program, cgGetNumProgramDomains will return 2. cgGetNumProgramDomains will always return 1 for a non-combined program. EXAMPLES CGprogram combined = cgCombinePrograms2( prog1, prog2 ); int numDomains = cgGetNumProgramDomains( combined ); /* numDomains == 2 */ ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetNumProgramDomains was introduced in Cg 1.5. SEE ALSO cgGetProfileDomain, cgGetProgramDomainProfile, cgGetProgramDomainProgram perl v5.10.0 Cg Toolkit 3.0 212 cgGetNumStateEnumerants(3) Cg Core Runtime API cgGetNumStateEnumerants(3) NAME cgGetNumStateEnumerants − gets the number of enumerants associated with a state SYNOPSIS #include int cgGetNumStateEnumerants( CGstate state ); PARAMETERS state The state from which to retrieve the number of associated enumerants. RETURN VALUES Returns the number of enumerants associated with state. Returns 0 if an error occurs. DESCRIPTION cgGetNumStateEnumerants returns the number of enumerants associated with a given CGstate. Enumerants can be added to a CGstate using cgAddStateEnumerant. EXAMPLES int value; char* pName; int nEnums = cgGetNumStateEnumerants(state); for (ii=0; ii int cgGetNumSupportedProfiles( void ); PARAMETERS None. RETURN VALUES Returns the number of profiles supported by this version of Cg. DESCRIPTION cgGetNumSupportedProfiles provides the number of profiles which are supported by this version of the Cg library. Note that a profile may be recognized by Cg but not supported by the platform on which the application is currently running. A graphics API specific routine such as cgGLIsProfileSupported must still be used to determine if the current GPU and driver combination supports a given profile. EXAMPLES CGprofile profile; int nProfiles; int ii; nProfiles = cgGetNumSupportedProfiles(); printf("NumSupportedProfiles: %i\n", nProfiles); for (ii=0; ii int cgGetNumUserTypes( CGhandle handle ); PARAMETERS handle The CGprogram or CGeffect in which the types are defined. RETURN VALUES Returns the number of user defined types. DESCRIPTION cgGetNumUserTypes returns the number of user-defined types in a given CGprogram or CGeffect. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if handle is not a valid program or effect handle. HISTORY cgGetNumUserTypes was introduced in Cg 1.2. SEE ALSO cgGetUserType, cgGetNamedUserType perl v5.10.0 Cg Toolkit 3.0 215 cgGetParameterBaseResource(3) Cg Core Runtime API cgGetParameterBaseResource(3) NAME cgGetParameterBaseResource − get a parameter’s base resource SYNOPSIS #include CGresource cgGetParameterBaseResource( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the base resource of param. Returns CG_UNDEFINED if no base resource exists for the given parameter. DESCRIPTION cgGetParameterBaseResource allows the application to retrieve the base resource for a parameter in a Cg program. The base resource is the first resource in a set of sequential resources. For example, if a given parameter has a resource of CG_ATTR7, it’s base resource would be CG_ATTR0. Only parameters with resources whose name ends with a number will have a base resource. For all other parameters the undefined resource CG_UNDEFINED will be returned. The numerical portion of the resource may be retrieved with cgGetParameterResourceIndex. For example, if the resource for a given parameter is CG_ATTR7, cgGetParameterResourceIndex will return 7. EXAMPLES /* log info about parameter param for debugging */ printf("Resource: %s:%d (base %s)\n", cgGetResourceString(cgGetParameterResource(param)), cgGetParameterResourceIndex(param), cgGetResourceString(cgGetParameterBaseResource(param))); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_PARAMETER_ERROR is generated if param is not a leaf node. HISTORY cgGetParameterBaseResource was introduced in Cg 1.1. SEE ALSO cgGetParameterResource, cgGetParameterResourceIndex, cgGetResourceString perl v5.10.0 Cg Toolkit 3.0 216 cgGetParameterBaseType(3) Cg Core Runtime API cgGetParameterBaseType(3) NAME cgGetParameterBaseType − get a program parameter’s base type SYNOPSIS #include CGtype cgGetParameterBaseType( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the base type enumerant of param. Returns CG_UNKNOWN_TYPE if an error occurs. DESCRIPTION cgGetParameterBaseType allows the application to retrieve the base type of a parameter. If param is of a numeric type (scalar, vector, or matrix), the scalar enumerant corresponding to param’s type will be returned. For example, if param is of type CG_FLOAT4x3, cgGetParameterBaseType will return CG_FLOAT. If param is an array, the base type of the array elements will be returned. If param is a structure, its type-specific enumerant will be returned, as per cgGetParameterNamedType. Otherwise, param’s type enumerant will be returned. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterBaseType was introduced in Cg 1.4. SEE ALSO cgGetParameterType, cgGetParameterNamedType, cgGetType, cgGetTypeString, cgGetParameterClass perl v5.10.0 Cg Toolkit 3.0 217 cgGetParameterBufferIndex(3) Cg Core Runtime API cgGetParameterBufferIndex(3) NAME cgGetParameterBufferIndex − get buffer index by parameter SYNOPSIS #include int cgGetParameterBufferIndex( CGparameter param ); PARAMETERS param The parameter for which the associated buffer index will be retrieved. RETURN VALUES Returns the index for the buffer to which param belongs. Returns −1 if param does not belong to a buffer or an error occurs. DESCRIPTION cgGetParameterBufferIndex returns the index for the buffer to which a parameter belongs. If param does not belong to a buffer, then −1 is returned. If the program to which param belongs is in an uncompiled state, it will be compiled by cgGetParameterBufferIndex. See cgSetAutoCompile for more information about program compile states. EXAMPLES int index = cgGetParameterBufferIndex( myParam ); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterBufferIndex was introduced in Cg 2.0. SEE ALSO cgSetProgramBuffer, cgGetParameterBufferOffset, cgGetParameterResourceSize, cgSetAutoCompile perl v5.10.0 Cg Toolkit 3.0 218 cgGetParameterBufferOffset(3) Cg Core Runtime API cgGetParameterBufferOffset(3) NAME cgGetParameterBufferOffset − get a parameter’s buffer offset SYNOPSIS #include int cgGetParameterBufferOffset( CGparameter param ); PARAMETERS param The parameter for which the buffer offset will be retrieved. RETURN VALUES Returns the buffer offset for param. Returns −1 if param does not belong to a buffer or an error occurs. DESCRIPTION cgGetParameterBufferOffset returns the buffer offset associated with a parameter. If param does not belong to a buffer, then −1 is returned. If the program to which param belongs is in an uncompiled state, it will be compiled by cgGetParameterBufferOffset. See cgSetAutoCompile for more information about program compile states. EXAMPLES int offset = cgGetParameterBufferOffset( myParam ); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterBufferOffset was introduced in Cg 2.0. SEE ALSO cgSetProgramBuffer, cgGetParameterBufferIndex, cgGetParameterResourceSize, cgSetAutoCompile perl v5.10.0 Cg Toolkit 3.0 219 cgGetParameterClass(3) Cg Core Runtime API cgGetParameterClass(3) NAME cgGetParameterClass − get a parameter’s class SYNOPSIS #include CGparameterclass cgGetParameterClass( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the parameter class enumerant of param. Returns CG_PARAMETERCLASS_UNKNOWN if an error occurs. DESCRIPTION cgGetParameterClass allows the application to retrieve the class of a parameter. The returned CGparameterclass value enumerates the high-level parameter classes: CG_PARAMETERCLASS_SCALAR The parameter is of a scalar type, such as CG_INT, or CG_FLOAT. CG_PARAMETERCLASS_VECTOR The parameter is of a vector type, such as CG_INT1, or CG_FLOAT4. CG_PARAMETERCLASS_MATRIX The parameter is of a matrix type, such as CG_INT1x1, or CG_FLOAT4x4. CG_PARAMETERCLASS_STRUCT The parameter is a struct or interface. CG_PARAMETERCLASS_ARRAY The parameter is an array. CG_PARAMETERCLASS_SAMPLER The parameter is a sampler. CG_PARAMETERCLASS_OBJECT The parameter is a texture, string, or program. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterClass was introduced in Cg 1.4. SEE ALSO cgGetParameterClassString, cgGetTypeString perl v5.10.0 cgGetParameterClassEnum, Cg Toolkit 3.0 cgGetParameterType, cgGetType, 220 cgGetParameterClassEnum(3) Cg Core Runtime API cgGetParameterClassEnum(3) NAME cgGetParameterClassEnum − get the enumerant associated with a parameter class name SYNOPSIS #include CGparameterclass cgGetParameterClassEnum( const char * pString ); PARAMETERS pString A string containing the case-sensitive parameter class name. RETURN VALUES Returns the parameter class enumerant associated with pString. Returns CG_PARAMETERCLASS_UNKNOWN if the given parameter class does not exist. DESCRIPTION cgGetParameterClassEnum returns the enumerant associated with a parameter class name. EXAMPLES CGparameterclass structParameterClass = cgGetParameterClassEnum("struct"); if(cgGetParameterClassEnum(myparam) == structParameterClass) { /* Do struct stuff */ } ERRORS CG_INVALID_PARAMETER_ERROR is generated if pString is NULL. HISTORY cgGetParameterClassEnum was introduced in Cg 2.2. SEE ALSO cgGetParameterClassString, cgGetParameterClass, cgGetTypeClass perl v5.10.0 Cg Toolkit 3.0 221 cgGetParameterClassString(3) Cg Core Runtime API cgGetParameterClassString(3) NAME cgGetParameterClassString − get the name associated with a parameter class enumerant SYNOPSIS #include const char * cgGetParameterClassString( CGparameterclass parameterclass ); PARAMETERS parameterclass The parameter class enumerant. RETURN VALUES Returns the name associated with parameterclass. Returns ‘‘unknown’’ if parameterclass is not a valid parameter class. DESCRIPTION cgGetParameterClassString returns the name associated with a parameter class enumerant. EXAMPLES static void dumpCgParameterInfo(CGparameter parameter) { /* ... */ const char* p = cgGetParameterClassString(cgGetParameterType(parameter)); if ( p ) { printf(" ParameterClass: %s\n", p); } /* ... */ } ERRORS None. HISTORY cgGetParameterClassString was introduced in Cg 2.2. SEE ALSO cgGetParameterClassEnum, cgGetParameterClass, cgGetTypeClass perl v5.10.0 Cg Toolkit 3.0 222 cgGetParameterColumns(3) Cg Core Runtime API cgGetParameterColumns(3) NAME cgGetParameterColumns − get number of parameter columns SYNOPSIS #include int cgGetParameterColumns( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the number of columns associated with the type if param is a numeric type or an array of numeric types. Returns 0 otherwise. DESCRIPTION cgGetParameterColumns return the number of columns associated with the given parameter’s type. If param is an array, the number of columns associated with each element of the array is returned. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterColumns was introduced in Cg 1.4. SEE ALSO cgGetParameterType, cgGetParameterRows perl v5.10.0 Cg Toolkit 3.0 223 cgGetParameterContext(3) Cg Core Runtime API cgGetParameterContext(3) NAME cgGetParameterContext − get a parameter’s parent context SYNOPSIS #include CGcontext cgGetParameterContext( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns a CGcontext handle to the parent context. Returns NULL if an error occurs. DESCRIPTION cgGetParameterContext allows the application to retrieve a handle to the context to which a given parameter belongs. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterContext was introduced in Cg 1.2. SEE ALSO cgCreateParameter, cgGetParameterProgram perl v5.10.0 Cg Toolkit 3.0 224 cgGetParameterDefaultValue(3) Cg Core Runtime API cgGetParameterDefaultValue(3) NAME cgGetParameterDefaultValue − get the default values of any numeric parameter SYNOPSIS #include /* TYPE is int, float, or double */ int cgGetParameterDefaultValue{ifd}{rc}( CGparameter param, int nelements, TYPE * v ); PARAMETERS param The program parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer to which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION The cgGetParameterDefaultValue functions allow the application to get the default values from any numeric parameter or parameter array. The default values are returned in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. There are versions of each function that return int, float or double values signified by i, f or d in the function name. There are versions of each function that will cause any matrices referenced by param to be copied in either row-major or column-major order, as signified by the r or c in the function name. For example, cgGetParameterDefaultValueic retrieves the default values of the given parameter using the supplied array of integer data, and copies matrix data in column-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY The cgGetParameterDefaultValue functions were introduced in Cg 2.1. perl v5.10.0 Cg Toolkit 3.0 225 cgGetParameterDefaultValue(3) Cg Core Runtime API cgGetParameterDefaultValue(3) SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetArrayTotalSize, cgGetParameterValue, cgSetParameterValue, cgGetParameterDefaultValuedc, cgGetParameterDefaultValuedr, cgGetParameterDefaultValuefc, cgGetParameterDefaultValuefr, cgGetParameterDefaultValueic, cgGetParameterDefaultValueir perl v5.10.0 Cg Toolkit 3.0 226 cgGetParameterDefaultValuedc(3) Cg Core Runtime API cgGetParameterDefaultValuedc(3) NAME cgGetParameterDefaultValuedc − get the default values of any numeric parameter SYNOPSIS #include int cgGetParameterDefaultValuedc( CGparameter param, int nelements, double * v ); PARAMETERS param The parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION cgGetParameterDefaultValuedc allows the application to get the default values from any numeric parameter or parameter array. The default values are returned as doubles in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in column-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterDefaultValuedc was introduced in Cg 2.1. SEE ALSO cgGetParameterValue, cgGetArrayTotalSize perl v5.10.0 cgSetParameterValue, cgGetParameterRows, Cg Toolkit 3.0 cgGetParameterColumns, 227 cgGetParameterDefaultValuedr(3) Cg Core Runtime API cgGetParameterDefaultValuedr(3) NAME cgGetParameterDefaultValuedr − get the default values of any numeric parameter SYNOPSIS #include int cgGetParameterDefaultValuedr( CGparameter param, int nelements, double * v ); PARAMETERS param The parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION cgGetParameterDefaultValuedr allows the application to get the default values from any numeric parameter or parameter array. The default values are returned as doubles in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in row-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterDefaultValuedr was introduced in Cg 2.1. SEE ALSO cgGetParameterValue, cgGetArrayTotalSize perl v5.10.0 cgSetParameterValue, cgGetParameterRows, Cg Toolkit 3.0 cgGetParameterColumns, 228 cgGetParameterDefaultValuefc(3) Cg Core Runtime API cgGetParameterDefaultValuefc(3) NAME cgGetParameterDefaultValuefc − get the default values of any numeric parameter SYNOPSIS #include int cgGetParameterDefaultValuefc( CGparameter param, int nelements, float * v ); PARAMETERS param The parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION cgGetParameterDefaultValuefc allows the application to get the default values from any numeric parameter or parameter array. The default values are returned as floats in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in column-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterDefaultValuefc was introduced in Cg 2.1. SEE ALSO cgGetParameterValue, cgGetArrayTotalSize perl v5.10.0 cgSetParameterValue, cgGetParameterRows, Cg Toolkit 3.0 cgGetParameterColumns, 229 cgGetParameterDefaultValuefr(3) Cg Core Runtime API cgGetParameterDefaultValuefr(3) NAME cgGetParameterDefaultValuefr − get the default values of any numeric parameter SYNOPSIS #include int cgGetParameterDefaultValuefr( CGparameter param, int nelements, float * v ); PARAMETERS param The parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION cgGetParameterDefaultValuefr allows the application to get the default values from any numeric parameter or parameter array. The default values are returned as floats in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in row-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterDefaultValuefr was introduced in Cg 2.1. SEE ALSO cgGetParameterValue, cgGetArrayTotalSize perl v5.10.0 cgSetParameterValue, cgGetParameterRows, Cg Toolkit 3.0 cgGetParameterColumns, 230 cgGetParameterDefaultValueic(3) Cg Core Runtime API cgGetParameterDefaultValueic(3) NAME cgGetParameterDefaultValueic − get the default values of any numeric parameter SYNOPSIS #include int cgGetParameterDefaultValueic( CGparameter param, int nelements, int * v ); PARAMETERS param The parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION cgGetParameterDefaultValueic allows the application to get the default values from any numeric parameter or parameter array. The default values are returned as ints in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in column-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterDefaultValueic was introduced in Cg 2.1. SEE ALSO cgGetParameterValue, cgGetArrayTotalSize perl v5.10.0 cgSetParameterValue, cgGetParameterRows, Cg Toolkit 3.0 cgGetParameterColumns, 231 cgGetParameterDefaultValueir(3) Cg Core Runtime API cgGetParameterDefaultValueir(3) NAME cgGetParameterDefaultValueir − get the default values of any numeric parameter SYNOPSIS #include int cgGetParameterDefaultValueir( CGparameter param, int nelements, int * v ); PARAMETERS param The parameter whose default values will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter default values will be written. RETURN VALUES Returns the total number of default values written to v. DESCRIPTION cgGetParameterDefaultValueir allows the application to get the default values from any numeric parameter or parameter array. The default values are returned as ints in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in row-major order. The size of v is passed as nelements. If v is smaller than the total number of default values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of default values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterDefaultValueir was introduced in Cg 2.1. SEE ALSO cgGetParameterValue, cgGetArrayTotalSize perl v5.10.0 cgSetParameterValue, cgGetParameterRows, Cg Toolkit 3.0 cgGetParameterColumns, 232 cgGetParameterDirection(3) Cg Core Runtime API cgGetParameterDirection(3) NAME cgGetParameterDirection − get a program parameter’s direction SYNOPSIS #include CGenum cgGetParameterDirection( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the direction of param. Returns CG_ERROR if an error occurs. DESCRIPTION cgGetParameterDirection allows the application to distinguish program input parameters from program output parameters. This information is necessary for the application to properly supply the program inputs and use the program outputs. cgGetParameterDirection will return one of the following enumerants : CG_IN Specifies an input parameter. CG_OUT Specifies an output parameter. CG_INOUT Specifies a parameter that is both input and output. CG_ERROR If an error occurs. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterDirection was introduced in Cg 1.1. SEE ALSO cgGetNamedParameter, cgGetNextParameter, cgGetParameterVariability, cgSetParameterVariability perl v5.10.0 Cg Toolkit 3.0 cgGetParameterName, cgGetParameterType, 233 cgGetParameterEffect(3) Cg Core Runtime API cgGetParameterEffect(3) NAME cgGetParameterEffect − get a parameter’s parent program SYNOPSIS #include CGeffect cgGetParameterEffect( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns a CGeffect handle to the parent effect. Returns NULL if the parameter is not a child of an effect or if an error occurs. DESCRIPTION cgGetParameterEffect allows the application to retrieve a handle to the effect to which a given parameter belongs. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterEffect was introduced in Cg 1.5. SEE ALSO cgCreateEffect, cgGetParameterProgram, cgCreateParameter perl v5.10.0 Cg Toolkit 3.0 234 cgGetParameterIndex(3) Cg Core Runtime API cgGetParameterIndex(3) NAME cgGetParameterIndex − get an array member parameter’s index SYNOPSIS #include int cgGetParameterIndex( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the index associated with an array member parameter. Returns −1 if the parameter is not in an array. DESCRIPTION cgGetParameterIndex returns the integer index of an array parameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_ARRAY_PARAM_ERROR is generated if param is not an array parameter. HISTORY cgGetParameterIndex was introduced in Cg 1.2. SEE ALSO cgGetArrayParameter perl v5.10.0 Cg Toolkit 3.0 235 cgGetParameterName(3) Cg Core Runtime API cgGetParameterName(3) NAME cgGetParameterName − get a program parameter’s name SYNOPSIS #include const char * cgGetParameterName( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the NULL-terminated name string for the parameter. Returns NULL if param is invalid. DESCRIPTION cgGetParameterName allows the application to retrieve the name of a parameter in a Cg program. This name can be used later to retrieve the parameter from the program using cgGetNamedParameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterName was introduced in Cg 1.1. SEE ALSO cgGetNamedParameter, cgGetNextParameter, cgGetParameterType, cgGetParameterDirection, cgSetParameterVariability perl v5.10.0 Cg Toolkit 3.0 cgGetParameterVariability, 236 cgGetParameterNamedType(3) Cg Core Runtime API cgGetParameterNamedType(3) NAME cgGetParameterNamedType − get a program parameter’s type SYNOPSIS #include CGtype cgGetParameterNamedType( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the type of param. DESCRIPTION cgGetParameterNamedType returns the type of param similarly to cgGetParameterType. However, if the type is a user defined struct it will return the unique enumerant associated with the user defined type instead of CG_STRUCT. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterNamedType was introduced in Cg 1.2. SEE ALSO cgGetParameterType, cgGetParameterBaseType perl v5.10.0 Cg Toolkit 3.0 237 cgGetParameterOrdinalNumber(3) Cg Core Runtime API cgGetParameterOrdinalNumber(3) NAME cgGetParameterOrdinalNumber − get a program parameter’s ordinal number SYNOPSIS #include int cgGetParameterOrdinalNumber( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the ordinal number associated with a parameter. If the parameter is a constant (cgGetParameterVariability returns CG_CONSTANT) then 0 is returned and no error is generated. When cgGetParameterOrdinalNumber is passed an array, the ordinal number of the first array element is returned. When passed a struct, the ordinal number of first struct data member is returned. DESCRIPTION cgGetParameterOrdinalNumber returns an integer that represents the order in which the parameter was declared within the Cg program. Ordinal numbering begins at zero, starting with a program’s first local leaf parameter. The subsequent local leaf parameters are enumerated in turn, followed by the program’s global leaf parameters. EXAMPLES The following Cg program: struct MyStruct { float a; sampler2D b; }; float globalvar1; float globalvar2 float4 main(float2 position : POSITION, float4 color : COLOR, uniform MyStruct mystruct, float2 texCoord : TEXCOORD0) : COLOR { /* etc ... */ } Would result in the following parameter ordinal numbering: position color mystruct.a mystruct.b texCoord globalvar1 globalvar2 −> −> −> −> −> −> −> 0 1 2 3 4 5 6 ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterOrdinalNumber was introduced in Cg 1.1. SEE ALSO cgGetParameterVariability perl v5.10.0 Cg Toolkit 3.0 238 cgGetParameterProgram(3) Cg Core Runtime API cgGetParameterProgram(3) NAME cgGetParameterProgram − get a parameter’s parent program SYNOPSIS #include CGprogram cgGetParameterProgram( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns a CGprogram handle to the parent program. Returns NULL if the parameter is not a child of a program or an error occurs. DESCRIPTION cgGetParameterProgram allows the application to retrieve a handle to the program to which a given parameter belongs. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterProgram was introduced in Cg 1.1. SEE ALSO cgCreateProgram, cgGetParameterEffect perl v5.10.0 Cg Toolkit 3.0 239 cgGetParameterResource(3) Cg Core Runtime API cgGetParameterResource(3) NAME cgGetParameterResource − get a program parameter’s resource SYNOPSIS #include CGresource cgGetParameterResource( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the resource of param. DESCRIPTION cgGetParameterResource allows the application to retrieve the resource for a parameter in a Cg program. This resource is necessary for the application to be able to supply the program’s inputs and use the program’s outputs. The resource enumerant is a profile-specific hardware resource. EXAMPLES /* log info about parameter param for debugging */ printf("Resource: %s:%d (base %s)\n", cgGetResourceString(cgGetParameterResource(param)), cgGetParameterResourceIndex(param), cgGetResourceString(cgGetParameterBaseResource(param))); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_PARAMETER_ERROR is generated if param is not a leaf node. HISTORY cgGetParameterResource was introduced in Cg 1.1. SEE ALSO cgGetParameterResourceIndex, cgGetParameterBaseResource, cgGetResourceString perl v5.10.0 Cg Toolkit 3.0 240 cgGetParameterResourceIndex(3) Cg Core Runtime API cgGetParameterResourceIndex(3) NAME cgGetParameterResourceIndex − get a program parameter’s resource index SYNOPSIS #include unsigned long cgGetParameterResourceIndex( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the resource index of param. Returns 0 if an error occurs. DESCRIPTION cgGetParameterResourceIndex allows the application to retrieve the resource index for a parameter in a Cg program. This index value is only used with resources that are linearly addressable. EXAMPLES /* log info about parameter param for debugging */ printf("Resource: %s:%d (base %s)\n", cgGetResourceString(cgGetParameterResource(param)), cgGetParameterResourceIndex(param), cgGetResourceString(cgGetParameterBaseResource(param))); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_PARAMETER_ERROR is generated if param is not a leaf node. HISTORY cgGetParameterResourceIndex was introduced in Cg 1.1. SEE ALSO cgGetParameterResource, cgGetResource, cgGetResourceString perl v5.10.0 Cg Toolkit 3.0 241 cgGetParameterResourceName(3) Cg Core Runtime API cgGetParameterResourceName(3) NAME cgGetParameterResourceName − get a program parameter’s resource name SYNOPSIS #include const char * cgGetParameterResourceName( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the resource name of param. Returns NULL if an error occurs. DESCRIPTION cgGetParameterResourceName allows the application to retrieve the resource name for a parameter in a Cg program. For translated profiles this name will most likely be different from the string returned by cgGetResourceString. EXAMPLES /* log info about parameter param for debugging */ printf("Resource: %s:%d (base %s) [name:%s]\n", cgGetResourceString(cgGetParameterResource(param)), cgGetParameterResourceIndex(param), cgGetResourceString(cgGetParameterBaseResource(param)), cgGetParameterResourceName(param)); ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_PARAMETER_ERROR is generated if param is not a leaf node. HISTORY cgGetParameterResourceName was introduced in Cg 2.1. SEE ALSO cgGetParameterBaseResource, cgGetParameterResource, cgGetParameterResourceIndex, cgGetResource, cgGetResourceString perl v5.10.0 Cg Toolkit 3.0 242 cgGetParameterResourceSize(3) Cg Core Runtime API cgGetParameterResourceSize(3) NAME cgGetParameterResourceSize − get size of resource associated with a parameter SYNOPSIS #include long cgGetParameterResourceSize( CGparameter param ); PARAMETERS param The parameter for which the associated resource size will be retrieved. RETURN VALUES Returns the size on the GPU of the resource associated with param. Returns −1 if an error occurs. DESCRIPTION cgGetParameterResourceSize returns the size in bytes of the resource corresponding to a parameter if the parameter belongs to a Cg buffer resource. The size of sampler parameters is zero because they have no actual data storage. The size of an array parameter is the size of an array element parameter times the length of the array. The size of a structure parameter is the sum of the size of all the members of the structure plus zero or more bytes of profile-dependent padding. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterResourceSize was introduced in Cg 2.0. SEE ALSO cgGetParameterBufferOffset, cgGetParameterBufferIndex perl v5.10.0 Cg Toolkit 3.0 243 cgGetParameterResourceType(3) Cg Core Runtime API cgGetParameterResourceType(3) NAME cgGetParameterResourceType − get a parameter’s resource type SYNOPSIS #include CGtype cgGetParameterResourceType( CGparameter param ); PARAMETERS param The parameter for which the resource type will be returned. RETURN VALUES Returns the resource type of param. Returns CG_UNKNOWN_TYPE if the parameter does not belong to a program, if the program is not compiled, or if an error occurs. DESCRIPTION cgGetParameterResourceType allows the application to retrieve the resource type for a parameter in a Cg program. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterResourceType was introduced in Cg 2.0. SEE ALSO cgGetParameterResource, cgGetParameterResourceIndex, cgGetParameterResourceSize, cgGetResource, cgGetResourceString perl v5.10.0 Cg Toolkit 3.0 244 cgGetParameterRows(3) Cg Core Runtime API cgGetParameterRows(3) NAME cgGetParameterRows − get number of parameter rows SYNOPSIS #include int cgGetParameterRows( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the number of rows associated with the type if param is a numeric type or an array of numeric types. Returns 0 otherwise. DESCRIPTION cgGetParameterRows return the number of rows associated with the given parameter’s type. If param is an array, the number of rows associated with each element of the array is returned. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterRows was introduced in Cg 1.4. SEE ALSO cgGetParameterType, cgGetParameterColumns perl v5.10.0 Cg Toolkit 3.0 245 cgGetParameterSemantic(3) Cg Core Runtime API cgGetParameterSemantic(3) NAME cgGetParameterSemantic − get a parameter’s semantic SYNOPSIS #include const char * cgGetParameterSemantic( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the NULL-terminated semantic string for the parameter. Returns NULL if an error occurs. DESCRIPTION cgGetParameterSemantic allows the application to retrieve the semantic of a parameter in a Cg program. If a uniform parameter does not have a user-assigned semantic, an empty string will be returned. If a varying parameter does not have a user-assigned semantic, the semantic string corresponding to the compiler-assigned resource for that varying will be returned. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterSemantic was introduced in Cg 1.1. SEE ALSO cgSetParameterSemantic, cgGetSemanticCasePolicy, cgSetSemanticCasePolicy, cgGetParameterResource, cgGetParameterResourceIndex, cgGetParameterName, cgGetParameterType perl v5.10.0 Cg Toolkit 3.0 246 cgGetParameterSettingMode(3) Cg Core Runtime API cgGetParameterSettingMode(3) NAME cgGetParameterSettingMode − get the parameter setting mode for a context SYNOPSIS #include CGenum cgGetParameterSettingMode( CGcontext context ); PARAMETERS context The context from which the parameter setting mode will be retrieved. RETURN VALUES Returns the parameter setting mode enumerant for context. Returns CG_UNKNOWN if an error occurs. DESCRIPTION cgGetParameterSettingMode returns the current parameter setting mode enumerant for context. See cgSetParameterSettingMode for more information. EXAMPLES /* assumes cgGetProgramContext(program) == context */ if (cgGetParameterSettingMode(context) == CG_DEFERRED_PARAMETER_SETTING) { cgUpdateProgramParameters(program); } ERRORS CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. HISTORY cgGetParameterSettingMode was introduced in Cg 2.0. SEE ALSO cgSetParameterSettingMode, cgUpdatePassParameters, cgUpdateProgramParameters perl v5.10.0 Cg Toolkit 3.0 247 cgGetParameterType(3) Cg Core Runtime API cgGetParameterType(3) NAME cgGetParameterType − get a program parameter’s type SYNOPSIS #include CGtype cgGetParameterType( CGparameter param ); PARAMETERS param The parameter. RETURN VALUES Returns the type enumerant of param. Returns CG_UNKNOWN_TYPE if an error occurs. DESCRIPTION cgGetParameterType allows the application to retrieve the type of a parameter in a Cg program. This type is necessary for the application to be able to supply the program’s inputs and use the program’s outputs. cgGetParameterType will return CG_STRUCT if the parameter is a struct and CG_ARRAY if the parameter is an array. Otherwise it will return the data type associated with the parameter. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterType was introduced in Cg 1.1. SEE ALSO cgGetType, cgGetParameterBaseType, cgGetTypeString, cgGetParameterClass perl v5.10.0 Cg Toolkit 3.0 248 cgGetParameterValue(3) Cg Core Runtime API cgGetParameterValue(3) NAME cgGetParameterValue − get the value of any numeric parameter SYNOPSIS #include /* TYPE is int, float, or double */ int cgGetParameterValue{ifd}{rc}( CGparameter param, int nelements, TYPE * v ); PARAMETERS param The program parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer to which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION The cgGetParameterValue functions allow the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. There are versions of each function that return int, float or double values signified by i, f or d in the function name. There are versions of each function that will cause any matrices referenced by param to be copied in either row-major or column-major order, as signified by the r or c in the function name. For example, cgGetParameterValueic retrieves the values of the given parameter using the supplied array of integer data, and copies matrix data in column-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; Note: Previous releases of Cg allowed you to store more values in a parameter than indicated by the parameter’s type. For example, one could use cgGLSetParameter4f to store four values into a parameter of type CG_FLOAT (not CG_FLOAT4). All four values could later be retrieved using a get call which requested more than one value. However, this feature conflicts with the GLSL approach and also leads to issues with parameters mapped into BUFFERS. Therefore, beginning with Cg 2.0 any components beyond the number indicated by the parameter type are ignored. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. perl v5.10.0 Cg Toolkit 3.0 249 cgGetParameterValue(3) Cg Core Runtime API cgGetParameterValue(3) CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY The cgGetParameterValue functions were introduced in Cg 1.4. SEE ALSO cgGetParameterRows, cgGetParameterColumns, cgGetArrayTotalSize, cgGetParameterDefaultValue, cgSetParameterValue, cgGetParameterValuedc, cgGetParameterValuedr, cgGetParameterValuefc, cgGetParameterValuefr, cgGetParameterValueic, cgGetParameterValueir perl v5.10.0 Cg Toolkit 3.0 250 cgGetParameterValuedc(3) Cg Core Runtime API cgGetParameterValuedc(3) NAME cgGetParameterValuedc − get the value of any numeric parameter SYNOPSIS #include int cgGetParameterValuedc( CGparameter param, int nelements, double * v ); PARAMETERS param The parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION cgGetParameterValuedc allows the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned as doubles in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in column-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterValuedc was introduced in Cg 1.4. SEE ALSO cgGetParameterDefaultValuedc, cgGetParameterValue, cgGetParameterColumns, cgGetArrayTotalSize perl v5.10.0 Cg Toolkit 3.0 cgSetParameterValue, cgGetParameterRows, 251 cgGetParameterValuedr(3) Cg Core Runtime API cgGetParameterValuedr(3) NAME cgGetParameterValuedr − get the value of any numeric parameter SYNOPSIS #include int cgGetParameterValuedr( CGparameter param, int nelements, double * v ); PARAMETERS param The parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION cgGetParameterValuedr allows the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned as doubles in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in row-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterValuedr was introduced in Cg 1.4. SEE ALSO cgGetParameterDefaultValuedr, cgGetParameterValue, cgGetParameterColumns, cgGetArrayTotalSize perl v5.10.0 Cg Toolkit 3.0 cgSetParameterValue, cgGetParameterRows, 252 cgGetParameterValuefc(3) Cg Core Runtime API cgGetParameterValuefc(3) NAME cgGetParameterValuefc − get the value of any numeric parameter SYNOPSIS #include int cgGetParameterValuefc( CGparameter param, int nelements, float * v ); PARAMETERS param The parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION cgGetParameterValuefc allows the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned as floats in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in column-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterValuefc was introduced in Cg 1.4. SEE ALSO cgGetParameterDefaultValuefc, cgGetParameterValue, cgGetParameterColumns, cgGetArrayTotalSize perl v5.10.0 Cg Toolkit 3.0 cgSetParameterValue, cgGetParameterRows, 253 cgGetParameterValuefr(3) Cg Core Runtime API cgGetParameterValuefr(3) NAME cgGetParameterValuefr − get the value of any numeric parameter SYNOPSIS #include int cgGetParameterValuefr( CGparameter param, int nelements, float * v ); PARAMETERS param The parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION cgGetParameterValuefr allows the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned as floats in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in row-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterValuefr was introduced in Cg 1.4. SEE ALSO cgGetParameterDefaultValuefr, cgGetParameterValue, cgGetParameterColumns, cgGetArrayTotalSize perl v5.10.0 Cg Toolkit 3.0 cgSetParameterValue, cgGetParameterRows, 254 cgGetParameterValueic(3) Cg Core Runtime API cgGetParameterValueic(3) NAME cgGetParameterValueic − get the value of any numeric parameter SYNOPSIS #include int cgGetParameterValueic( CGparameter param, int nelements, int * v ); PARAMETERS param The parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION cgGetParameterValueic allows the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned as ints in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in column-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterValueic was introduced in Cg 1.4. SEE ALSO cgGetParameterDefaultValueic, cgGetParameterValue, cgGetParameterColumns, cgGetArrayTotalSize perl v5.10.0 Cg Toolkit 3.0 cgSetParameterValue, cgGetParameterRows, 255 cgGetParameterValueir(3) Cg Core Runtime API cgGetParameterValueir(3) NAME cgGetParameterValueir − get the value of any numeric parameter SYNOPSIS #include int cgGetParameterValueir( CGparameter param, int nelements, int * v ); PARAMETERS param The parameter whose value will be retrieved. nelements The number of elements in array v. v Destination buffer into which the parameter values will be written. RETURN VALUES Returns the total number of values written to v. DESCRIPTION cgGetParameterValueir allows the application to get the value(s) from any numeric parameter or parameter array. The value(s) are returned as ints in v. The given parameter must be a scalar, vector, matrix, or a (possibly multidimensional) array of scalars, vectors, or matrices. Any matrices referenced by param will be copied in row-major order. The size of v is passed as nelements. If v is smaller than the total number of values in the given source parameter, CG_NOT_ENOUGH_DATA_ERROR is generated. The total number of values in a parameter, ntotal, may be computed as follow: int nrows = cgGetParameterRows(param); int ncols = cgGetParameterColumns(param); int asize = cgGetArrayTotalSize(param); int ntotal = nrows*ncols; if (asize > 0) ntotal *= asize; EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. CG_INVALID_POINTER_ERROR is generated if v is NULL. CG_NOT_ENOUGH_DATA_ERROR is generated if nelements is less than the total size of param. CG_NON_NUMERIC_PARAMETER_ERROR is generated if param is of a non-numeric type. HISTORY cgGetParameterValueir was introduced in Cg 1.4. SEE ALSO cgGetParameterDefaultValueir, cgGetParameterValue, cgGetParameterColumns, cgGetArrayTotalSize perl v5.10.0 Cg Toolkit 3.0 cgSetParameterValue, cgGetParameterRows, 256 cgGetParameterValues(3) Cg Core Runtime API cgGetParameterValues(3) NAME cgGetParameterValues − deprecated DESCRIPTION cgGetParameterValues is deprecated. cgGetParameterDefaultValue instead. Use a variation of cgGetParameterValue or SEE ALSO cgGetParameterValue, cgGetParameterDefaultValue perl v5.10.0 Cg Toolkit 3.0 257 cgGetParameterVariability(3) Cg Core Runtime API cgGetParameterVariability(3) NAME cgGetParameterVariability − get a parameter’s variability SYNOPSIS #include CGenum cgGetParameterVariability( CGparameter param ); PARAMETERS param The program parameter. RETURN VALUES Returns the variability of param. Returns CG_ERROR if an error occurs. DESCRIPTION cgGetParameterVariability allows the application to retrieve the variability of a parameter in a Cg program. This variability is necessary for the application to be able to supply the program’s inputs and use the program’s outputs. cgGetParameterVariability will return one of the following variabilities: CG_VARYING A varying parameter is one whose value changes with each invocation of the program. CG_UNIFORM A uniform parameter is one whose value does not change with each invocation of a program, but whose value can change between groups of program invocations. CG_LITERAL A literal parameter is folded out at compile time. Making a uniform parameter literal with cgSetParameterVariability will often make a program more efficient at the expense of requiring a compile every time the value is set. CG_CONSTANT A constant parameter is never changed by the user. It’s generated by the compiler by certain profiles that require immediate values to be placed in certain resource locations. CG_MIXED A structure parameter that contains parameters that differ in variability. EXAMPLES to-be-written ERRORS CG_INVALID_PARAM_HANDLE_ERROR is generated if param is not a valid parameter. HISTORY cgGetParameterVariability was introduced in Cg 1.1. SEE ALSO cgGetNamedParameter, cgGetNextParameter, cgGetParameterDirection, cgSetParameterVariability perl v5.10.0 Cg Toolkit 3.0 cgGetParameterName, cgGetParameterType, 258 cgGetParentType(3) Cg Core Runtime API cgGetParentType(3) NAME cgGetParentType − gets a parent type of a child type SYNOPSIS #include CGtype cgGetParentType( CGtype type, int index ); PARAMETERS type The child type. index The index of the parent type. index must be greater than or equal to 0 and less than the value returned by cgGetNumParentTypes. RETURN VALUES Returns the number of parent types. Returns NULL if there are no parents. Returns CG_UNKNOWN_TYPE if type is a built-in type or an error is thrown. DESCRIPTION cgGetParentType returns a parent type of type. A parent type is one from which the given type inherits, or an interface type that the given type implements. For example, given the type definitions: interface myiface { float4 eval(void); }; struct mystruct : myiface { float4 value; float4 eval(void ) { return value; } }; mystruct has a single parent type, myiface. Note that the current Cg language specification implies that a type may only have a single parent type — an interface implemented by the given type. EXAMPLES to-be-written ERRORS CG_OUT_OF_ARRAY_BOUNDS_ERROR is generated if index is outside the proper range. HISTORY cgGetParentType was introduced in Cg 1.2. SEE ALSO cgGetNumParentTypes perl v5.10.0 Cg Toolkit 3.0 259 cgGetPassName(3) Cg Core Runtime API cgGetPassName(3) NAME cgGetPassName − get a technique pass’s name SYNOPSIS #include const char * cgGetPassName( CGpass pass ); PARAMETERS pass The pass. RETURN VALUES Returns the NULL-terminated name string for the pass. Returns NULL if pass is invalid. DESCRIPTION cgGetPassName allows the application to retrieve the name of a pass in a Cg program. This name can be used later to retrieve the pass from the program using cgGetNamedPass. EXAMPLES to-be-written ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetPassName was introduced in Cg 1.4. SEE ALSO cgGetNamedPass, cgGetFirstPass, cgGetNextPass perl v5.10.0 Cg Toolkit 3.0 260 cgGetPassProgram(3) Cg Core Runtime API cgGetPassProgram(3) NAME cgGetPassProgram − get domain program from a pass SYNOPSIS #include CGprogram cgGetPassProgram( CGpass pass, CGdomain domain ); PARAMETERS pass The pass from which to get a program. domain The domain for which a program will be retrieved. RETURN VALUES Returns the program associated with a specified domain from the given pass. Returns NULL if pass or domain is invalid. DESCRIPTION cgGetPassProgram allows the application to retrieve the program associated with a specific domain from a pass. EXAMPLES to-be-written ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. CG_INVALID_ENUMERANT_ERROR is generated if domain CG_FRAGMENT_DOMAIN, or CG_GEOMETRY_DOMAIN. is not CG_VERTEX_DOMAIN, HISTORY cgGetPassProgram was introduced in Cg 2.1. SEE ALSO cgGetFirstPass, cgGetNextPass perl v5.10.0 Cg Toolkit 3.0 261 cgGetPassTechnique(3) Cg Core Runtime API cgGetPassTechnique(3) NAME cgGetPassTechnique − get a pass’s technique SYNOPSIS #include CGtechnique cgGetPassTechnique( CGpass pass ); PARAMETERS pass The pass. RETURN VALUES Returns a CGtechnique handle to the technique. Returns NULL if an error occurs. DESCRIPTION cgGetPassTechnique allows the application to retrieve a handle to the technique to which a given pass belongs. EXAMPLES to-be-written ERRORS CG_INVALID_PASS_HANDLE_ERROR is generated if pass is not a valid pass. HISTORY cgGetPassTechnique was introduced in Cg 1.4. SEE ALSO cgIsTechnique, cgGetNextTechnique, cgIsPass perl v5.10.0 Cg Toolkit 3.0 262 cgGetProfile(3) Cg Core Runtime API cgGetProfile(3) NAME cgGetProfile − get the profile enumerant from a profile name SYNOPSIS #include CGprofile cgGetProfile( const char * profile_string ); PARAMETERS profile_string A string containing the case-sensitive profile name. RETURN VALUES Returns the profile enumerant of profile_string. Returns CG_PROFILE_UNKNOWN if the given profile does not exist. DESCRIPTION cgGetProfile returns the enumerant assigned to a profile name. EXAMPLES CGprofile ARBVP1Profile = cgGetProfile("arbvp1"); if(cgGetProgramProfile(myprog) == ARBVP1Profile) { /* Do stuff */ } ERRORS CG_INVALID_PARAMETER_ERROR is generated if profile_string is NULL. HISTORY cgGetProfile was introduced in Cg 1.1. SEE ALSO cgGetProfileString, cgGetProgramProfile perl v5.10.0 Cg Toolkit 3.0 263 cgGetProfileDomain(3) Cg Core Runtime API cgGetProfileDomain(3) NAME cgGetProfileDomain − get the domain of a profile enumerant SYNOPSIS #include CGdomain cgGetProfileDomain( CGprofile profile ); PARAMETERS profile The profile enumerant. RETURN VALUES Returns: CG_UNKNOWN_DOMAIN CG_VERTEX_DOMAIN CG_FRAGMENT_DOMAIN CG_GEOMETRY_DOMAIN DESCRIPTION cgGetProfileDomain returns which type of domain the given profile belongs to. EXAMPLES CGdomain domain = cgGetProfileDomain(CG_PROFILE_PS_3_0); /* domain == CG_FRAGMENT_DOMAIN */ ERRORS None. HISTORY cgGetProfileDomain was introduced in Cg 1.5. CG_GEOMETRY_DOMAIN was introduced in Cg 2.0. SEE ALSO cgGetNumProgramDomains, cgGetProgramDomainProfile perl v5.10.0 Cg Toolkit 3.0 264 cgGetProfileProperty(3) Cg Core Runtime API cgGetProfileProperty(3) NAME cgGetProfileProperty − query property of a profile SYNOPSIS #include CGbool cgGetProfileProperty( CGprofile profile, CGenum query ); PARAMETERS profile The profile to query. query An enumerant describing the property to be queried. The following enumerants are allowed: • CG_IS_OPENGL_PROFILE • CG_IS_DIRECT3D_PROFILE • CG_IS_DIRECT3D_8_PROFILE • CG_IS_DIRECT3D_9_PROFILE • CG_IS_DIRECT3D_10_PROFILE • CG_IS_DIRECT3D_11_PROFILE • CG_IS_VERTEX_PROFILE • CG_IS_FRAGMENT_PROFILE • CG_IS_GEOMETRY_PROFILE • CG_IS_TESSELLATION_CONTROL_PROFILE • CG_IS_TESSELLATION_EVALUATION_PROFILE • CG_IS_TRANSLATION_PROFILE • CG_IS_HLSL_PROFILE • CG_IS_GLSL_PROFILE RETURN VALUES Returns CG_TRUE if profile holds the property expressed by query. Returns CG_FALSE otherwise. DESCRIPTION cgGetProfileProperty returns property information about the given profile. query must be one of the following enumerants : • CG_IS_OPENGL_PROFILE profile is an OpenGL profile. • CG_IS_DIRECT3D_PROFILE profile is Direct3D profile. • CG_IS_DIRECT3D_8_PROFILE profile is Direct3D8 profile. • CG_IS_DIRECT3D_9_PROFILE profile is Direct3D9 profile. • CG_IS_DIRECT3D_10_PROFILE profile is Direct3D10 profile. • CG_IS_DIRECT3D_11_PROFILE profile is Direct3D11 profile. perl v5.10.0 Cg Toolkit 3.0 265 cgGetProfileProperty(3) • Cg Core Runtime API cgGetProfileProperty(3) CG_IS_VERTEX_PROFILE profile is vertex profile. • CG_IS_FRAGMENT_PROFILE profile is fragment profile. • CG_IS_GEOMETRY_PROFILE profile is geometry profile. • CG_IS_TESSELLATION_CONTROL_PROFILE profile is tessellation control profile. • CG_IS_TESSELLATION_EVALUATION_PROFILE profile is tessellation evaluation profile. • CG_IS_TRANSLATION_PROFILE profile is a translation profile. • CG_IS_HLSL_PROFILE profile is an HLSL translation profile. • CG_IS_GLSL_PROFILE profile is a GLSL translation profile. EXAMPLES CGprofile profile; int nProfiles; int ii; nProfiles = cgGetNumSupportedProfiles(); printf("NumSupportedProfiles: %i\n", nProfiles); for (ii=0; ii const char * cgGetProfileString( CGprofile profile ); PARAMETERS profile The profile enumerant. RETURN VALUES Returns the profile string of the enumerant profile. Returns NULL if profile is not a valid profile. DESCRIPTION cgGetProfileString returns the profile name associated with a profile enumerant. EXAMPLES static void dumpCgProgramInfo(CGprogram program) { const char* p = cgGetProfileString(cgGetProgramProfile(program)); if ( p ) { printf(" Profile: %s\n", p ); } /* ... */ } ERRORS None. HISTORY cgGetProfileString was introduced in Cg 1.1. SEE ALSO cgGetProfile, cgGetProgramProfile perl v5.10.0 Cg Toolkit 3.0 267 cgGetProgramBuffer(3) Cg Core Runtime API cgGetProgramBuffer(3) NAME cgGetProgramBuffer − get buffer associated with a buffer index SYNOPSIS #include CGbuffer cgGetProgramBuffer( CGprogram program, int bufferIndex ); PARAMETERS program The program from which the associated buffer will be retrieved. bufferIndex The buffer index for which the associated buffer will be retrieved. RETURN VALUES Returns a buffer handle on success. Returns NULL if an error occurs. DESCRIPTION cgGetProgramBuffer returns the buffer handle associated with a given buffer index from program. The returned value can be NULL if no buffer is associated with this index or if an error occurs. EXAMPLES CGbuffer myBuffer = cgGetProgramBuffer( myProgram, 0 ); ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_BUFFER_INDEX_OUT_OF_RANGE_ERROR is generated if bufferIndex is not within the valid range of buffer indices for program. HISTORY cgGetProgramBuffer was introduced in Cg 2.0. SEE ALSO cgSetProgramBuffer, cgGetParameterBufferIndex, cgCreateBuffer perl v5.10.0 Cg Toolkit 3.0 268 cgGetProgramBufferMaxIndex(3) Cg Core Runtime API cgGetProgramBufferMaxIndex(3) NAME cgGetProgramBufferMaxIndex − get the maximum index of a buffer for a given profile SYNOPSIS #include int cgGetProgramBufferMaxIndex( CGprofile profile ); PARAMETERS profile The target for determining the maximum buffer index. RETURN VALUES Returns the maximum buffer index for a given profile. Returns 0 if an error occurs. DESCRIPTION cgGetProgramBufferMaxIndex returns the maximum buffer cgGetProgramBufferMaxIndex will return 0 if an invalid profile is passed. index for a profile. EXAMPLES int size = cgGetProgramBufferMaxIndex( CG_PROFILE_GPU_VP ); ERRORS none. HISTORY cgGetProgramBufferMaxIndex was introduced in Cg 2.0. SEE ALSO cgSetProgramBuffer, cgGetParameterBufferIndex, cgCreateBuffer perl v5.10.0 Cg Toolkit 3.0 269 cgGetProgramBufferMaxSize(3) Cg Core Runtime API cgGetProgramBufferMaxSize(3) NAME cgGetProgramBufferMaxSize − get the maximum size of a buffer in bytes for a given profile SYNOPSIS #include int cgGetProgramBufferMaxSize( CGprofile profile ); PARAMETERS profile The target for determining the maximum buffer size. RETURN VALUES Returns the size of a buffer for the given profile in bytes. Returns 0 if an error occurs. DESCRIPTION cgGetProgramBufferMaxSize returns the maximum size of a buffer for a profile in bytes. cgGetProgramBufferMaxSize will return 0 if an invalid profile is passed. EXAMPLES int size = cgGetProgramBufferMaxSize( CG_PROFILE_GPU_VP ); ERRORS none. HISTORY cgGetProgramBufferMaxSize was introduced in Cg 2.0. SEE ALSO cgSetProgramBuffer, cgGetParameterBufferIndex, cgCreateBuffer perl v5.10.0 Cg Toolkit 3.0 270 cgGetProgramContext(3) Cg Core Runtime API cgGetProgramContext(3) NAME cgGetProgramContext − get a programs parent context SYNOPSIS #include CGcontext cgGetProgramContext( CGprogram program ); PARAMETERS program The program. RETURN VALUES Returns a CGcontext handle to the parent context. Returns NULL if an error occurs. DESCRIPTION cgGetProgramContext allows the application to retrieve a handle to the context to which a given program belongs. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetProgramContext was introduced in Cg 1.1. SEE ALSO cgCreateProgram, cgCreateContext perl v5.10.0 Cg Toolkit 3.0 271 cgGetProgramDomain(3) Cg Core Runtime API cgGetProgramDomain(3) NAME cgGetProgramDomain − get a program’s domain SYNOPSIS #include CGdomain cgGetProgramDomain( CGprogram program ); PARAMETERS program The program. RETURN VALUES Returns the domain enumerant associated with program. DESCRIPTION cgGetProgramDomain retrieves the domain enumerant currently associated with a program. This is a convenience routine which essentially calls cgGetProgramProfile followed by cgGetProfileDomain. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetProgramDomain was introduced in Cg 2.2. SEE ALSO cgGetDomain, cgGetDomainString perl v5.10.0 Cg Toolkit 3.0 272 cgGetProgramDomainProfile(3) Cg Core Runtime API cgGetProgramDomainProfile(3) NAME cgGetProgramDomainProfile − get the profile associated with a domain SYNOPSIS #include CGprofile cgGetProgramDomainProfile( CGprogram program, int index ); PARAMETERS program The handle of the combined program object. index The index of the program’s domain to be queried. RETURN VALUES Returns the profile enumerant for the program with the given domain index, specifically one of: CG_UNKNOWN_DOMAIN CG_VERTEX_DOMAIN CG_FRAGMENT_DOMAIN CG_GEOMETRY_DOMAIN Returns CG_PROFILE_UNKNOWN if an error occurs. DESCRIPTION cgGetProgramDomainProfile gets the profile of the passed combined program using the index to select which domain to choose. EXAMPLES /* This will enable all profiles for each domain in glslComboProgram */ int domains = cgGetProgramDomains(glslComboProgram); for (int i=0; i CGprogram cgGetProgramDomainProgram( CGprogram program, int index ); PARAMETERS program The handle of the combined program object. index The index of the program’s domain program to be queried. RETURN VALUES Returns the program handle for the program with the given domain index. Returns 0 if an error occurs. DESCRIPTION A combined program consists of multiple domain programs. For example, a combined program may contain a vertex domain program and a fragment domain program. cgGetProgramDomainProgram gets the indexed domain program of the specified combined program. If the program parameter is not a combined program and the index is zero, program handle is simply returned as-is without error. EXAMPLES /* This will enable all profiles for each domain in glslComboProgram */ int domains = cgGetNumProgramDomains(glslComboProgram); for (int i=0; i CGenum cgGetProgramInput( CGprogram program ); PARAMETERS program A program handle. RETURN VALUES Returns a program input enumerant. If the program is a vertex or fragment program, it returns CG_VERTEX or CG_FRAGMENT, respectively. For geometry programs the input is one of: CG_POINT, CG_LINE, CG_LINE_ADJ, CG_TRIANGLE, or CG_TRIANGLE_ADJ. For tessellation control and evaluation programs the input is CG_PATCH. Returns CG_UNKNOWN if the input is unknown. DESCRIPTION cgGetProgramInput returns the program input enumerant. EXAMPLES void printProgramInput(CGprogram program) { char * input = NULL; switch(cgGetProgramInput(program)) { case CG_FRAGMENT: input = "fragment"; break; case CG_VERTEX: input = "vertex"; break; case CG_POINT: input = "point"; break; case CG_LINE: input = "line"; break; case CG_LINE_ADJ: input = "line adjacency"; break; case CG_TRIANGLE: input = "triangle"; break; case CG_TRIANGLE_ADJ: input = "triangle adjacency"; break; case CG_PATCH: input = "patch"; break; default: input = "unknown"; break; } printf("Program inputs %s.\n", input); } perl v5.10.0 Cg Toolkit 3.0 275 cgGetProgramInput(3) Cg Core Runtime API cgGetProgramInput(3) ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not valid program handle. HISTORY cgGetProgramInput was introduced in Cg 2.0. SEE ALSO cgGetProgramOutput perl v5.10.0 Cg Toolkit 3.0 276 cgGetProgramOptions(3) Cg Core Runtime API cgGetProgramOptions(3) NAME cgGetProgramOptions − get strings from a program object SYNOPSIS #include char const * const * cgGetProgramOptions( CGprogram program ); PARAMETERS program The Cg program to query. RETURN VALUES Returns the options used to compile the program as an array of NULL-terminated strings. Returns NULL if no options exist, or if an error occurs. DESCRIPTION cgGetProgramOptions allows the application to retrieve the set of options used to compile the program. The options are returned in an array of ASCII-encoded NULL-terminated character strings. Each string contains a single option. The last element of the string array is guaranteed to be NULL. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetProgramOptions was introduced in Cg 1.4. SEE ALSO cgGetProgramString perl v5.10.0 Cg Toolkit 3.0 277 cgGetProgramOutput(3) Cg Core Runtime API cgGetProgramOutput(3) NAME cgGetProgramOutput − get the program’s output SYNOPSIS #include CGenum cgGetProgramOutput( CGprogram program ); PARAMETERS program A program handle. RETURN VALUES Returns a program output enumerant. If the program is a vertex or fragment program, it returns CG_VERTEX or CG_FRAGMENT, respectively. For geometry programs the output is one of: CG_POINT_OUT, CG_LINE_OUT, or CG_TRIANGLE_OUT. For tessellation control programs the output is CG_PATCH. Returns CG_UNKNOWN if the output is unknown. DESCRIPTION cgGetProgramOutput returns the program output enumerant. For geometry programs, an input must be specified but not an output because of implicit output defaults. For example, if either ‘‘TRIANGLE’’ or ‘‘TRIANGLE_ADJ’’ is specified as an input without an explicit output in the shader source, then cgGetProgramOutput will return CG_TRIANGLE_OUT. EXAMPLES void printProgramOutput(CGprogram program) { char * output = NULL; switch(cgGetProgramOutput(program)) { case CG_VERTEX: output = "vertex"; break; case CG_FRAGMENT: output = "fragment"; break; case CG_POINT_OUT: output = "point"; break; case CG_LINE_OUT: output = "line"; break; case CG_TRIANGLE_OUT: output = "triangle"; break; case CG_PATCH: output = "patch"; break; default: output = "unknown"; break; } printf("Program outputs %s.\n", output); } perl v5.10.0 Cg Toolkit 3.0 278 cgGetProgramOutput(3) Cg Core Runtime API cgGetProgramOutput(3) ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetProgramOutput was introduced in Cg 2.0. SEE ALSO cgGetProgramInput perl v5.10.0 Cg Toolkit 3.0 279 cgGetProgramProfile(3) Cg Core Runtime API cgGetProgramProfile(3) NAME cgGetProgramProfile − get a program’s profile SYNOPSIS #include CGprofile cgGetProgramProfile( CGprogram program ); PARAMETERS program The program. RETURN VALUES Returns the profile enumerant associated with program. DESCRIPTION cgGetProgramProfile retrieves the profile enumerant currently associated with a program. EXAMPLES to-be-written ERRORS CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. HISTORY cgGetProgramProfile was introduced in Cg 1.1. SEE ALSO cgSetProgramProfile, cgGetProfile, cgGetProfileString, cgCreateProgram perl v5.10.0 Cg Toolkit 3.0 280 cgGetProgramStateAssignmentValue(3) Cg Core Runtime API cgGetProgramStateAssignmentValue(3) NAME cgGetProgramStateAssignmentValue − get a program-valued state assignment’s values SYNOPSIS #include CGprogram cgGetProgramStateAssignmentValue( CGstateassignment sa ); PARAMETERS sa The state assignment. RETURN VALUES Returns a CGprogram handle. Returns NULL if an error occurs or no program is available. DESCRIPTION cgGetProgramStateAssignmentValue allows the application to retrieve the value(s) of a state assignment that stores a CGprogram. EXAMPLES to-be-written ERRORS CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR is generated if sa is not a state assignment of a program type. HISTORY cgGetProgramStateAssignmentValue was introduced in Cg 1.4. SEE ALSO cgGetStateAssignmentState, cgGetStateType, cgGetFloatStateAssignmentValues, cgGetIntStateAssignmentValues, cgGetBoolStateAssignmentValues, cgGetStringStateAssignmentValue, cgGetSamplerStateAssignmentValue, cgGetTextureStateAssignmentValue perl v5.10.0 Cg Toolkit 3.0 281 cgGetProgramString(3) Cg Core Runtime API cgGetProgramString(3) NAME cgGetProgramString − get strings from a program object SYNOPSIS #include