1 /*
2 * Copyright (c) 2012-2016, Bruno Levy
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * If you modify this software, you should include a notice giving the
30 * name of the person performing the modification, the date of modification,
31 * and the reason for such modification.
32 *
33 * Contact: Bruno Levy
34 *
35 * Bruno.Levy@inria.fr
36 * http://www.loria.fr/~levy
37 *
38 * ALICE Project
39 * LORIA, INRIA Lorraine,
40 * Campus Scientifique, BP 239
41 * 54506 VANDOEUVRE LES NANCY CEDEX
42 * FRANCE
43 *
44 */
45
46 #ifndef GEOGRAM_GFX_GLUP_GLUP_PRIVATE
47 #define GEOGRAM_GFX_GLUP_GLUP_PRIVATE
48
49 #include <geogram_gfx/GLUP/GLUP.h>
50 #include <geogram_gfx/GLUP/GLUP_context.h>
51
52 /**
53 * \file geogram_gfx/GLUP/GLUP_private.h
54 * \brief Slightly faster GLUP functions, not part of the API (do not use in
55 * client code).
56 */
57
58
59 namespace GLUP {
60 using namespace GEO;
61 extern GLUP_API Context* current_context_;
62 }
63
glupPrivateBegin(GLUPprimitive primitive)64 inline void glupPrivateBegin(GLUPprimitive primitive) {
65 GLUP::current_context_->begin(primitive);
66 }
67
glupPrivateEnd()68 inline void glupPrivateEnd() {
69 GLUP::current_context_->end();
70 }
71
glupPrivateVertex2fv(const GLUPfloat * xy)72 inline void glupPrivateVertex2fv(const GLUPfloat* xy) {
73 GLUP::current_context_->immediate_vertex(xy[0], xy[1]);
74 }
75
glupPrivateVertex3fv(const GLUPfloat * xyz)76 inline void glupPrivateVertex3fv(const GLUPfloat* xyz) {
77 GLUP::current_context_->immediate_vertex(xyz[0], xyz[1], xyz[2]);
78 }
79
glupPrivateVertex4fv(const GLUPfloat * xyzw)80 inline void glupPrivateVertex4fv(const GLUPfloat* xyzw) {
81 GLUP::current_context_->immediate_vertex(
82 xyzw[0], xyzw[1], xyzw[2], xyzw[3]
83 );
84 }
85
glupPrivateVertex2dv(const GLUPdouble * xy)86 inline void glupPrivateVertex2dv(const GLUPdouble* xy) {
87 GLUP::current_context_->immediate_vertex(
88 GLfloat(xy[0]),
89 GLfloat(xy[1])
90 );
91 }
92
glupPrivateVertex3dv(const GLUPdouble * xyz)93 inline void glupPrivateVertex3dv(const GLUPdouble* xyz) {
94 GLUP::current_context_->immediate_vertex(
95 GLfloat(xyz[0]),
96 GLfloat(xyz[1]),
97 GLfloat(xyz[2])
98 );
99 }
100
glupPrivateVertex4dv(const GLUPdouble * xyzw)101 inline void glupPrivateVertex4dv(const GLUPdouble* xyzw) {
102 GLUP::current_context_->immediate_vertex(
103 GLfloat(xyzw[0]),
104 GLfloat(xyzw[1]),
105 GLfloat(xyzw[2]),
106 GLfloat(xyzw[3])
107 );
108 }
109
glupPrivateVertex2f(GLUPfloat x,GLUPfloat y)110 inline void glupPrivateVertex2f(GLUPfloat x, GLUPfloat y) {
111 GLUP::current_context_->immediate_vertex(x,y);
112 }
113
glupPrivateVertex3f(GLUPfloat x,GLUPfloat y,GLUPfloat z)114 inline void glupPrivateVertex3f(GLUPfloat x, GLUPfloat y, GLUPfloat z) {
115 GLUP::current_context_->immediate_vertex(x,y,z);
116 }
117
glupPrivateVertex4f(GLUPfloat x,GLUPfloat y,GLUPfloat z,GLUPfloat w)118 inline void glupPrivateVertex4f(
119 GLUPfloat x, GLUPfloat y, GLUPfloat z, GLUPfloat w
120 ) {
121 GLUP::current_context_->immediate_vertex(x,y,z,w);
122 }
123
glupPrivateVertex2d(GLUPdouble x,GLUPdouble y)124 inline void glupPrivateVertex2d(GLUPdouble x, GLUPdouble y) {
125 GLUP::current_context_->immediate_vertex(
126 GLfloat(x),
127 GLfloat(y)
128 );
129 }
130
glupPrivateVertex3d(GLUPdouble x,GLUPdouble y,GLUPdouble z)131 inline void glupPrivateVertex3d(GLUPdouble x, GLUPdouble y, GLUPdouble z) {
132 GLUP::current_context_->immediate_vertex(
133 GLfloat(x),
134 GLfloat(y),
135 GLfloat(z)
136 );
137 }
138
glupPrivateVertex4d(GLUPdouble x,GLUPdouble y,GLUPdouble z,GLUPdouble w)139 inline void glupPrivateVertex4d(
140 GLUPdouble x, GLUPdouble y, GLUPdouble z, GLUPdouble w
141 ) {
142 GLUP::current_context_->immediate_vertex(
143 GLfloat(x),
144 GLfloat(y),
145 GLfloat(z),
146 GLfloat(w)
147 );
148 }
149
glupPrivateColor3fv(const GLUPfloat * rgb)150 inline void glupPrivateColor3fv(const GLUPfloat* rgb) {
151 GLUP::current_context_->immediate_color(rgb[0], rgb[1], rgb[2]);
152 }
153
glupPrivateColor4fv(const GLUPfloat * rgba)154 inline void glupPrivateColor4fv(const GLUPfloat* rgba) {
155 GLUP::current_context_->immediate_color(rgba[0], rgba[1], rgba[2], rgba[3]);
156 }
157
glupPrivateColor3dv(const GLUPdouble * rgb)158 inline void glupPrivateColor3dv(const GLUPdouble* rgb) {
159 GLUP::current_context_->immediate_color(
160 GLfloat(rgb[0]),
161 GLfloat(rgb[1]),
162 GLfloat(rgb[2])
163 );
164 }
165
glupPrivateColor4dv(const GLUPdouble * rgba)166 inline void glupPrivateColor4dv(const GLUPdouble* rgba) {
167 GLUP::current_context_->immediate_color(
168 GLfloat(rgba[0]),
169 GLfloat(rgba[1]),
170 GLfloat(rgba[2]),
171 GLfloat(rgba[3])
172 );
173 }
174
glupPrivateColor3f(GLUPfloat r,GLUPfloat g,GLUPfloat b)175 inline void glupPrivateColor3f(GLUPfloat r, GLUPfloat g, GLUPfloat b) {
176 GLUP::current_context_->immediate_color(r, g, b);
177 }
178
glupPrivateColor4f(GLUPfloat r,GLUPfloat g,GLUPfloat b,GLUPfloat a)179 inline void glupPrivateColor4f(
180 GLUPfloat r, GLUPfloat g, GLUPfloat b, GLUPfloat a
181 ) {
182 GLUP::current_context_->immediate_color(r, g, b, a);
183 }
184
glupPrivateColor3d(GLUPdouble r,GLUPdouble g,GLUPdouble b)185 inline void glupPrivateColor3d(GLUPdouble r, GLUPdouble g, GLUPdouble b) {
186 GLUP::current_context_->immediate_color(
187 GLfloat(r),
188 GLfloat(g),
189 GLfloat(b)
190 );
191 }
192
glupPrivateColor4d(GLUPdouble r,GLUPdouble g,GLUPdouble b,GLUPdouble a)193 inline void glupPrivateColor4d(
194 GLUPdouble r, GLUPdouble g, GLUPdouble b, GLUPdouble a
195 ) {
196 GLUP::current_context_->immediate_color(
197 GLfloat(r),
198 GLfloat(g),
199 GLfloat(b),
200 GLfloat(a)
201 );
202 }
203
glupPrivateTexCoord2fv(const GLUPfloat * st)204 inline void glupPrivateTexCoord2fv(const GLUPfloat* st) {
205 GLUP::current_context_->immediate_tex_coord(st[0], st[1]);
206 }
207
glupPrivateTexCoord3fv(const GLUPfloat * stu)208 inline void glupPrivateTexCoord3fv(const GLUPfloat* stu) {
209 GLUP::current_context_->immediate_tex_coord(stu[0], stu[1], stu[2]);
210 }
211
glupPrivateTexCoord4fv(const GLUPfloat * stuv)212 inline void glupPrivateTexCoord4fv(const GLUPfloat* stuv) {
213 GLUP::current_context_->immediate_tex_coord(
214 stuv[0], stuv[1], stuv[2], stuv[3]
215 );
216 }
217
glupPrivateTexCoord2dv(const GLUPdouble * st)218 inline void glupPrivateTexCoord2dv(const GLUPdouble* st) {
219 GLUP::current_context_->immediate_tex_coord(
220 GLfloat(st[0]),
221 GLfloat(st[1])
222 );
223 }
224
glupPrivateTexCoord3dv(const GLUPdouble * stu)225 inline void glupPrivateTexCoord3dv(const GLUPdouble* stu) {
226 GLUP::current_context_->immediate_tex_coord(
227 GLfloat(stu[0]),
228 GLfloat(stu[1]),
229 GLfloat(stu[2])
230 );
231 }
232
glupPrivateTexCoord4dv(const GLUPdouble * stuv)233 inline void glupPrivateTexCoord4dv(const GLUPdouble* stuv) {
234 GLUP::current_context_->immediate_tex_coord(
235 GLfloat(stuv[0]),
236 GLfloat(stuv[1]),
237 GLfloat(stuv[2]),
238 GLfloat(stuv[3])
239 );
240 }
241
glupPrivateTexCoord1f(GLUPfloat s)242 inline void glupPrivateTexCoord1f(GLUPfloat s) {
243 GLUP::current_context_->immediate_tex_coord(s);
244 }
245
glupPrivateTexCoord2f(GLUPfloat s,GLUPfloat t)246 inline void glupPrivateTexCoord2f(GLUPfloat s, GLUPfloat t) {
247 GLUP::current_context_->immediate_tex_coord(s,t);
248 }
249
glupPrivateTexCoord3f(GLUPfloat s,GLUPfloat t,GLUPfloat u)250 inline void glupPrivateTexCoord3f(GLUPfloat s, GLUPfloat t, GLUPfloat u) {
251 GLUP::current_context_->immediate_tex_coord(s,t,u);
252 }
253
glupPrivateTexCoord4f(GLUPfloat s,GLUPfloat t,GLUPfloat u,GLUPfloat v)254 inline void glupPrivateTexCoord4f(
255 GLUPfloat s, GLUPfloat t, GLUPfloat u, GLUPfloat v
256 ) {
257 GLUP::current_context_->immediate_tex_coord(s,t,u,v);
258 }
259
glupPrivateTexCoord1d(GLUPdouble s)260 inline void glupPrivateTexCoord1d(GLUPdouble s) {
261 GLUP::current_context_->immediate_tex_coord(
262 GLfloat(s)
263 );
264 }
265
glupPrivateTexCoord2d(GLUPdouble s,GLUPdouble t)266 inline void glupPrivateTexCoord2d(GLUPdouble s, GLUPdouble t) {
267 GLUP::current_context_->immediate_tex_coord(
268 GLfloat(s),
269 GLfloat(t)
270 );
271 }
272
glupPrivateTexCoord3d(GLUPdouble s,GLUPdouble t,GLUPdouble u)273 inline void glupPrivateTexCoord3d(GLUPdouble s, GLUPdouble t, GLUPdouble u) {
274 GLUP::current_context_->immediate_tex_coord(
275 GLfloat(s),
276 GLfloat(t),
277 GLfloat(u)
278 );
279 }
280
glupPrivateTexCoord4d(GLUPdouble s,GLUPdouble t,GLUPdouble u,GLUPdouble v)281 inline void glupPrivateTexCoord4d(
282 GLUPdouble s, GLUPdouble t, GLUPdouble u, GLUPdouble v
283 ) {
284 GLUP::current_context_->immediate_tex_coord(
285 GLfloat(s),
286 GLfloat(t),
287 GLfloat(u),
288 GLfloat(v)
289 );
290 }
291
292
glupPrivateNormal3fv(GLUPfloat * xyz)293 inline void glupPrivateNormal3fv(GLUPfloat* xyz) {
294 GLUP::current_context_->immediate_normal(
295 xyz[0],xyz[1],xyz[2]
296 );
297 }
298
glupPrivateNormal3f(GLUPfloat x,GLUPfloat y,GLUPfloat z)299 inline void glupPrivateNormal3f(GLUPfloat x, GLUPfloat y, GLUPfloat z) {
300 GLUP::current_context_->immediate_normal(
301 x,y,z
302 );
303 }
304
glupPrivateNormal3dv(GLUPdouble * xyz)305 inline void glupPrivateNormal3dv(GLUPdouble* xyz) {
306 GLUP::current_context_->immediate_normal(
307 GLfloat(xyz[0]),
308 GLfloat(xyz[1]),
309 GLfloat(xyz[2])
310 );
311 }
312
glupPrivateNormal3d(GLUPdouble x,GLUPdouble y,GLUPdouble z)313 inline void glupPrivateNormal3d(GLUPdouble x, GLUPdouble y, GLUPdouble z) {
314 GLUP::current_context_->immediate_normal(
315 GLfloat(x),
316 GLfloat(y),
317 GLfloat(z)
318 );
319 }
320
321 #endif
322