summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-02-05 15:19:32 +0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2019-02-12 19:42:08 +0200
commit9b66be7bef71d100579647d787b542d248952f88 (patch)
treecd37cc02e15dcc2819606632ee65c6961bb5b10f
parent1fadf563688785a51ce4fe935a7865d05e3e72a9 (diff)
downloadqtlocation-mapboxgl-9b66be7bef71d100579647d787b542d248952f88.tar.gz
[core] Abstract the OpenGL implementation
The platform will be responsible to load the OpenGL implementation and give the function pointers to Mapbox GL Core. The platform might load OpenGL by linking against some OpenGL implementation, load it dynamically, etc. It doesn't matter as long as it is a valid implementation. Also adds the `::platform` namespace where all the missing symbols and interfaces expected to be implemented by the platforms will live.
-rw-r--r--include/mbgl/platform/gl_functions.hpp337
-rw-r--r--src/mbgl/gl/defines.hpp175
-rw-r--r--src/mbgl/platform/gl_functions.cpp17
3 files changed, 529 insertions, 0 deletions
diff --git a/include/mbgl/platform/gl_functions.hpp b/include/mbgl/platform/gl_functions.hpp
new file mode 100644
index 0000000000..a007a48b88
--- /dev/null
+++ b/include/mbgl/platform/gl_functions.hpp
@@ -0,0 +1,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(_WINDOWS)
+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 \ No newline at end of file
diff --git a/src/mbgl/gl/defines.hpp b/src/mbgl/gl/defines.hpp
new file mode 100644
index 0000000000..41c4cb07d6
--- /dev/null
+++ b/src/mbgl/gl/defines.hpp
@@ -0,0 +1,175 @@
+#pragma once
+
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ALPHA 0x1906
+#define GL_ALWAYS 0x0207
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_BACK 0x0405
+#define GL_BLEND 0x0BE2
+#define GL_BLEND_COLOR 0x8005
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_BYTE 0x1400
+#define GL_CCW 0x0901
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_CW 0x0900
+#define GL_DECR 0x1E03
+#define GL_DECR_WRAP 0x8508
+#define GL_DEPTH24_STENCIL8_OES 0x88F0
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DONT_CARE 0x1100
+#define GL_DST_ALPHA 0x0304
+#define GL_DST_COLOR 0x0306
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_EQUAL 0x0202
+#define GL_EXTENSIONS 0x1F03
+#define GL_FALSE 0
+#define GL_FLOAT 0x1406
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_FRONT 0x0404
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_FRONT_FACE 0x0B46
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_GEQUAL 0x0206
+#define GL_GREATER 0x0204
+#define GL_INCR 0x1E02
+#define GL_INCR_WRAP 0x8507
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_INT 0x1404
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_INVALID_OPERATION 0x0502
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVERT 0x150A
+#define GL_KEEP 0x1E00
+#define GL_LEQUAL 0x0203
+#define GL_LESS 0x0201
+#define GL_LINEAR 0x2601
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_LINE_LOOP 0x0002
+#define GL_LINES 0x0001
+#define GL_LINE_STRIP 0x0003
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINK_STATUS 0x8B82
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_NEAREST 0x2600
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_NEVER 0x0200
+#define GL_NO_ERROR 0
+#define GL_NOTEQUAL 0x0205
+#define GL_ONE 1
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_POINTS 0x0000
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_RENDERER 0x1F01
+#define GL_REPEAT 0x2901
+#define GL_REPLACE 0x1E01
+#define GL_RGBA 0x1908
+#define GL_RGBA8_OES 0x8058
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_SHORT 0x1402
+#define GL_SRC_ALPHA 0x0302
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_SRC_COLOR 0x0300
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STREAM_DRAW 0x88E0
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRUE 1
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_UNSIGNED_INT 0x1405
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_VIEWPORT 0x0BA2
+#define GL_ZERO 0
+
+#ifndef MBGL_USE_GLES2
+#define GL_CURRENT_RASTER_POSITION 0x0B07
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_DEPTH_BIAS 0x0D1F
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_DEPTH_SCALE 0x0D1E
+#define GL_INDEX_OFFSET 0x0D13
+#define GL_INDEX_SHIFT 0x0D12
+#define GL_LUMINANCE 0x1909
+#define GL_POINT_SIZE 0x0B11
+#define GL_RGBA8 0x8058
+#define GL_ZOOM_X 0x0D16
+#define GL_ZOOM_Y 0x0D17
+#endif \ No newline at end of file
diff --git a/src/mbgl/platform/gl_functions.cpp b/src/mbgl/platform/gl_functions.cpp
new file mode 100644
index 0000000000..6eb7790ca2
--- /dev/null
+++ b/src/mbgl/platform/gl_functions.cpp
@@ -0,0 +1,17 @@
+#include <mbgl/platform/gl_functions.hpp>
+
+#include <mbgl/util/logging.hpp>
+
+namespace mbgl {
+namespace platform {
+
+#ifndef NDEBUG
+void glCheckError(const char* cmd, const char* file, int line) {
+ if (GLenum err = glGetError()) {
+ Log::Warning(Event::OpenGL, "Error %d: %s - %s:%d", err, cmd, file, line);
+ }
+}
+#endif
+
+} // namespace platform
+} // namespace mbgl