1 #ifndef COIN_GLUE_CG_H
2 #define COIN_GLUE_CG_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #ifndef COIN_INTERNAL
37 #error this is a private header file
38 #endif
39 
40 #ifdef HAVE_CONFIG_H
41 #include <config.h>
42 #endif /* HAVE_CONFIG_H */
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif /* __cplusplus */
47 
48 #if 0 /* to get proper auto-indentation in emacs */
49 }
50 #endif /* emacs indentation */
51 
52 #if !defined(HAVE_DYNAMIC_LINKING) && defined(HAVE_CGLIB)
53 
54 /* FIXME: static linking with Cg library has not been tested
55    yet. 20050125 mortene.*/
56 
57 #define CGLIB_RUNTIME_LINKING 0
58 
59 #include <Cg/cg.h>
60 #include <Cg/cgGL.h>
61 
62 #else /* HAVE_DYNAMIC_LINKING || !HAVE_CGLIB */
63 
64 #define CGLIB_RUNTIME_LINKING 1
65 
66 /*
67    We need some Cg structs and defines, so set them up here for
68    runtime linking support, as we want to avoid including
69    Cg/<whatever>.h.
70 */
71 
72 /* typedef struct _CGprogram * CGprogram; XXX */
73 typedef void * CGprogram;
74 typedef void * CGeffect;
75 typedef void * CGtechnique;
76 typedef void * CGpass;
77 
78 /* typedef struct _CGcontext * CGcontext; XXX */
79 typedef void * CGcontext;
80 
81 /* typedef struct _CGparameter *CGparameter; XXX */
82 typedef void * CGparameter;
83 
84 typedef enum {
85   CG_PROFILE_ARBVP1 = 6150,
86   CG_PROFILE_ARBFP1 = 7000,
87   CG_GENERIC = 7002
88 } CGprofile;
89 
90 typedef enum {
91   CG_NO_ERROR = 0
92 } CGerror;
93 
94 typedef enum {
95   CG_SOURCE = 4112
96 } CGenum;
97 
98 typedef enum {
99   CG_GL_MATRIX_IDENTITY = 0,
100   CG_GL_MATRIX_TRANSPOSE = 1,
101   CG_GL_MATRIX_INVERSE = 2,
102   CG_GL_MATRIX_INVERSE_TRANSPOSE = 3,
103 
104   CG_GL_MODELVIEW_MATRIX = 4,
105   CG_GL_PROJECTION_MATRIX = 5,
106   CG_GL_TEXTURE_MATRIX = 6,
107   CG_GL_MODELVIEW_PROJECTION_MATRIX = 7,
108 
109   CG_GL_VERTEX = 8,
110   CG_GL_FRAGMENT = 9
111 } CGGLenum;
112 
113 typedef enum {
114   CG_UNKNOWN_TYPE = 0,
115   CG_STRUCT = 1,
116   CG_ARRAY = 2,
117 
118   CG_FLOAT = 1045,
119   CG_FLOAT1 = 1091,
120   CG_FLOAT2 = 1046,
121   CG_FLOAT3 = 1047,
122   CG_FLOAT4 = 1048,
123   CG_FLOAT2x2 = 1054,
124   CG_FLOAT3x3 = 1059,
125   CG_FLOAT4x4 = 1064,
126   CG_SAMPLER1D = 1065,
127   CG_SAMPLER2D = 1066,
128   CG_SAMPLER3D = 1067,
129   CG_SAMPLERRECT = 1068,
130   CG_SAMPLERCUBE = 1069,
131   CG_INT = 1093,
132   CG_INT1 = 1094
133 } CGtype;
134 
135 typedef int CGbool;
136 typedef void (* CGerrorCallbackFunc)(void);
137 
138 #endif /* HAVE_DYNAMIC_LINKING */
139 
140 int cc_cgglue_available(void);
141 
142 CGcontext glue_cgCreateContext(void);
143 void glue_cgDestroyContext(CGcontext);
144 CGbool glue_cgIsContext(CGcontext);
145 const char * glue_cgGetLastListing(CGcontext);
146 
147 CGprogram glue_cgCreateProgram(CGcontext, CGenum, const char *, CGprofile,
148                                const char *, const char **);
149 void glue_cgDestroyProgram(CGprogram);
150 CGbool glue_cgIsProgram(CGprogram);
151 
152 
153 const char * glue_cgGetProfileString(CGprofile);
154 
155 CGerror glue_cgGetError(void);
156 const char * glue_cgGetErrorString(CGerror);
157 void glue_cgSetErrorCallback(CGerrorCallbackFunc);
158 
159 CGbool glue_cgIsParameter(CGparameter);
160 CGtype glue_cgGetParameterType(CGparameter);
161 CGparameter glue_cgGetNamedParameter(CGprogram, const char *);
162 
163 const char * glue_cgGetTypeString(CGtype);
164 
165 CGbool glue_cgGLIsProfileSupported(CGprofile);
166 void glue_cgGLEnableProfile(CGprofile);
167 void glue_cgGLDisableProfile(CGprofile);
168 CGprofile glue_cgGLGetLatestProfile(CGGLenum);
169 
170 void glue_cgGLLoadProgram(CGprogram);
171 void glue_cgGLBindProgram(CGprogram);
172 
173 void glue_cgGLSetParameter1f(CGparameter, float);
174 void glue_cgGLSetParameter2f(CGparameter, float, float);
175 void glue_cgGLSetParameter3f(CGparameter, float, float, float);
176 void glue_cgGLSetParameter4f(CGparameter, float, float, float, float);
177 void glue_cgGLSetStateMatrixParameter(CGparameter, CGGLenum, CGGLenum);
178 
179 void glue_cgGLSetParameterArray1f(CGparameter, long, long, const float *);
180 void glue_cgGLSetParameterArray2f(CGparameter, long, long, const float *);
181 void glue_cgGLSetParameterArray3f(CGparameter, long, long, const float *);
182 void glue_cgGLSetParameterArray4f(CGparameter, long, long, const float *);
183 
184 void glue_cgGLSetMatrixParameterfc(CGparameter, const float *);
185 void glue_cgGLSetMatrixParameterArrayfc(CGparameter, long, long, const float *);
186 
187 int glue_cgGetArrayDimension(CGparameter);
188 int glue_cgGetArraySize(CGparameter, int);
189 
190 /* texture parameters */
191 void glue_cgGLSetManageTextureParameters(CGcontext, CGbool);
192 
193 /* CgFx */
194 int glue_cgglue_cgfx_available();
195 CGeffect glue_cgCreateEffect(CGcontext, const char *, const char **);
196 CGprogram glue_cgCreateProgramFromEffect(CGeffect, CGprofile, const char * entry, const char ** args);
197 void glue_cgDestroyEffect(CGeffect);
198 CGbool glue_cgIsEffect(CGeffect);
199 void glue_cgGLRegisterStates(CGcontext);
200 
201 CGtechnique glue_cgGetFirstTechnique(CGeffect);
202 CGtechnique glue_cgGetNextTechnique(CGtechnique);
203 CGbool glue_cgValidateTechnique(CGtechnique);
204 
205 CGpass glue_cgGetFirstPass(CGtechnique);
206 CGpass glue_cgGetNextPass(CGpass);
207 void glue_cgSetPassState(CGpass);
208 void glue_cgResetPassState(CGpass);
209 
210 #ifdef __cplusplus
211 }
212 #endif /* __cplusplus */
213 
214 #endif /* !COIN_GLUE_CG_H */
215