summaryrefslogtreecommitdiff
path: root/include/mbgl/platform/gl_functions.hpp
blob: b617b3561093e30d5e78ae34f274bb24dcb0de19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#pragma once

#include <cstddef>

// Pointers to OpenGL ES 2.0 functions. They must be
// initialized by the platform at linking time.

#ifndef NDEBUG
#define MBGL_CHECK_ERROR(cmd) ([&]() { struct __MBGL_CHECK_ERROR { ~__MBGL_CHECK_ERROR() noexcept(false) { mbgl::platform::glCheckError(#cmd, __FILE__, __LINE__); } } __MBGL_CHECK_ERROR; return cmd; }())
#else
#define MBGL_CHECK_ERROR(cmd) (cmd)
#endif

namespace mbgl {
namespace platform {

using GLbitfield = unsigned int;
using GLboolean = unsigned char;
using GLchar = char;
using GLdouble = double;
using GLenum = unsigned int;
using GLfloat = float;
using GLint = int;
using GLsizei = int;
using GLubyte = unsigned char;
using GLuint = unsigned int;
using GLvoid = void;

#if defined(_WIN32)
using GLintptr = long long;
using GLsizeiptr = long long;
#else
using GLintptr = long;
using GLsizeiptr = long;
#endif

/// Pointer to glActiveTexture OpenGL function.
extern void (* const glActiveTexture)(GLenum);
/// Pointer to glAttachShader OpenGL function.
extern void (* const glAttachShader)(GLuint, GLuint);
/// Pointer to glBindAttribLocation OpenGL function.
extern void (* const glBindAttribLocation)(GLuint, GLuint, const GLchar *);
/// Pointer to glBindBuffer OpenGL function.
extern void (* const glBindBuffer)(GLenum, GLuint);
/// Pointer to glBindFramebuffer OpenGL function.
extern void (* const glBindFramebuffer)(GLenum, GLuint);
/// Pointer to glBindRenderbuffer OpenGL function.
extern void (* const glBindRenderbuffer)(GLenum, GLuint);
/// Pointer to glBindTexture OpenGL function.
extern void (* const glBindTexture)(GLenum, GLuint);
/// Pointer to glBlendColor OpenGL function.
extern void (* const glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat);
/// Pointer to glBlendEquation OpenGL function.
extern void (* const glBlendEquation)(GLenum);
/// Pointer to glBlendEquationSeparate OpenGL function.
extern void (* const glBlendEquationSeparate)(GLenum, GLenum);
/// Pointer to glBlendFunc OpenGL function.
extern void (* const glBlendFunc)(GLenum, GLenum);
/// Pointer to glBlendFuncSeparate OpenGL function.
extern void (* const glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);
/// Pointer to glBufferData OpenGL function.
extern void (* const glBufferData)(GLenum, GLsizeiptr, const void *, GLenum);
/// Pointer to glBufferSubData OpenGL function.
extern void (* const glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const void *);
/// Pointer to glCheckFramebufferStatus OpenGL function.
extern GLenum (* const glCheckFramebufferStatus)(GLenum);
/// Pointer to glClear OpenGL function.
extern void (* const glClear)(GLbitfield);
/// Pointer to glClearColor OpenGL function.
extern void (* const glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat);
/// Pointer to glClearDepthf OpenGL function.
extern void (* const glClearDepthf)(GLfloat);
/// Pointer to glClearStencil OpenGL function.
extern void (* const glClearStencil)(GLint);
/// Pointer to glColorMask OpenGL function.
extern void (* const glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
/// Pointer to glCompileShader OpenGL function.
extern void (* const glCompileShader)(GLuint);
/// Pointer to glCompressedTexImage2D OpenGL function.
extern void (* const glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *);
/// Pointer to glCompressedTexSubImage2D OpenGL function.
extern void (* const glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *);
/// Pointer to glCopyTexImage2D OpenGL function.
extern void (* const glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
/// Pointer to glCopyTexSubImage2D OpenGL function.
extern void (* const glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
/// Pointer to glCreateProgram OpenGL function.
extern GLuint (* const glCreateProgram)();
/// Pointer to glCreateShader OpenGL function.
extern GLuint (* const glCreateShader)(GLenum);
/// Pointer to glCullFace OpenGL function.
extern void (* const glCullFace)(GLenum);
/// Pointer to glDeleteBuffers OpenGL function.
extern void (* const glDeleteBuffers)(GLsizei, const GLuint *);
/// Pointer to glDeleteFramebuffers OpenGL function.
extern void (* const glDeleteFramebuffers)(GLsizei, const GLuint *);
/// Pointer to glDeleteProgram OpenGL function.
extern void (* const glDeleteProgram)(GLuint);
/// Pointer to glDeleteRenderbuffers OpenGL function.
extern void (* const glDeleteRenderbuffers)(GLsizei, const GLuint *);
/// Pointer to glDeleteShader OpenGL function.
extern void (* const glDeleteShader)(GLuint);
/// Pointer to glDeleteTextures OpenGL function.
extern void (* const glDeleteTextures)(GLsizei, const GLuint *);
/// Pointer to glDepthFunc OpenGL function.
extern void (* const glDepthFunc)(GLenum);
/// Pointer to glDepthMask OpenGL function.
extern void (* const glDepthMask)(GLboolean);
/// Pointer to glDepthRangef OpenGL function.
extern void (* const glDepthRangef)(GLfloat, GLfloat);
/// Pointer to glDetachShader OpenGL function.
extern void (* const glDetachShader)(GLuint, GLuint);
/// Pointer to glDisable OpenGL function.
extern void (* const glDisable)(GLenum);
/// Pointer to glDisableVertexAttribArray OpenGL function.
extern void (* const glDisableVertexAttribArray)(GLuint);
/// Pointer to glDrawArrays OpenGL function.
extern void (* const glDrawArrays)(GLenum, GLint, GLsizei);
/// Pointer to glDrawElements OpenGL function.
extern void (* const glDrawElements)(GLenum, GLsizei, GLenum, const void *);
/// Pointer to glEnable OpenGL function.
extern void (* const glEnable)(GLenum);
/// Pointer to glEnableVertexAttribArray OpenGL function.
extern void (* const glEnableVertexAttribArray)(GLuint);
/// Pointer to glFinish OpenGL function.
extern void (* const glFinish)();
/// Pointer to glFlush OpenGL function.
extern void (* const glFlush)();
/// Pointer to glFramebufferRenderbuffer OpenGL function.
extern void (* const glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint);
/// Pointer to glFramebufferTexture2D OpenGL function.
extern void (* const glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint);
/// Pointer to glFrontFace OpenGL function.
extern void (* const glFrontFace)(GLenum);
/// Pointer to glGenBuffers OpenGL function.
extern void (* const glGenBuffers)(GLsizei, GLuint *);
/// Pointer to glGenerateMipmap OpenGL function.
extern void (* const glGenerateMipmap)(GLenum);
/// Pointer to glGenFramebuffers OpenGL function.
extern void (* const glGenFramebuffers)(GLsizei, GLuint *);
/// Pointer to glGenRenderbuffers OpenGL function.
extern void (* const glGenRenderbuffers)(GLsizei, GLuint *);
/// Pointer to glGenTextures OpenGL function.
extern void (* const glGenTextures)(GLsizei, GLuint *);
/// Pointer to glGetActiveAttrib OpenGL function.
extern void (* const glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
/// Pointer to glGetActiveUniform OpenGL function.
extern void (* const glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
/// Pointer to glGetAttachedShaders OpenGL function.
extern void (* const glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *);
/// Pointer to glGetAttribLocation OpenGL function.
extern GLint (* const glGetAttribLocation)(GLuint, const GLchar *);
/// Pointer to glGetBooleanv OpenGL function.
extern void (* const glGetBooleanv)(GLenum, GLboolean *);
/// Pointer to glGetBufferParameteriv OpenGL function.
extern void (* const glGetBufferParameteriv)(GLenum, GLenum, GLint *);
/// Pointer to glGetError OpenGL function.
extern GLenum (* const glGetError)();
/// Pointer to glGetFloatv OpenGL function.
extern void (* const glGetFloatv)(GLenum, GLfloat *);
/// Pointer to glGetFramebufferAttachmentParameteriv OpenGL function.
extern void (* const glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *);
/// Pointer to glGetIntegerv OpenGL function.
extern void (* const glGetIntegerv)(GLenum, GLint *);
/// Pointer to glGetProgramInfoLog OpenGL function.
extern void (* const glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
/// Pointer to glGetProgramiv OpenGL function.
extern void (* const glGetProgramiv)(GLuint, GLenum, GLint *);
/// Pointer to glGetRenderbufferParameteriv OpenGL function.
extern void (* const glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *);
/// Pointer to glGetShaderInfoLog OpenGL function.
extern void (* const glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
/// Pointer to glGetShaderiv OpenGL function.
extern void (* const glGetShaderiv)(GLuint, GLenum, GLint *);
/// Pointer to glGetShaderSource OpenGL function.
extern void (* const glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *);
/// Pointer to glGetString OpenGL function.
extern const GLubyte *(*glGetString)(GLenum);
/// Pointer to glGetTexParameterfv OpenGL function.
extern void (* const glGetTexParameterfv)(GLenum, GLenum, GLfloat *);
/// Pointer to glGetTexParameteriv OpenGL function.
extern void (* const glGetTexParameteriv)(GLenum, GLenum, GLint *);
/// Pointer to glGetUniformfv OpenGL function.
extern void (* const glGetUniformfv)(GLuint, GLint, GLfloat *);
/// Pointer to glGetUniformiv OpenGL function.
extern void (* const glGetUniformiv)(GLuint, GLint, GLint *);
/// Pointer to glGetUniformLocation OpenGL function.
extern GLint (* const glGetUniformLocation)(GLuint, const GLchar *);
/// Pointer to glGetVertexAttribfv OpenGL function.
extern void (* const glGetVertexAttribfv)(GLuint, GLenum, GLfloat *);
/// Pointer to glGetVertexAttribiv OpenGL function.
extern void (* const glGetVertexAttribiv)(GLuint, GLenum, GLint *);
/// Pointer to glGetVertexAttribPointerv OpenGL function.
extern void (* const glGetVertexAttribPointerv)(GLuint, GLenum, void **);
/// Pointer to glHint OpenGL function.
extern void (* const glHint)(GLenum, GLenum);
/// Pointer to glIsBuffer OpenGL function.
extern GLboolean (* const glIsBuffer)(GLuint);
/// Pointer to glIsEnabled OpenGL function.
extern GLboolean (* const glIsEnabled)(GLenum);
/// Pointer to glIsFramebuffer OpenGL function.
extern GLboolean (* const glIsFramebuffer)(GLuint);
/// Pointer to glIsProgram OpenGL function.
extern GLboolean (* const glIsProgram)(GLuint);
/// Pointer to glIsRenderbuffer OpenGL function.
extern GLboolean (* const glIsRenderbuffer)(GLuint);
/// Pointer to glIsShader OpenGL function.
extern GLboolean (* const glIsShader)(GLuint);
/// Pointer to glIsTexture OpenGL function.
extern GLboolean (* const glIsTexture)(GLuint);
/// Pointer to glLineWidth OpenGL function.
extern void (* const glLineWidth)(GLfloat);
/// Pointer to glLinkProgram OpenGL function.
extern void (* const glLinkProgram)(GLuint);
/// Pointer to glPixelStorei OpenGL function.
extern void (* const glPixelStorei)(GLenum, GLint);
/// Pointer to glPolygonOffset OpenGL function.
extern void (* const glPolygonOffset)(GLfloat, GLfloat);
/// Pointer to glReadPixels OpenGL function.
extern void (* const glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *);
/// Pointer to glRenderbufferStorage OpenGL function.
extern void (* const glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei);
/// Pointer to glSampleCoverage OpenGL function.
extern void (* const glSampleCoverage)(GLfloat, GLboolean);
/// Pointer to glScissor OpenGL function.
extern void (* const glScissor)(GLint, GLint, GLsizei, GLsizei);
/// Pointer to glShaderSource OpenGL function.
extern void (* const glShaderSource)(GLuint, GLsizei, const GLchar * const*, const GLint *);
/// Pointer to glStencilFunc OpenGL function.
extern void (* const glStencilFunc)(GLenum, GLint, GLuint);
/// Pointer to glStencilFuncSeparate OpenGL function.
extern void (* const glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint);
/// Pointer to glStencilMask OpenGL function.
extern void (* const glStencilMask)(GLuint);
/// Pointer to glStencilMaskSeparate OpenGL function.
extern void (* const glStencilMaskSeparate)(GLenum, GLuint);
/// Pointer to glStencilOp OpenGL function.
extern void (* const glStencilOp)(GLenum, GLenum, GLenum);
/// Pointer to glStencilOpSeparate OpenGL function.
extern void (* const glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum);
/// Pointer to glTexImage2D OpenGL function.
extern void (* const glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *);
/// Pointer to glTexParameterf OpenGL function.
extern void (* const glTexParameterf)(GLenum, GLenum, GLfloat);
/// Pointer to glTexParameterfv OpenGL function.
extern void (* const glTexParameterfv)(GLenum, GLenum, const GLfloat *);
/// Pointer to glTexParameteri OpenGL function.
extern void (* const glTexParameteri)(GLenum, GLenum, GLint);
/// Pointer to glTexParameteriv OpenGL function.
extern void (* const glTexParameteriv)(GLenum, GLenum, const GLint *);
/// Pointer to glTexSubImage2D OpenGL function.
extern void (* const glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *);
/// Pointer to glUniform1f OpenGL function.
extern void (* const glUniform1f)(GLint, GLfloat);
/// Pointer to glUniform1fv OpenGL function.
extern void (* const glUniform1fv)(GLint, GLsizei, const GLfloat *);
/// Pointer to glUniform1i OpenGL function.
extern void (* const glUniform1i)(GLint, GLint);
/// Pointer to glUniform1iv OpenGL function.
extern void (* const glUniform1iv)(GLint, GLsizei, const GLint *);
/// Pointer to glUniform2f OpenGL function.
extern void (* const glUniform2f)(GLint, GLfloat, GLfloat);
/// Pointer to glUniform2fv OpenGL function.
extern void (* const glUniform2fv)(GLint, GLsizei, const GLfloat *);
/// Pointer to glUniform2i OpenGL function.
extern void (* const glUniform2i)(GLint, GLint, GLint);
/// Pointer to glUniform2iv OpenGL function.
extern void (* const glUniform2iv)(GLint, GLsizei, const GLint *);
/// Pointer to glUniform3f OpenGL function.
extern void (* const glUniform3f)(GLint, GLfloat, GLfloat, GLfloat);
/// Pointer to glUniform3fv OpenGL function.
extern void (* const glUniform3fv)(GLint, GLsizei, const GLfloat *);
/// Pointer to glUniform3i OpenGL function.
extern void (* const glUniform3i)(GLint, GLint, GLint, GLint);
/// Pointer to glUniform3iv OpenGL function.
extern void (* const glUniform3iv)(GLint, GLsizei, const GLint *);
/// Pointer to glUniform4f OpenGL function.
extern void (* const glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
/// Pointer to glUniform4fv OpenGL function.
extern void (* const glUniform4fv)(GLint, GLsizei, const GLfloat *);
/// Pointer to glUniform4i OpenGL function.
extern void (* const glUniform4i)(GLint, GLint, GLint, GLint, GLint);
/// Pointer to glUniform4iv OpenGL function.
extern void (* const glUniform4iv)(GLint, GLsizei, const GLint *);
/// Pointer to glUniformMatrix2fv OpenGL function.
extern void (* const glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *);
/// Pointer to glUniformMatrix3fv OpenGL function.
extern void (* const glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *);
/// Pointer to glUniformMatrix4fv OpenGL function.
extern void (* const glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *);
/// Pointer to glUseProgram OpenGL function.
extern void (* const glUseProgram)(GLuint);
/// Pointer to glValidateProgram OpenGL function.
extern void (* const glValidateProgram)(GLuint);
/// Pointer to glVertexAttrib1f OpenGL function.
extern void (* const glVertexAttrib1f)(GLuint, GLfloat);
/// Pointer to glVertexAttrib1fv OpenGL function.
extern void (* const glVertexAttrib1fv)(GLuint, const GLfloat *);
/// Pointer to glVertexAttrib2f OpenGL function.
extern void (* const glVertexAttrib2f)(GLuint, GLfloat, GLfloat);
/// Pointer to glVertexAttrib2fv OpenGL function.
extern void (* const glVertexAttrib2fv)(GLuint, const GLfloat *);
/// Pointer to glVertexAttrib3f OpenGL function.
extern void (* const glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat);
/// Pointer to glVertexAttrib3fv OpenGL function.
extern void (* const glVertexAttrib3fv)(GLuint, const GLfloat *);
/// Pointer to glVertexAttrib4f OpenGL function.
extern void (* const glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
/// Pointer to glVertexAttrib4fv OpenGL function.
extern void (* const glVertexAttrib4fv)(GLuint, const GLfloat *);
/// Pointer to glVertexAttribPointer OpenGL function.
extern void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *);
/// Pointer to glViewport OpenGL function.
extern void (* const glViewport)(GLint, GLint, GLsizei, GLsizei);

#ifndef MBGL_USE_GLES2
/// Pointer to glDrawPixels OpenGL function.
extern void (* const glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
/// Pointer to glGetDoublev OpenGL function.
extern void (* const glGetDoublev)(GLenum, GLdouble *);
/// Pointer to glPixelTransferf OpenGL function.
extern void (* const glPixelTransferf)(GLenum, GLfloat);
/// Pointer to glPixelZoom OpenGL function.
extern void (* const glPixelZoom)(GLfloat, GLfloat);
/// Pointer to glPointSize OpenGL function.
extern void (* const glPointSize)(GLfloat);
/// Pointer to glRasterPos4d OpenGL function.
extern void (* const glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble);
#endif

#ifndef NDEBUG
/// Check for GL errors and print on the console.
void glCheckError(const char *cmd, const char *file, int line);
#endif

}  // namespace platform
} // namespace mbgl