Fix direct-casting BOOL / int or BOOL / bool
[scilab.git] / scilab / modules / graphic_export / src / cpp / JoGLInterface.cpp
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2008 - INRIA - Jean-Baptiste Silvy 
4  * desc : C++ interface of JoGL function used by GL2PS
5  *
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11  *
12  */
13
14 #include "JoGLInterface.h"
15 #include "GL2PSToJOGL.hxx"
16 #include "JOGLConstant.hxx"
17
18 extern "C"
19 {
20 #include "getScilabJavaVM.h"
21 }
22
23 #define VIEWPORT_SIZE 4
24 #define COLOR_CLEAR_VALUE_SIZE 4
25 #define CURRENT_RASTER_POSITION_SIZE 4
26 #define CURRENT_RASTER_COLOR_SIZE 4
27
28 using namespace org_scilab_modules_graphic_export;
29
30 /*---------------------------------------------------------------------------------*/
31 void joglFeedbackBuffer(int size, int type)
32 {
33     GL2PSToJOGL::glFeedbackBuffer(getScilabJavaVM(), size, type);
34 }
35
36 /*---------------------------------------------------------------------------------*/
37 void joglReadFeedbackBuffer(int size, float *buffer)
38 {
39     float *javaBuffer = GL2PSToJOGL::readFeedbackBuffer(getScilabJavaVM(), size);
40
41     // copy the computed buffer into buffer
42     for (int i = 0; i < size; i++)
43     {
44         buffer[i] = javaBuffer[i];
45     }
46     delete[]javaBuffer;
47
48 }
49
50 /*---------------------------------------------------------------------------------*/
51 BOOL joglIsEnabled(int cap)
52 {
53     return booltoBOOL((GL2PSToJOGL::glIsEnabled(getScilabJavaVM(), cap) == true));
54 }
55
56 /*---------------------------------------------------------------------------------*/
57 void joglBegin(int mode)
58 {
59     GL2PSToJOGL::glBegin(getScilabJavaVM(), mode);
60 }
61
62 /*---------------------------------------------------------------------------------*/
63 void joglVertex3f(float x, float y, float z)
64 {
65     GL2PSToJOGL::glVertex3f(getScilabJavaVM(), x, y, z);
66 }
67
68 /*---------------------------------------------------------------------------------*/
69 void joglEnd(void)
70 {
71     GL2PSToJOGL::glEnd(getScilabJavaVM());
72 }
73
74 /*---------------------------------------------------------------------------------*/
75 void joglGetCurrentRasterPositionValid(BOOL * value)
76 {
77     *value = booltoBOOL((GL2PSToJOGL::glGetCurrentRasterPositionValid(getScilabJavaVM()) == true));
78 }
79
80 /*---------------------------------------------------------------------------------*/
81 int joglRenderMode(int mode)
82 {
83     return GL2PSToJOGL::glRenderMode(getScilabJavaVM(), mode);
84 }
85
86 /*---------------------------------------------------------------------------------*/
87 void joglGetLineStipplePattern(int *value)
88 {
89     *value = GL2PSToJOGL::glGetLineStipplePattern(getScilabJavaVM());
90 }
91
92 /*---------------------------------------------------------------------------------*/
93 void joglGetLineStippleRepeat(int *value)
94 {
95     *value = GL2PSToJOGL::glGetLineStippleRepeat(getScilabJavaVM());
96 }
97
98 /*---------------------------------------------------------------------------------*/
99 void joglGetIndexClearValue(int *value)
100 {
101     *value = GL2PSToJOGL::glGetIndexClearValue(getScilabJavaVM());
102 }
103
104 /*---------------------------------------------------------------------------------*/
105 void joglGetViewport(int *viewPort)
106 {
107     int *javaViewPort = GL2PSToJOGL::glGetViewport(getScilabJavaVM());
108
109     for (int i = 0; i < VIEWPORT_SIZE; i++)
110     {
111         viewPort[i] = javaViewPort[i];
112     }
113     delete[]javaViewPort;
114 }
115
116 /*---------------------------------------------------------------------------------*/
117 void joglGetBlendSrc(int *value)
118 {
119     *value = GL2PSToJOGL::glGetBlendSrc(getScilabJavaVM());
120 }
121
122 /*---------------------------------------------------------------------------------*/
123 void joglGetBlendDst(int *value)
124 {
125     *value = GL2PSToJOGL::glGetBlendDst(getScilabJavaVM());
126 }
127
128 /*---------------------------------------------------------------------------------*/
129 void joglGetColorClearValue(float *color)
130 {
131     float *javaColor = GL2PSToJOGL::glGetColorClearValue(getScilabJavaVM());
132
133     for (int i = 0; i < COLOR_CLEAR_VALUE_SIZE; i++)
134     {
135         color[i] = javaColor[i];
136     }
137     delete[]javaColor;
138 }
139
140 /*---------------------------------------------------------------------------------*/
141 void joglGetPolygonOffsetFactor(float *value)
142 {
143     *value = GL2PSToJOGL::glGetPolygonOffsetFactor(getScilabJavaVM());
144 }
145
146 /*---------------------------------------------------------------------------------*/
147 void joglGetPolygonOffsetUnits(float *value)
148 {
149     *value = GL2PSToJOGL::glGetPolygonOffsetUnits(getScilabJavaVM());
150 }
151
152 /*---------------------------------------------------------------------------------*/
153 void joglGetCurrentRasterPosition(float *position)
154 {
155     float *javaPos = GL2PSToJOGL::glGetCurrentRasterPosition(getScilabJavaVM());
156
157     for (int i = 0; i < CURRENT_RASTER_POSITION_SIZE; i++)
158     {
159         position[i] = javaPos[i];
160     }
161     delete[]javaPos;
162 }
163
164 /*---------------------------------------------------------------------------------*/
165 void joglGetCurrentRasterColor(float *color)
166 {
167     float *javaColor = GL2PSToJOGL::glGetCurrentRasterColor(getScilabJavaVM());
168
169     for (int i = 0; i < CURRENT_RASTER_COLOR_SIZE; i++)
170     {
171         color[i] = javaColor[i];
172     }
173     delete[]javaColor;
174 }
175
176 /*---------------------------------------------------------------------------------*/
177 void joglPassThrough(float token)
178 {
179     GL2PSToJOGL::glPassThrough(getScilabJavaVM(), token);
180 }
181
182 /*---------------------------------------------------------------------------------*/
183
184 /*---------------------------------------------------------------------------------*/
185 int joglGL_RGBA(void)
186 {
187     return JOGLConstant::get_GL_RGBA(getScilabJavaVM());
188 }
189
190 /*---------------------------------------------------------------------------------*/
191 int joglGL_RGB(void)
192 {
193     return JOGLConstant::get_GL_RGB(getScilabJavaVM());
194 }
195
196 /*---------------------------------------------------------------------------------*/
197 int joglGL_SRC_ALPHA(void)
198 {
199     return JOGLConstant::get_GL_SRC_ALPHA(getScilabJavaVM());
200 }
201
202 /*---------------------------------------------------------------------------------*/
203 int joglGL_ONE_MINUS_SRC_ALPHA(void)
204 {
205     return JOGLConstant::get_GL_ONE_MINUS_SRC_ALPHA(getScilabJavaVM());
206 }
207
208 /*---------------------------------------------------------------------------------*/
209 int joglGL_ONE(void)
210 {
211     return JOGLConstant::get_GL_ONE(getScilabJavaVM());
212 }
213
214 /*---------------------------------------------------------------------------------*/
215 int joglGL_ZERO(void)
216 {
217     return JOGLConstant::get_GL_ZERO(getScilabJavaVM());
218 }
219
220 /*---------------------------------------------------------------------------------*/
221 int joglGL_COLOR_INDEX(void)
222 {
223     return JOGLConstant::get_GL_COLOR_INDEX(getScilabJavaVM());
224 }
225
226 /*---------------------------------------------------------------------------------*/
227 int joglGL_POINT_TOKEN(void)
228 {
229     return JOGLConstant::get_GL_POINT_TOKEN(getScilabJavaVM());
230 }
231
232 /*---------------------------------------------------------------------------------*/
233 int joglGL_LINE_TOKEN(void)
234 {
235     return JOGLConstant::get_GL_LINE_TOKEN(getScilabJavaVM());
236 }
237
238 /*---------------------------------------------------------------------------------*/
239 int joglGL_LINE_RESET_TOKEN(void)
240 {
241     return JOGLConstant::get_GL_LINE_RESET_TOKEN(getScilabJavaVM());
242 }
243
244 /*---------------------------------------------------------------------------------*/
245 int joglGL_POLYGON_TOKEN(void)
246 {
247     return JOGLConstant::get_GL_POLYGON_TOKEN(getScilabJavaVM());
248 }
249
250 /*---------------------------------------------------------------------------------*/
251 int joglGL_BITMAP_TOKEN(void)
252 {
253     return JOGLConstant::get_GL_BITMAP_TOKEN(getScilabJavaVM());
254 }
255
256 /*---------------------------------------------------------------------------------*/
257 int joglGL_DRAW_PIXEL_TOKEN(void)
258 {
259     return JOGLConstant::get_GL_DRAW_PIXEL_TOKEN(getScilabJavaVM());
260 }
261
262 /*---------------------------------------------------------------------------------*/
263 int joglGL_COPY_PIXEL_TOKEN(void)
264 {
265     return JOGLConstant::get_GL_COPY_PIXEL_TOKEN(getScilabJavaVM());
266 }
267
268 /*---------------------------------------------------------------------------------*/
269 int joglGL_PASS_THROUGH_TOKEN(void)
270 {
271     return JOGLConstant::get_GL_PASS_THROUGH_TOKEN(getScilabJavaVM());
272 }
273
274 /*---------------------------------------------------------------------------------*/
275 int joglGL_FEEDBACK(void)
276 {
277     return JOGLConstant::get_GL_FEEDBACK(getScilabJavaVM());
278 }
279
280 /*---------------------------------------------------------------------------------*/
281 int joglGL_COLOR_CLEAR_VALUE(void)
282 {
283     return JOGLConstant::get_GL_COLOR_CLEAR_VALUE(getScilabJavaVM());
284 }
285
286 /*---------------------------------------------------------------------------------*/
287 int joglGL_INDEX_CLEAR_VALUE(void)
288 {
289     return JOGLConstant::get_GL_INDEX_CLEAR_VALUE(getScilabJavaVM());
290 }
291
292 /*---------------------------------------------------------------------------------*/
293 int joglGL_RENDER(void)
294 {
295     return JOGLConstant::get_GL_RENDER(getScilabJavaVM());
296 }
297
298 /*---------------------------------------------------------------------------------*/
299 int joglGL_VIEWPORT(void)
300 {
301     return JOGLConstant::get_GL_VIEWPORT(getScilabJavaVM());
302 }
303
304 /*---------------------------------------------------------------------------------*/
305 int joglGL_BLEND(void)
306 {
307     return JOGLConstant::get_GL_BLEND(getScilabJavaVM());
308 }
309
310 /*---------------------------------------------------------------------------------*/
311 int joglGL_BLEND_SRC(void)
312 {
313     return JOGLConstant::get_GL_BLEND_SRC(getScilabJavaVM());
314 }
315
316 /*---------------------------------------------------------------------------------*/
317 int joglGL_BLEND_DST(void)
318 {
319     return JOGLConstant::get_GL_BLEND_DST(getScilabJavaVM());
320 }
321
322 /*---------------------------------------------------------------------------------*/
323 int joglGL_3D_COLOR(void)
324 {
325     return JOGLConstant::get_GL_3D_COLOR(getScilabJavaVM());
326 }
327
328 /*---------------------------------------------------------------------------------*/
329 int joglGL_FLOAT(void)
330 {
331     return JOGLConstant::get_GL_FLOAT(getScilabJavaVM());
332 }
333
334 /*---------------------------------------------------------------------------------*/
335 /* Calixte */
336 int joglGL_UNSIGNED_BYTE(void)
337 {
338     return JOGLConstant::get_GL_UNSIGNED_BYTE(getScilabJavaVM());
339 }
340
341 /*---------------------------------------------------------------------------------*/
342 int joglGL_POINTS(void)
343 {
344     return JOGLConstant::get_GL_POINTS(getScilabJavaVM());
345 }
346
347 /*---------------------------------------------------------------------------------*/
348 int joglGL_POLYGON_OFFSET_FACTOR(void)
349 {
350     return JOGLConstant::get_GL_POLYGON_OFFSET_FACTOR(getScilabJavaVM());
351 }
352
353 /*---------------------------------------------------------------------------------*/
354 int joglGL_POLYGON_OFFSET_UNITS(void)
355 {
356     return JOGLConstant::get_GL_POLYGON_OFFSET_UNITS(getScilabJavaVM());
357 }
358
359 /*---------------------------------------------------------------------------------*/
360 int joglGL_LINE_STIPPLE_PATTERN(void)
361 {
362     return JOGLConstant::get_GL_LINE_STIPPLE_PATTERN(getScilabJavaVM());
363 }
364
365 /*---------------------------------------------------------------------------------*/
366 int joglGL_LINE_STIPPLE_REPEAT(void)
367 {
368     return JOGLConstant::get_GL_LINE_STIPPLE_REPEAT(getScilabJavaVM());
369 }
370
371 /*---------------------------------------------------------------------------------*/