Graphite Version 3
An experimental 3D geometry processing program
Loading...
Searching...
No Matches
GL.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_BASIC_GL
41#define GEOGRAM_GFX_BASIC_GL
42
43#ifdef GEO_DEBUG
44#define GEO_DEBUG_GL
45#endif
46
49
50#if defined(GEO_OS_EMSCRIPTEN)
51# define GLFW_INCLUDE_ES2
52# include <GLFW/glfw3.h>
53# define GL_GLEXT_PROTOTYPES
54# include <GLES3/gl3.h>
55 typedef double GLdouble;
56# define GEO_GL_ES2
57# define GEO_GL_140
58# define GEO_GL_NO_DOUBLES
59#elif defined(GEO_OS_ANDROID)
60# include <GLES3/gl3.h>
61# include <GLES3/gl31.h>
62# include <GLES3/gl32.h>
63# define GEO_GL_TEXTURE_3D
64# define GEO_GL_ES2
65# define GEO_GL_140
66# define GEO_GL_150
67# define GEO_GL_NO_DOUBLES
68#else
69
70# ifdef GEO_COMPILER_CLANG
71# pragma GCC diagnostic push
72# pragma GCC diagnostic ignored "-Wreserved-identifier"
73# endif
74
75# include <geogram_gfx/third_party/glad/glad.h>
76
77# ifdef GEO_COMPILER_CLANG
78# pragma GCC diagnostic pop
79# endif
80
81# define GEO_GL_TEXTURE_3D
82# define GEO_GL_140
83# define GEO_GL_150
84# define GEO_GL_ES2
85
86# ifndef GEO_OS_APPLE
87# define GEO_GL_430
88# define GEO_GL_440
89# endif
90
91#endif
92
95
96// Some defines missing in Emscripten GL headers
97#if defined(GEO_OS_EMSCRIPTEN) || defined(GEO_OS_ANDROID)
98# ifndef GL_RGB8
99# define GL_RGB8 0x8051
100# endif
101
102# ifndef GL_RGBA8
103# define GL_RGBA8 0x8058
104# endif
105
106# ifndef GL_R16F
107# define GL_R16F 0x822D
108# endif
109
110# ifndef GL_R32F
111# define GL_R32F 0x822E
112# endif
113
114# ifndef GL_RED
115# define GL_RED 0x1903
116# endif
117
118# ifndef GL_R8
119# define GL_R8 0x8229
120# endif
121
122# ifndef GL_R16
123# define GL_R16 0x822A
124# endif
125
126# ifndef GL_DEPTH_COMPONENT24
127# define GL_DEPTH_COMPONENT24 0x81A6
128# endif
129
130#endif
131
136
137namespace GEO {
138
139 namespace GL {
145
151 }
152
153
158 inline void glupVertex(const vec2& v) {
159 glupVertex2dv(v.data());
160 }
161
166 inline void glupVertex(const vec3& v) {
167 glupVertex3dv(v.data());
168 }
169
175 inline void glupVertex(const vec4& v) {
176 glupVertex4dv(v.data());
177 }
178
183 inline void glupColor(const vec3& v) {
184 glupColor3dv(v.data());
185 }
186
191 inline void glupColor(const vec4& v) {
192 glupColor4dv(v.data());
193 }
194
195
200 inline void glupTexCoord(const vec2& v) {
201 glupTexCoord2dv(v.data());
202 }
203
208 inline void glupTexCoord(const vec3& v) {
209 glupTexCoord3dv(v.data());
210 }
211
216 inline void glupTexCoord(const vec4& v) {
217 glupTexCoord4dv(v.data());
218 }
219
224 inline void glupTranslate(const vec3& v) {
225 glupTranslated(v.x, v.y, v.z);
226 }
227
238 double minval, double maxval, index_t mult=1
239 );
240
251
262
272
287 GLuint& buffer_id, GLenum target, size_t new_size, const void* data
288 );
289
308 GLuint& buffer_id, GLenum target, size_t new_size, const void* data
309 );
310
311
332 GLuint& buffer_id, GLenum target, size_t new_size, const void* data,
333 bool update
334 );
335
344 const char* file, int line, bool warning_only=false
345 );
346
356 void GEOGRAM_GFX_API clear_gl_error_flags(const char* file, int line);
357
361 enum TexturedQuadMode { TEX_QUAD_RGBA, TEX_QUAD_RRR1, TEX_QUAD_DEPTH };
362
378 TexturedQuadMode mode = TEX_QUAD_RGBA
379 );
380
386#ifdef GEO_DEBUG_GL
387# define GEO_CHECK_GL() ::GEO::check_gl(__FILE__,__LINE__)
388#else
389# define GEO_CHECK_GL()
390#endif
391
392 /***********************************************************/
393
394 void GEOGRAM_GFX_API glTexImage2Dxpm(char const* const* xpm_data);
395
396}
397
398#endif
GLUP: GL Useful Primitives.
void initialize()
Initializes some GL functions and objects.
void terminate()
Terminates GL functions and objects.
T * data()
Gets modifiable vector data.
Definition vecg.h:165
Geometric functions in 2d and 3d.
Common include file, providing basic definitions. Should be included before anything else by all head...
Basic definitions for the Geogram C API.
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Definition defs.h:55
Global Vorpaline namespace.
void glupLoadMatrix(const mat4 &m)
Replaces the current GLUP matrix with a user defined one.
Matrix< 4, Numeric::float64 > mat4
Represents a 4x4 matrix.
Definition geometry.h:153
void update_or_check_buffer_object(GLuint &buffer_id, GLenum target, size_t new_size, const void *data, bool update)
Updates the content of an OpenGL buffer object, and resizes it if need be, or tests whether it has th...
vecng< 3, Numeric::float64 > vec3
Represents points and vectors in 3d.
Definition geometry.h:65
GLint64 get_size_of_bound_buffer_object(GLenum target)
Gets the size (in bytes) of the OpenGL buffer bound to a specified target.
void glupVertex(const vec2 &v)
Sends a vertex to OpenGL.
Definition GL.h:158
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:341
vecng< 4, Numeric::float64 > vec4
Represents points and vectors in 4d.
Definition geometry.h:71
void glupTexCoord(const vec2 &v)
Sends 2d texture coordinates to OpenGL.
Definition GL.h:200
void clear_gl_error_flags(const char *file, int line)
Clears all error flags set by previous OpenGL calls.
void draw_unit_textured_quad(TexturedQuadMode mode=TEX_QUAD_RGBA)
Draws a textured quad.
void glupTranslate(const vec3 &v)
Applies a translation.
Definition GL.h:224
void glupMapTexCoords1d(double minval, double maxval, index_t mult=1)
Maps texture coordinates from a specified interval to the unit interval.
void update_buffer_object(GLuint &buffer_id, GLenum target, size_t new_size, const void *data)
Updates the content of an OpenGL buffer object, and resizes it if need be.
TexturedQuadMode
Constants for draw_unit_textured_quad().
Definition GL.h:361
vecng< 2, Numeric::float64 > vec2
Represents points and vectors in 2d.
Definition geometry.h:59
vecng< DIM, FT > mult(const Matrix< DIM, FT > &M, const vecng< DIM, FT > &x)
Computes a matrix vector product.
Definition matrix.h:592
void check_gl(const char *file, int line, bool warning_only=false)
Tests for OpenGL errors and displays a message if OpenGL errors were encountered.
void glupColor(const vec3 &v)
Sends a RGB color to OpenGL.
Definition GL.h:183
void glupMultMatrix(const mat4 &m)
Multiplies the current GLUP matrix with another one.
void stream_buffer_object(GLuint &buffer_id, GLenum target, size_t new_size, const void *data)
Updates the content of an OpenGL buffer object in streaming mode.