Geogram Version 1.9.6-rc
A programming library of geometric algorithms
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
51#if defined(GEO_OS_EMSCRIPTEN)
52# define GLFW_INCLUDE_ES2
53# include <GLFW/glfw3.h>
54# define GL_GLEXT_PROTOTYPES
55# include <GLES2/gl2ext.h>
56# define GL_INVALID_INDEX GLuint(-1)
57typedef double GLdouble;
58# define glGenVertexArrays glGenVertexArraysOES
59# define glBindVertexArray glBindVertexArrayOES
60# define glDeleteVertexArrays glDeleteVertexArraysOES
61# define GEO_GL_ES2
62# define GEO_GL_NO_DOUBLES
63#elif defined(GEO_OS_ANDROID)
64# include <GLES3/gl3.h>
65# include <GLES3/gl31.h>
66# include <GLES3/gl32.h>
67# define GEO_GL_TEXTURE_3D
68# define GEO_GL_ES2
69# define GEO_GL_140
70# define GEO_GL_150
71# define GEO_GL_NO_DOUBLES
72#else
73# include <geogram_gfx/third_party/glad/glad.h>
74# define GEO_GL_TEXTURE_3D
75# define GEO_GL_140
76# define GEO_GL_150
77# define GEO_GL_440
78# define GEO_GL_ES2
79#endif
80
83
84// Some defines missing in Emscripten GL headers
85#if defined(GEO_OS_EMSCRIPTEN) || defined(GEO_OS_ANDROID)
86# ifndef GL_RGB8
87# define GL_RGB8 0x8051
88# endif
89
90# ifndef GL_RGBA8
91# define GL_RGBA8 0x8058
92# endif
93
94# ifndef GL_R16F
95# define GL_R16F 0x822D
96# endif
97
98# ifndef GL_R32F
99# define GL_R32F 0x822E
100# endif
101
102# ifndef GL_RED
103# define GL_RED 0x1903
104# endif
105
106# ifndef GL_R8
107# define GL_R8 0x8229
108# endif
109
110# ifndef GL_R16
111# define GL_R16 0x822A
112# endif
113
114# ifndef GL_DEPTH_COMPONENT24
115# define GL_DEPTH_COMPONENT24 0x81A6
116# endif
117
118#endif
119
125namespace GEO {
126
127 namespace GL {
132 void GEOGRAM_GFX_API initialize();
133
138 void GEOGRAM_GFX_API terminate();
139 }
140
141
146 inline void glupVertex(const vec2& v) {
147 glupVertex2dv(v.data());
148 }
149
154 inline void glupVertex(const vec3& v) {
155 glupVertex3dv(v.data());
156 }
157
163 inline void glupVertex(const vec4& v) {
164 glupVertex4dv(v.data());
165 }
166
171 inline void glupColor(const vec3& v) {
172 glupColor3dv(v.data());
173 }
174
179 inline void glupColor(const vec4& v) {
180 glupColor4dv(v.data());
181 }
182
183
188 inline void glupTexCoord(const vec2& v) {
189 glupTexCoord2dv(v.data());
190 }
191
196 inline void glupTexCoord(const vec3& v) {
197 glupTexCoord3dv(v.data());
198 }
199
204 inline void glupTexCoord(const vec4& v) {
205 glupTexCoord4dv(v.data());
206 }
207
212 inline void glupTranslate(const vec3& v) {
213 glupTranslated(v.x, v.y, v.z);
214 }
215
226 double minval, double maxval, index_t mult=1
227 );
228
239
250
260
275 GLuint& buffer_id, GLenum target, size_t new_size, const void* data
276 );
277
296 GLuint& buffer_id, GLenum target, size_t new_size, const void* data
297 );
298
299
320 GLuint& buffer_id, GLenum target, size_t new_size, const void* data,
321 bool update
322 );
323
332 const char* file, int line, bool warning_only=false
333 );
334
344 void GEOGRAM_GFX_API clear_gl_error_flags(const char* file, int line);
345
358
364#ifdef GEO_DEBUG_GL
365# define GEO_CHECK_GL() ::GEO::check_gl(__FILE__,__LINE__)
366#else
367# define GEO_CHECK_GL()
368#endif
369
370 /***********************************************************/
371
372 void GEOGRAM_GFX_API glTexImage2Dxpm(char const* const* xpm_data);
373
374}
375
376#endif
GLUP: GL Useful Primitives.
T * data()
Gets modifiable vector data.
Definition vecg.h:161
Geometric functions in 2d and 3d.
Basic definitions for the Geogram C API.
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Definition defs.h:55
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
Definition basic.h:55
void GEOGRAM_GFX_API 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...
void GEOGRAM_GFX_API glupMultMatrix(const mat4 &m)
Multiplies the current GLUP matrix with another one.
void GEOGRAM_GFX_API glupMapTexCoords1d(double minval, double maxval, index_t mult=1)
Maps texture coordinates from a specified interval to the unit interval.
void GEOGRAM_GFX_API 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.
GLint64 GEOGRAM_GFX_API get_size_of_bound_buffer_object(GLenum target)
Gets the size (in bytes) of the OpenGL buffer bound to a specified target.
vecng< 3, Numeric::float64 > vec3
Represents points and vectors in 3d.
Definition geometry.h:65
void GEOGRAM_GFX_API 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.
void glupVertex(const vec2 &v)
Sends a vertex to OpenGL.
Definition GL.h:146
void GEOGRAM_GFX_API clear_gl_error_flags(const char *file, int line)
Clears all error flags set by previous OpenGL calls.
void GEOGRAM_GFX_API glupLoadMatrix(const mat4 &m)
Replaces the current GLUP matrix with a user defined one.
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:329
vecng< 4, Numeric::float64 > vec4
Represents points and vectors in 4d.
Definition geometry.h:71
void GEOGRAM_GFX_API draw_unit_textured_quad(bool BW=false)
Draws a textured quad.
void glupTexCoord(const vec2 &v)
Sends 2d texture coordinates to OpenGL.
Definition GL.h:188
void glupTranslate(const vec3 &v)
Applies a translation.
Definition GL.h:212
void glupColor(const vec3 &v)
Sends a RGB color to OpenGL.
Definition GL.h:171
void GEOGRAM_GFX_API check_gl(const char *file, int line, bool warning_only=false)
Tests for OpenGL errors and displays a message if OpenGL errors were encountered.