source: GTP/trunk/App/Demos/Illum/Standalone/Hierarchical Systems Demo [OpenGL]/RESOURCES/include/Cg/cg.h @ 852

Revision 852, 13.8 KB checked in by szirmay, 19 years ago (diff)
Line 
1/*
2 *
3 * Copyright (c) 2002, NVIDIA Corporation.
4 *
5 * 
6 *
7 * NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
8 * of your agreement to the following terms, and your use, installation,
9 * modification or redistribution of this NVIDIA software constitutes
10 * acceptance of these terms.  If you do not agree with these terms, please do
11 * not use, install, modify or redistribute this NVIDIA software.
12 *
13 * 
14 *
15 * In consideration of your agreement to abide by the following terms, and
16 * subject to these terms, NVIDIA grants you a personal, non-exclusive license,
17 * under NVIDIA’s copyrights in this original NVIDIA software (the "NVIDIA
18 * Software"), to use, reproduce, modify and redistribute the NVIDIA
19 * Software, with or without modifications, in source and/or binary forms;
20 * provided that if you redistribute the NVIDIA Software, you must retain the
21 * copyright notice of NVIDIA, this notice and the following text and
22 * disclaimers in all such redistributions of the NVIDIA Software. Neither the
23 * name, trademarks, service marks nor logos of NVIDIA Corporation may be used
24 * to endorse or promote products derived from the NVIDIA Software without
25 * specific prior written permission from NVIDIA.  Except as expressly stated
26 * in this notice, no other rights or licenses express or implied, are granted
27 * by NVIDIA herein, including but not limited to any patent rights that may be
28 * infringed by your derivative works or by other works in which the NVIDIA
29 * Software may be incorporated. No hardware is licensed hereunder.
30 *
31 * 
32 *
33 * THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
34 * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
35 * WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
36 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
37 * EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
38 *
39 * 
40 *
41 * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
42 * EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
43 * PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
44 * PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
45 * REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
46 * HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
47 * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
48 * OF THE POSSIBILITY OF SUCH DAMAGE.
49 *
50 */
51
52
53#ifndef _cg_h
54#define _cg_h
55
56
57#define CG_VERSION_1_2                1
58#define CG_VERSION_NUM                1200
59
60
61//
62// This #define foreces the old API for now.  This will be removed soon, but
63// the user will still have the ability to enable it.
64//
65// #define CG_DEPRECATED_1_1_API 1
66
67// Set up for either Win32 import/export/lib.
68#ifndef CGDLL_API
69#ifdef WIN32
70    #ifdef CGDLL_EXPORTS
71    #define CGDLL_API __declspec(dllexport)
72    #elif defined (CG_LIB)
73    #define CGDLL_API
74    #else
75    #define CGDLL_API __declspec(dllimport)
76    #endif
77#else
78    #define CGDLL_API
79#endif
80#endif
81
82/*************************************************************************/
83/*** CG Run-Time Library API                                          ***/
84/*************************************************************************/
85
86/*************************************************************************/
87/*** Data types and enumerants                                         ***/
88/*************************************************************************/
89
90typedef int CGbool;
91
92#define CG_FALSE ((CGbool)0)
93#define CG_TRUE ((CGbool)1)
94
95typedef struct _CGcontext *CGcontext;
96typedef struct _CGprogram *CGprogram;
97typedef struct _CGparameter *CGparameter;
98
99
100//!!! PREPROCESS BEGIN
101
102typedef enum
103 {
104  CG_UNKNOWN_TYPE,
105  CG_STRUCT,
106  CG_ARRAY,
107
108  CG_TYPE_START_ENUM = 1024,
109# define CG_DATATYPE_MACRO(name, compiler_name, enum_name, ncols, nrows) \
110  enum_name ,
111
112#include <Cg/cg_datatypes.h>
113
114 } CGtype;
115
116typedef enum
117 {
118# define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,\
119                               enum_int,addressable,param_type) \
120  enum_name = enum_int,
121
122#include <Cg/cg_bindlocations.h>
123
124  CG_UNDEFINED,
125
126 } CGresource;
127
128typedef enum
129 {
130  CG_PROFILE_START = 6144,
131  CG_PROFILE_UNKNOWN,
132
133# define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
134   CG_PROFILE_##compiler_id_caps = int_id,
135 
136#include <Cg/cg_profiles.h>
137
138  CG_PROFILE_MAX = 7100,
139 } CGprofile;
140
141typedef enum
142 {
143# define CG_ERROR_MACRO(code, enum_name, message) \
144   enum_name = code,
145# include <Cg/cg_errors.h>
146 } CGerror;
147
148//!!! PREPROCESS END
149
150typedef enum
151 {
152# define CG_ENUM_MACRO(enum_name, enum_val) \
153   enum_name = enum_val,
154# include <Cg/cg_enums.h>
155 } CGenum;
156
157#include <stdarg.h>
158
159#ifdef __cplusplus
160extern "C" {
161#endif
162
163typedef void (*CGerrorCallbackFunc)(void);
164
165/*************************************************************************/
166/*** Functions                                                         ***/
167/*************************************************************************/
168
169#ifndef CG_EXPLICIT
170
171/*** Context functions ***/
172
173CGDLL_API CGcontext cgCreateContext(void);
174CGDLL_API void cgDestroyContext(CGcontext ctx);
175CGDLL_API CGbool cgIsContext(CGcontext ctx);
176CGDLL_API const char *cgGetLastListing(CGcontext ctx);
177CGDLL_API void cgSetAutoCompile(CGcontext ctx, CGenum flag);
178
179/*** Program functions ***/
180CGDLL_API CGprogram cgCreateProgram(CGcontext ctx,
181                                    CGenum program_type,
182                                    const char *program,
183                                    CGprofile profile,
184                                    const char *entry,
185                                    const char **args);
186CGDLL_API CGprogram cgCreateProgramFromFile(CGcontext ctx,
187                                            CGenum program_type,
188                                            const char *program_file,
189                                            CGprofile profile,
190                                            const char *entry,
191                                            const char **args);
192CGDLL_API CGprogram cgCopyProgram(CGprogram program);
193CGDLL_API void cgDestroyProgram(CGprogram program);
194
195CGDLL_API CGprogram cgGetFirstProgram(CGcontext ctx);
196CGDLL_API CGprogram cgGetNextProgram(CGprogram current);
197CGDLL_API CGcontext cgGetProgramContext(CGprogram prog);
198CGDLL_API CGbool cgIsProgram(CGprogram program);
199
200CGDLL_API void cgCompileProgram(CGprogram program);
201CGDLL_API CGbool cgIsProgramCompiled(CGprogram program);
202CGDLL_API const char *cgGetProgramString(CGprogram prog, CGenum pname);
203CGDLL_API CGprofile cgGetProgramProfile(CGprogram prog);
204
205/*** Parameter functions ***/
206
207CGDLL_API CGparameter cgCreateParameter(CGcontext ctx, CGtype type);
208CGDLL_API CGparameter cgCreateParameterArray(CGcontext ctx,
209                                             CGtype type,
210                                             int length);
211CGDLL_API CGparameter cgCreateParameterMultiDimArray(CGcontext ctx,
212                                                     CGtype type,
213                                                     int dim,
214                                                     const int *lengths);
215CGDLL_API void cgDestroyParameter(CGparameter param);
216CGDLL_API void cgConnectParameter(CGparameter from, CGparameter to);
217CGDLL_API void cgDisconnectParameter(CGparameter param);
218CGDLL_API CGparameter cgGetConnectedParameter(CGparameter param);
219
220CGDLL_API int cgGetNumConnectedToParameters(CGparameter param);
221CGDLL_API CGparameter cgGetConnectedToParameter(CGparameter param, int index);
222
223CGDLL_API CGparameter cgGetNamedParameter(CGprogram prog, const char *name);
224CGDLL_API CGparameter cgGetNamedProgramParameter(CGprogram prog,
225                                                 CGenum name_space,
226                                                 const char *name);
227
228CGDLL_API CGparameter cgGetFirstParameter(CGprogram prog, CGenum name_space);
229CGDLL_API CGparameter cgGetNextParameter(CGparameter current);
230CGDLL_API CGparameter cgGetFirstLeafParameter(CGprogram prog, CGenum name_space);
231CGDLL_API CGparameter cgGetNextLeafParameter(CGparameter current);
232
233CGDLL_API CGparameter cgGetFirstStructParameter(CGparameter param);
234CGDLL_API CGparameter cgGetNamedStructParameter(CGparameter param,
235                                                const char *name);
236
237CGDLL_API CGparameter cgGetFirstDependentParameter(CGparameter param);
238
239CGDLL_API CGparameter cgGetArrayParameter(CGparameter aparam, int index);
240CGDLL_API int cgGetArrayDimension(CGparameter param);
241CGDLL_API CGtype cgGetArrayType(CGparameter param);
242CGDLL_API int cgGetArraySize(CGparameter param, int dimension);
243CGDLL_API void cgSetArraySize(CGparameter param, int size);
244CGDLL_API void cgSetMultiDimArraySize(CGparameter param, const int *sizes);
245
246CGDLL_API CGprogram cgGetParameterProgram(CGparameter param);
247CGDLL_API CGcontext cgGetParameterContext(CGparameter param);
248CGDLL_API CGbool cgIsParameter(CGparameter param);
249CGDLL_API const char *cgGetParameterName(CGparameter param);
250CGDLL_API CGtype cgGetParameterType(CGparameter param);
251CGDLL_API CGtype cgGetParameterNamedType(CGparameter param);
252CGDLL_API const char *cgGetParameterSemantic(CGparameter param);
253CGDLL_API CGresource cgGetParameterResource(CGparameter param);
254CGDLL_API CGresource cgGetParameterBaseResource(CGparameter param);
255CGDLL_API unsigned long cgGetParameterResourceIndex(CGparameter param);
256CGDLL_API CGenum cgGetParameterVariability(CGparameter param);
257CGDLL_API CGenum cgGetParameterDirection(CGparameter param);
258CGDLL_API CGbool cgIsParameterReferenced(CGparameter param);
259CGDLL_API const double *cgGetParameterValues(CGparameter param,
260                                             CGenum value_type,
261                                             int *nvalues);
262CGDLL_API int cgGetParameterOrdinalNumber(CGparameter param);
263CGDLL_API CGbool cgIsParameterGlobal(CGparameter param);
264CGDLL_API int cgGetParameterIndex(CGparameter param);
265
266CGDLL_API void cgSetParameterVariability(CGparameter param, CGenum vary);
267CGDLL_API void cgSetParameterSemantic(CGparameter param, const char *semantic);
268
269
270CGDLL_API void cgSetParameter1f(CGparameter param, float x);
271CGDLL_API void cgSetParameter2f(CGparameter param, float x, float y);
272CGDLL_API void cgSetParameter3f(CGparameter param, float x, float y, float z);
273CGDLL_API void cgSetParameter4f(CGparameter param,
274                                float x,
275                                float y,
276                                float z,
277                                float w);
278CGDLL_API void cgSetParameter1d(CGparameter param, double x);
279CGDLL_API void cgSetParameter2d(CGparameter param, double x, double y);
280CGDLL_API void cgSetParameter3d(CGparameter param,
281                                double x,
282                                double y,
283                                double z);
284CGDLL_API void cgSetParameter4d(CGparameter param,
285                                double x,
286                                double y,
287                                double z,
288                                double w);
289
290
291CGDLL_API void cgSetParameter1fv(CGparameter param, const float *v);
292CGDLL_API void cgSetParameter2fv(CGparameter param, const float *v);
293CGDLL_API void cgSetParameter3fv(CGparameter param, const float *v);
294CGDLL_API void cgSetParameter4fv(CGparameter param, const float *v);
295CGDLL_API void cgSetParameter1dv(CGparameter param, const double *v);
296CGDLL_API void cgSetParameter2dv(CGparameter param, const double *v);
297CGDLL_API void cgSetParameter3dv(CGparameter param, const double *v);
298CGDLL_API void cgSetParameter4dv(CGparameter param, const double *v);
299
300CGDLL_API void cgSetMatrixParameterdr(CGparameter param, const double *matrix);
301CGDLL_API void cgSetMatrixParameterfr(CGparameter param, const float *matrix);
302CGDLL_API void cgSetMatrixParameterdc(CGparameter param, const double *matrix);
303CGDLL_API void cgSetMatrixParameterfc(CGparameter param, const float *matrix);
304
305
306/*** Type Functions ***/
307
308CGDLL_API const char *cgGetTypeString(CGtype type);
309CGDLL_API CGtype cgGetType(const char *type_string);
310
311CGDLL_API CGtype cgGetNamedUserType(CGprogram program, const char *name);
312
313CGDLL_API int cgGetNumUserTypes(CGprogram program);
314CGDLL_API CGtype cgGetUserType(CGprogram program, int index);
315
316CGDLL_API int cgGetNumParentTypes(CGtype type);
317CGDLL_API CGtype cgGetParentType(CGtype type, int index);
318
319CGDLL_API CGbool cgIsParentType(CGtype parent, CGtype child);
320CGDLL_API CGbool cgIsInterfaceType(CGtype type);
321
322/*** Resource Functions ***/
323
324CGDLL_API const char *cgGetResourceString(CGresource resource);
325CGDLL_API CGresource cgGetResource(const char *resource_string);
326
327/*** Enum Functions ***/
328
329CGDLL_API const char *cgGetEnumString(CGenum en);
330CGDLL_API CGenum cgGetEnum(const char *enum_string);
331
332/*** Profile Functions ***/
333
334CGDLL_API const char *cgGetProfileString(CGprofile profile);
335CGDLL_API CGprofile cgGetProfile(const char *profile_string);
336
337/*** Error Functions ***/
338
339CGDLL_API CGerror cgGetError(void);
340CGDLL_API const char *cgGetErrorString(CGerror error);
341CGDLL_API const char *cgGetLastErrorString(CGerror *error);
342CGDLL_API void cgSetErrorCallback(CGerrorCallbackFunc func);
343CGDLL_API CGerrorCallbackFunc cgGetErrorCallback(void);
344
345/*** Misc Functions ***/
346
347CGDLL_API const char *cgGetString(CGenum sname);
348
349
350/*** Support for deprecated Cg 1.1 API ***/
351
352CGDLL_API CGparameter cgGetNextParameter_depr1_1(CGparameter current);
353CGDLL_API CGparameter cgGetNextLeafParameter_depr1_1(CGparameter current);
354
355#ifdef CG_DEPRECATED_1_1_API
356
357#define cgGetNextParameter cgGetNextParameter_depr1_1
358#define cgGetNextLeafParameter cgGetNextLeafParameter_depr1_1
359
360#endif
361
362#endif
363
364#ifdef __cplusplus
365}
366#endif
367
368
369#endif
Note: See TracBrowser for help on using the repository browser.