Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GLUP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
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  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 #ifndef GEOGRAM_GFX_GLUP_GLUP
41 #define GEOGRAM_GFX_GLUP_GLUP
42 
43 #include <geogram_gfx/api/defs.h>
44 #define GLUP_API GEOGRAM_GFX_API
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
60  typedef float GLUPfloat;
61  typedef double GLUPdouble;
62  typedef int GLUPint;
63  typedef unsigned int GLUPuint;
64  typedef int GLUPsizei;
65  typedef unsigned int GLUPenum;
66  typedef unsigned long int GLUPuint64;
67  typedef void GLUPvoid;
68  typedef int GLUPbitfield;
69 
70  enum {
71  GLUP_FALSE=0, GLUP_TRUE = 1
72  };
73 
74  typedef unsigned char GLUPboolean;
75 
80  /************************************************/
81 
90  typedef void* GLUPcontext;
91 
99 
104  void GLUP_API glupDeleteContext(GLUPcontext context);
105 
111 
118  GLUP_API const char* glupCurrentProfileName(void);
119 
124  void GLUP_API glupMakeCurrent(GLUPcontext context);
125 
132  void GLUP_API glupBindUniformState(GLUPuint program);
133 
138  /************************************************/
139 
145  typedef enum {
146  GLUP_LIGHTING =0,
147  GLUP_VERTEX_COLORS =1,
148  GLUP_TEXTURING =2,
149  GLUP_DRAW_MESH =3,
150  GLUP_CLIPPING =4,
151  GLUP_INDIRECT_TEXTURING =5,
152  GLUP_VERTEX_NORMALS =6,
153  GLUP_PICKING =7,
154  GLUP_ALPHA_DISCARD =8,
155  GLUP_NORMAL_MAPPING =9,
156  GLUP_PRIMITIVE_FILTERING =10
157  } GLUPtoggle;
158 
159  void GLUP_API glupEnable(GLUPtoggle toggle);
160  void GLUP_API glupDisable(GLUPtoggle toggle);
161  GLUPboolean GLUP_API glupIsEnabled(GLUPtoggle toggle);
162 
167  /************************************************/
168 
183  enum {
184  GLUP_TEXTURE_1D_UNIT=0,
185  GLUP_TEXTURE_2D_UNIT=1,
186  GLUP_TEXTURE_3D_UNIT=2,
187  GLUP_TEXTURE_PRIMITIVE_FILTERING_UNIT=3
188  };
189 
198  enum {
199  GLUP_TEXTURE_1D_TARGET=0x0DE1,
200  GLUP_TEXTURE_2D_TARGET=0x0DE1,
201  GLUP_TEXTURE_3D_TARGET=0x806F
202  };
203 
204  typedef enum {
205  GLUP_TEXTURE_1D=1,
206  GLUP_TEXTURE_2D=2,
207  GLUP_TEXTURE_3D=3
208  } GLUPtextureType;
209 
210  void GLUP_API glupTextureType(GLUPtextureType type);
211  GLUPtextureType GLUP_API glupGetTextureType(void);
212 
213  typedef enum {
214  GLUP_TEXTURE_REPLACE=0,
215  GLUP_TEXTURE_MODULATE=1,
216  GLUP_TEXTURE_ADD=2
217  } GLUPtextureMode;
218 
219  void GLUP_API glupTextureMode(GLUPtextureMode mode);
220  GLUPtextureMode GLUP_API glupGetTextureMode(void);
221 
226  /************************************************/
227 
228 
235  typedef enum {
236  GLUP_FRONT_COLOR=0,
237  GLUP_BACK_COLOR=1,
238  GLUP_MESH_COLOR=2,
239  GLUP_FRONT_AND_BACK_COLOR=3
240  } GLUPcolor;
241 
242  void GLUP_API glupSetColor4fv(GLUPcolor color, const GLUPfloat* rgba);
243  void GLUP_API glupGetColor4fv(GLUPcolor color, float* rgba);
244 
245  void GLUP_API glupSetColor3fv(GLUPcolor color, const GLUPfloat* rgba);
246  void GLUP_API glupSetColor4f(
247  GLUPcolor color, GLUPfloat r, GLUPfloat g, GLUPfloat b, GLUPfloat a
248  );
249  void GLUP_API glupSetColor3f(
250  GLUPcolor color, GLUPfloat r, GLUPfloat g, GLUPfloat b
251  );
252  void GLUP_API glupSetColor4dv(GLUPcolor color, const GLUPdouble* rgba);
253  void GLUP_API glupSetColor3dv(GLUPcolor color, const GLUPdouble* rgba);
254  void GLUP_API glupSetColor4d(
255  GLUPcolor color, GLUPdouble r, GLUPdouble g, GLUPdouble b, GLUPdouble a
256  );
257  void GLUP_API glupSetColor3d(
258  GLUPcolor color, GLUPdouble r, GLUPdouble g, GLUPdouble b
259  );
260 
261  void GLUP_API glupLightVector3f(GLUPfloat x, GLUPfloat y, GLUPfloat z);
262  void GLUP_API glupLightVector3fv(GLUPfloat* xyz);
263  void GLUP_API glupGetLightVector3fv(GLUPfloat* xyz);
264 
265  void GLUP_API glupSetPointSize(GLUPfloat size);
266  GLUPfloat GLUP_API glupGetPointSize(void);
267 
268  void GLUP_API glupSetMeshWidth(GLUPint width);
269  GLUPint GLUP_API glupGetMeshWidth(void);
270 
271  void GLUP_API glupSetCellsShrink(GLUPfloat x);
272  GLUPfloat GLUP_API glupGetCellsShrink(void);
273 
274  void GLUP_API glupSetAlphaThreshold(GLUPfloat x);
275  GLUPfloat GLUP_API glupGetAlphaThreshold(void);
276 
277  void GLUP_API glupSetSpecular(GLUPfloat x);
278  GLUPfloat GLUP_API glupGetSpecular(void);
279 
284  /************************************************/
285 
291  typedef enum {
292  GLUP_PICK_PRIMITIVE=1,
293  GLUP_PICK_CONSTANT=2
294  } GLUPpickingMode;
295 
296  void GLUP_API glupPickingMode(GLUPpickingMode mode);
297  GLUPpickingMode GLUP_API glupGetPickingMode(void);
298 
299  void GLUP_API glupPickingId(GLUPuint64 id);
300  GLUPuint64 GLUP_API glupGetPickingId(void);
301 
302  void GLUP_API glupBasePickingId(GLUPuint64 id);
303  GLUPuint64 GLUP_API glupGetBasePickingId(void);
304 
309  /************************************************/
310 
316  typedef enum {
317  GLUP_CLIP_STANDARD=0,
318  GLUP_CLIP_WHOLE_CELLS=1,
319  GLUP_CLIP_STRADDLING_CELLS=2,
320  GLUP_CLIP_SLICE_CELLS=3
321  } GLUPclipMode;
322 
329  void GLUP_API glupClipMode(GLUPclipMode mode);
330 
335  GLUPclipMode GLUP_API glupGetClipMode(void);
336 
346  void GLUP_API glupClipPlane(const GLUPdouble* eqn);
347 
353  void GLUP_API glupGetClipPlane(GLUPdouble* eqn);
354 
359  /************************************************/
360 
366  typedef enum {
367  GLUP_MODELVIEW_MATRIX = 0,
368  GLUP_PROJECTION_MATRIX = 1,
369  GLUP_TEXTURE_MATRIX = 2
370  } GLUPmatrix;
371 
372  void GLUP_API glupMatrixMode(GLUPmatrix matrix);
373  GLUPmatrix GLUP_API glupGetMatrixMode(void);
374  void GLUP_API glupPushMatrix(void);
375  void GLUP_API glupPopMatrix(void);
376 
384  void GLUP_API glupGetMatrixdv(GLUPmatrix matrix, GLUPdouble* ptr);
385 
393  void GLUP_API glupGetMatrixfv(GLUPmatrix matrix, GLUPfloat* ptr);
394 
395  void GLUP_API glupLoadIdentity(void);
396  void GLUP_API glupLoadMatrixf(const GLUPfloat* M);
397  void GLUP_API glupLoadMatrixd(const GLUPdouble* M);
398  void GLUP_API glupMultMatrixf(const GLUPfloat* M);
399  void GLUP_API glupMultMatrixd(const GLUPdouble* M);
400  void GLUP_API glupTranslatef(GLUPfloat x, GLUPfloat y, GLUPfloat z);
401  void GLUP_API glupTranslated(GLUPdouble x, GLUPdouble y, GLUPdouble z);
402  void GLUP_API glupScalef(GLUPfloat sx, GLUPfloat sy, GLUPfloat sz);
403  void GLUP_API glupScaled(GLUPdouble sx, GLUPdouble sy, GLUPdouble sz);
404  void GLUP_API glupRotatef(
405  GLUPfloat angle, GLUPfloat x, GLUPfloat y, GLUPfloat z
406  );
407  void GLUP_API glupRotated(
408  GLUPdouble angle, GLUPdouble x, GLUPdouble y, GLUPdouble z
409  );
410  void GLUP_API glupOrtho(
411  GLUPdouble left, GLUPdouble right,
412  GLUPdouble bottom, GLUPdouble top,
413  GLUPdouble nearVal, GLUPdouble farVal
414  );
415  void GLUP_API glupOrtho2D(
416  GLUPdouble left, GLUPdouble right, GLUPdouble bottom, GLUPdouble top
417  );
418  void GLUP_API glupFrustum(
419  GLUPdouble left, GLUPdouble right,
420  GLUPdouble bottom, GLUPdouble top,
421  GLUPdouble nearVal, GLUPdouble farVal
422  );
423  void GLUP_API glupPerspective(
424  GLUPdouble fovy, GLUPdouble aspect,
425  GLUPdouble zNear, GLUPdouble zFar
426  );
427 
428  GLUPint GLUP_API glupProject(
429  GLUPdouble objx, GLUPdouble objy, GLUPdouble objz,
430  const GLUPdouble modelMatrix[16],
431  const GLUPdouble projMatrix[16],
432  const GLUPint viewport[4],
433  GLUPdouble* winx, GLUPdouble* winy, GLUPdouble* winz
434  );
435 
436  GLUPboolean GLUP_API glupUnProject(
437  GLUPdouble winx, GLUPdouble winy, GLUPdouble winz,
438  const GLUPdouble modelMatrix[16],
439  const GLUPdouble projMatrix[16],
440  const GLUPint viewport[4],
441  GLUPdouble *objx, GLUPdouble *objy, GLUPdouble *objz
442  );
443 
444  GLUPboolean GLUP_API glupInvertMatrixfv(
445  GLUPfloat Minvert[16],
446  const GLUPfloat M[16]
447  );
448 
449  GLUPboolean GLUP_API glupInvertMatrixdv(
450  GLUPdouble Minvert[16],
451  const GLUPdouble M[16]
452  );
453 
458  /************************************************/
459 
470  typedef enum {
471  GLUP_POINTS = 0,
472  GLUP_LINES = 1,
473  GLUP_TRIANGLES = 2,
474  GLUP_QUADS = 3,
475  GLUP_TETRAHEDRA = 4,
476  GLUP_HEXAHEDRA = 5,
477  GLUP_PRISMS = 6,
478  GLUP_PYRAMIDS = 7,
479  GLUP_CONNECTORS = 8,
480  GLUP_SPHERES = 9,
481  GLUP_RESERVED_PRIMITIVE_1 = 10,
482  GLUP_NB_PRIMITIVES = 11
483  } GLUPprimitive;
484 
493  GLUPboolean GLUP_API glupPrimitiveSupportsArrayMode(GLUPprimitive prim);
494 
495  void GLUP_API glupDrawArrays(
496  GLUPprimitive primitive, GLUPint first, GLUPsizei count
497  );
498 
499  void GLUP_API glupDrawElements(
500  GLUPprimitive primitive, GLUPsizei count,
501  GLUPenum type, const GLUPvoid* indices
502  );
503 
504  void GLUP_API glupBegin(GLUPprimitive primitive);
505  void GLUP_API glupEnd(void);
506 
507  void GLUP_API glupVertex2fv(const GLUPfloat* xy);
508  void GLUP_API glupVertex3fv(const GLUPfloat* xyz);
509  void GLUP_API glupVertex4fv(const GLUPfloat* xyzw);
510 
511  void GLUP_API glupVertex2dv(const GLUPdouble* xy);
512  void GLUP_API glupVertex3dv(const GLUPdouble* xyz);
513  void GLUP_API glupVertex4dv(const GLUPdouble* xyzw);
514 
515  void GLUP_API glupVertex2f(GLUPfloat x, GLUPfloat y);
516  void GLUP_API glupVertex3f(GLUPfloat x, GLUPfloat y, GLUPfloat z);
517  void GLUP_API glupVertex4f(
518  GLUPfloat x, GLUPfloat y, GLUPfloat z, GLUPfloat w
519  );
520 
521  void GLUP_API glupVertex2d(GLUPdouble x, GLUPdouble y);
522  void GLUP_API glupVertex3d(GLUPdouble x, GLUPdouble y, GLUPdouble z);
523  void GLUP_API glupVertex4d(
524  GLUPdouble x, GLUPdouble y, GLUPdouble z, GLUPdouble w
525  );
526 
527  void GLUP_API glupColor3fv(const GLUPfloat* rgb);
528  void GLUP_API glupColor4fv(const GLUPfloat* rgba);
529 
530  void GLUP_API glupColor3dv(const GLUPdouble* rgb);
531  void GLUP_API glupColor4dv(const GLUPdouble* rgba);
532 
533  void GLUP_API glupColor3f(GLUPfloat r, GLUPfloat g, GLUPfloat b);
534  void GLUP_API glupColor4f(
535  GLUPfloat r, GLUPfloat g, GLUPfloat b, GLUPfloat a
536  );
537 
538  void GLUP_API glupColor3d(GLUPdouble r, GLUPdouble g, GLUPdouble b);
539  void GLUP_API glupColor4d(
540  GLUPdouble r, GLUPdouble g, GLUPdouble b, GLUPdouble a
541  );
542 
543  void GLUP_API glupTexCoord2fv(const GLUPfloat* st);
544  void GLUP_API glupTexCoord3fv(const GLUPfloat* stu);
545  void GLUP_API glupTexCoord4fv(const GLUPfloat* stuv);
546 
547  void GLUP_API glupTexCoord2dv(const GLUPdouble* st);
548  void GLUP_API glupTexCoord3dv(const GLUPdouble* stu);
549  void GLUP_API glupTexCoord4dv(const GLUPdouble* stuv);
550 
551  void GLUP_API glupTexCoord1f(GLUPfloat s);
552  void GLUP_API glupTexCoord2f(GLUPfloat s, GLUPfloat t);
553  void GLUP_API glupTexCoord3f(GLUPfloat s, GLUPfloat t, GLUPfloat u);
554  void GLUP_API glupTexCoord4f(
555  GLUPfloat s, GLUPfloat t, GLUPfloat u, GLUPfloat v
556  );
557 
558  void GLUP_API glupTexCoord1d(GLUPdouble s);
559  void GLUP_API glupTexCoord2d(GLUPdouble s, GLUPdouble t);
560  void GLUP_API glupTexCoord3d(GLUPdouble s, GLUPdouble t, GLUPdouble u);
561  void GLUP_API glupTexCoord4d(
562  GLUPdouble s, GLUPdouble t, GLUPdouble u, GLUPdouble v
563  );
564 
565 
566  void GLUP_API glupNormal3fv(GLUPfloat* xyz);
567  void GLUP_API glupNormal3f(GLUPfloat x, GLUPfloat y, GLUPfloat z);
568 
569  void GLUP_API glupNormal3dv(GLUPdouble* xyz);
570  void GLUP_API glupNormal3d(GLUPdouble x, GLUPdouble y, GLUPdouble z);
571 
572 
583  void GLUP_API glupUseProgram(GLUPuint program);
584 
589  /************************************************/
590 
604  void GLUP_API glupGenVertexArrays(GLUPsizei n, GLUPuint* arrays);
605 
614  void GLUP_API glupDeleteVertexArrays(GLUPsizei n, const GLUPuint *arrays);
615 
616 
623  void GLUP_API glupBindVertexArray(GLUPuint array);
624 
632  GLUPuint GLUP_API glupGetVertexArrayBinding(void);
633 
638  /************************************************/
639 
652  GLUP_API const char* glupUniformStateDeclaration(void);
653 
664  GLUP_API GLUPuint glupCompileShader(
665  GLUPenum target, GLUPprimitive primitive, const char* source
666  );
667 
683  GLUP_API GLUPuint glupCompileProgram(const char* source);
684 
689 #ifdef __cplusplus
690 }
691 #endif
692 
693 #endif
void GLUP_API glupGetMatrixdv(GLUPmatrix matrix, GLUPdouble *ptr)
Queries a GLUP matrix.
GLUPcontext GLUP_API glupCreateContext(void)
Creates a new GLUP context.
GLUP_API const char * glupUniformStateDeclaration(void)
Gets the GLSL declaration of GLUP uniform state.
void GLUP_API glupGetMatrixfv(GLUPmatrix matrix, GLUPfloat *ptr)
Queries a GLUP matrix.
void GLUP_API glupMakeCurrent(GLUPcontext context)
Makes a GLUP context the current one.
GLUPclipMode GLUP_API glupGetClipMode(void)
Gets the clipping mode.
void GLUP_API glupBindUniformState(GLUPuint program)
Binds the GLUP uniform state to a program.
GLUPboolean GLUP_API glupPrimitiveSupportsArrayMode(GLUPprimitive prim)
Tests whether a given GLUP primitive supports array mode.
GLUPuint GLUP_API glupGetVertexArrayBinding(void)
Gets the name of the bound vertex array object.
void GLUP_API glupDeleteVertexArrays(GLUPsizei n, const GLUPuint *arrays)
Deletes vertex array objects.
void GLUP_API glupClipMode(GLUPclipMode mode)
Sets the current clipping mode.
void GLUP_API glupDeleteContext(GLUPcontext context)
Deletes a GLUP context.
void GLUP_API glupClipPlane(const GLUPdouble *eqn)
Defines the plane used by GLUP clipping.
void GLUP_API glupUseProgram(GLUPuint program)
Specifies a GLSL program to be used for drawing the primitives.
GLUP_API GLUPuint glupCompileProgram(const char *source)
Compiles a GLSL program.
void GLUP_API glupGenVertexArrays(GLUPsizei n, GLUPuint *arrays)
Generate vertex array object names.
void GLUP_API glupGetClipPlane(GLUPdouble *eqn)
Gets the current clipping plane.
GLUPcontext GLUP_API glupCurrentContext(void)
Gets the current GLUP context.
void GLUP_API glupBindVertexArray(GLUPuint array)
Binds a vertex array object.
GLUP_API GLUPuint glupCompileShader(GLUPenum target, GLUPprimitive primitive, const char *source)
Compiles a GLSL shader.
void * GLUPcontext
Opaque identifier of a GLUP context.
Definition: GLUP.h:90
GLUP_API const char * glupCurrentProfileName(void)
The name of the profile implemented by the current context.
GLUPprimitive
Symbolic values corresponding to GLUP primitive types.
Definition: GLUP.h:470
Basic definitions for the Geogram C API.
double angle(const vec3 &a, const vec3 &b)
Computes the angle between two 3d vectors.
Definition: geometry.h:266