summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/gl/attribute.cpp4
-rw-r--r--src/mbgl/gl/color_mode.cpp2
-rw-r--r--src/mbgl/gl/context.cpp3
-rw-r--r--src/mbgl/gl/context.hpp1
-rw-r--r--src/mbgl/gl/cull_face_mode.cpp2
-rw-r--r--src/mbgl/gl/debugging.cpp2
-rw-r--r--src/mbgl/gl/debugging_extension.hpp4
-rw-r--r--src/mbgl/gl/depth_mode.cpp2
-rw-r--r--src/mbgl/gl/gl.cpp71
-rw-r--r--src/mbgl/gl/gl.hpp24
-rw-r--r--src/mbgl/gl/program_binary_extension.hpp2
-rw-r--r--src/mbgl/gl/stencil_mode.cpp2
-rw-r--r--src/mbgl/gl/uniform.cpp8
-rw-r--r--src/mbgl/gl/value.cpp11
-rw-r--r--src/mbgl/gl/value.hpp1
-rw-r--r--src/mbgl/gl/vertex_array.cpp1
-rw-r--r--src/mbgl/gl/vertex_array_extension.hpp8
-rw-r--r--src/mbgl/renderer/layers/render_custom_layer.cpp6
18 files changed, 31 insertions, 123 deletions
diff --git a/src/mbgl/gl/attribute.cpp b/src/mbgl/gl/attribute.cpp
index b2d05fe665..4983a8c204 100644
--- a/src/mbgl/gl/attribute.cpp
+++ b/src/mbgl/gl/attribute.cpp
@@ -1,10 +1,12 @@
#include <mbgl/gl/attribute.hpp>
#include <mbgl/gl/context.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
namespace mbgl {
namespace gl {
+using namespace platform;
+
void bindAttributeLocation(Context& context, ProgramID id, AttributeLocation location, const char* name) {
// We're using sequentially numberered attribute locations starting with 0. Therefore we can use
// the location as a proxy for the number of attributes.
diff --git a/src/mbgl/gl/color_mode.cpp b/src/mbgl/gl/color_mode.cpp
index e838c8e2ff..e524bfdf98 100644
--- a/src/mbgl/gl/color_mode.cpp
+++ b/src/mbgl/gl/color_mode.cpp
@@ -1,5 +1,5 @@
#include <mbgl/gl/color_mode.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
#include <mbgl/util/traits.hpp>
namespace mbgl {
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 18ab38e684..2463993cf0 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -1,5 +1,4 @@
#include <mbgl/gl/context.hpp>
-#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/debugging_extension.hpp>
#include <mbgl/gl/vertex_array_extension.hpp>
#include <mbgl/gl/program_binary_extension.hpp>
@@ -12,6 +11,8 @@
namespace mbgl {
namespace gl {
+using namespace platform;
+
static_assert(underlying_type(ShaderType::Vertex) == GL_VERTEX_SHADER, "OpenGL type mismatch");
static_assert(underlying_type(ShaderType::Fragment) == GL_FRAGMENT_SHADER, "OpenGL type mismatch");
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index bd682f44da..810fb41990 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -15,6 +15,7 @@
#include <mbgl/gl/depth_mode.hpp>
#include <mbgl/gl/stencil_mode.hpp>
#include <mbgl/gl/color_mode.hpp>
+#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/util/noncopyable.hpp>
diff --git a/src/mbgl/gl/cull_face_mode.cpp b/src/mbgl/gl/cull_face_mode.cpp
index 42729aeea7..53dd340204 100644
--- a/src/mbgl/gl/cull_face_mode.cpp
+++ b/src/mbgl/gl/cull_face_mode.cpp
@@ -1,5 +1,5 @@
#include <mbgl/gl/cull_face_mode.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
#include <mbgl/util/traits.hpp>
namespace mbgl {
diff --git a/src/mbgl/gl/debugging.cpp b/src/mbgl/gl/debugging.cpp
index 366b4d63c7..7b8121f003 100644
--- a/src/mbgl/gl/debugging.cpp
+++ b/src/mbgl/gl/debugging.cpp
@@ -5,6 +5,8 @@
namespace mbgl {
namespace gl {
+using namespace platform;
+
#ifndef NDEBUG
DebugGroup::DebugGroup(const Context& context_, const std::string& name) : context(context_) {
diff --git a/src/mbgl/gl/debugging_extension.hpp b/src/mbgl/gl/debugging_extension.hpp
index 5657bbde88..0fa5a7b424 100644
--- a/src/mbgl/gl/debugging_extension.hpp
+++ b/src/mbgl/gl/debugging_extension.hpp
@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/gl/extension.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/platform/gl_functions.hpp>
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
@@ -51,6 +51,8 @@ namespace mbgl {
namespace gl {
namespace extension {
+using namespace platform;
+
class Debugging {
public:
using Callback = void (*)(GLenum source,
diff --git a/src/mbgl/gl/depth_mode.cpp b/src/mbgl/gl/depth_mode.cpp
index 21af75a391..fdd9cf31d1 100644
--- a/src/mbgl/gl/depth_mode.cpp
+++ b/src/mbgl/gl/depth_mode.cpp
@@ -1,5 +1,5 @@
#include <mbgl/gl/depth_mode.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
#include <mbgl/util/traits.hpp>
namespace mbgl {
diff --git a/src/mbgl/gl/gl.cpp b/src/mbgl/gl/gl.cpp
deleted file mode 100644
index bd6d7b192d..0000000000
--- a/src/mbgl/gl/gl.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <mbgl/gl/gl.hpp>
-#include <mbgl/util/string.hpp>
-#include <mbgl/util/util.hpp>
-
-namespace mbgl {
-namespace gl {
-
-namespace {
-
-MBGL_CONSTEXPR const char* stringFromError(GLenum err) {
- switch (err) {
- case GL_INVALID_ENUM:
- return "GL_INVALID_ENUM";
-
- case GL_INVALID_VALUE:
- return "GL_INVALID_VALUE";
-
- case GL_INVALID_OPERATION:
- return "GL_INVALID_OPERATION";
-
- case GL_INVALID_FRAMEBUFFER_OPERATION:
- return "GL_INVALID_FRAMEBUFFER_OPERATION";
-
- case GL_OUT_OF_MEMORY:
- return "GL_OUT_OF_MEMORY";
-
-#ifdef GL_TABLE_TOO_LARGE
- case GL_TABLE_TOO_LARGE:
- return "GL_TABLE_TOO_LARGE";
-#endif
-
-#ifdef GL_STACK_OVERFLOW
- case GL_STACK_OVERFLOW:
- return "GL_STACK_OVERFLOW";
-#endif
-
-#ifdef GL_STACK_UNDERFLOW
- case GL_STACK_UNDERFLOW:
- return "GL_STACK_UNDERFLOW";
-#endif
-
-#ifdef GL_CONTEXT_LOST
- case GL_CONTEXT_LOST:
- return "GL_CONTEXT_LOST";
-#endif
-
- default:
- return "GL_UNKNOWN";
- }
-}
-
-} // namespace
-
-void checkError(const char* cmd, const char* file, int line) {
-// fprintf(stderr, "cmd: %s\n", cmd);
- GLenum err = GL_NO_ERROR;
- if ((err = glGetError()) != GL_NO_ERROR) {
- std::string message = std::string(cmd) + ": Error " + stringFromError(err);
-
- // Check for further errors
- while ((err = glGetError()) != GL_NO_ERROR) {
- message += ", ";
- message += stringFromError(err);
- }
-
- throw Error(message + " at " + file + ":" + util::toString(line));
- }
-}
-
-} // namespace gl
-} // namespace mbgl
diff --git a/src/mbgl/gl/gl.hpp b/src/mbgl/gl/gl.hpp
deleted file mode 100644
index 976b7d2f74..0000000000
--- a/src/mbgl/gl/gl.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/gl_impl.hpp>
-
-#include <stdexcept>
-#include <limits>
-
-namespace mbgl {
-namespace gl {
-
-struct Error : std::runtime_error {
- using std::runtime_error::runtime_error;
-};
-
-void checkError(const char *cmd, const char *file, int line);
-
-#ifndef NDEBUG
-#define MBGL_CHECK_ERROR(cmd) ([&]() { struct __MBGL_C_E { ~__MBGL_C_E() noexcept(false) { ::mbgl::gl::checkError(#cmd, __FILE__, __LINE__); } } __MBGL_C_E; return cmd; }())
-#else
-#define MBGL_CHECK_ERROR(cmd) (cmd)
-#endif
-
-} // namespace gl
-} // namespace mbgl
diff --git a/src/mbgl/gl/program_binary_extension.hpp b/src/mbgl/gl/program_binary_extension.hpp
index a4aa1eeefc..b14876728b 100644
--- a/src/mbgl/gl/program_binary_extension.hpp
+++ b/src/mbgl/gl/program_binary_extension.hpp
@@ -2,7 +2,7 @@
#include <mbgl/gl/features.hpp>
#include <mbgl/gl/extension.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
#if MBGL_HAS_BINARY_PROGRAMS
diff --git a/src/mbgl/gl/stencil_mode.cpp b/src/mbgl/gl/stencil_mode.cpp
index 6858d6d106..fc6f3076dc 100644
--- a/src/mbgl/gl/stencil_mode.cpp
+++ b/src/mbgl/gl/stencil_mode.cpp
@@ -1,5 +1,5 @@
#include <mbgl/gl/stencil_mode.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
#include <mbgl/util/traits.hpp>
namespace mbgl {
diff --git a/src/mbgl/gl/uniform.cpp b/src/mbgl/gl/uniform.cpp
index 3d8a8d53d9..e6c77be50b 100644
--- a/src/mbgl/gl/uniform.cpp
+++ b/src/mbgl/gl/uniform.cpp
@@ -1,5 +1,6 @@
#include <mbgl/gl/uniform.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
+#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/size.hpp>
#include <mbgl/util/convert.hpp>
@@ -9,6 +10,8 @@
namespace mbgl {
namespace gl {
+using namespace platform;
+
UniformLocation uniformLocation(ProgramID id, const char* name) {
return MBGL_CHECK_ERROR(glGetUniformLocation(id, name));
}
@@ -101,8 +104,7 @@ ActiveUniforms activeUniforms(ProgramID id) {
GLint size;
GLenum type;
for (GLint index = 0; index < count; index++) {
- MBGL_CHECK_ERROR(
- glGetActiveUniform(id, index, maxLength, &length, &size, &type, name.get()));
+ MBGL_CHECK_ERROR(glGetActiveUniform(id, index, maxLength, &length, &size, &type, name.get()));
active.emplace(
std::string{ name.get(), static_cast<size_t>(length) },
ActiveUniform{ static_cast<size_t>(size), static_cast<UniformDataType>(type) });
diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp
index 581acd0358..d685e533a5 100644
--- a/src/mbgl/gl/value.cpp
+++ b/src/mbgl/gl/value.cpp
@@ -1,5 +1,4 @@
#include <mbgl/gl/value.hpp>
-#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/vertex_array_extension.hpp>
@@ -7,14 +6,12 @@ namespace mbgl {
namespace gl {
namespace value {
+using namespace platform;
+
const constexpr ClearDepth::Type ClearDepth::Default;
void ClearDepth::Set(const Type& value) {
-#if MBGL_USE_GLES2
MBGL_CHECK_ERROR(glClearDepthf(value));
-#else
- MBGL_CHECK_ERROR(glClearDepth(value));
-#endif
}
ClearDepth::Type ClearDepth::Get() {
@@ -130,11 +127,7 @@ StencilOp::Type StencilOp::Get() {
const constexpr DepthRange::Type DepthRange::Default;
void DepthRange::Set(const Type& value) {
-#if MBGL_USE_GLES2
MBGL_CHECK_ERROR(glDepthRangef(value.min, value.max));
-#else
- MBGL_CHECK_ERROR(glDepthRange(value.min, value.max));
-#endif
}
DepthRange::Type DepthRange::Get() {
diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp
index 25f22aa038..8e2c995e11 100644
--- a/src/mbgl/gl/value.hpp
+++ b/src/mbgl/gl/value.hpp
@@ -6,6 +6,7 @@
#include <mbgl/gl/color_mode.hpp>
#include <mbgl/gl/cull_face_mode.hpp>
#include <mbgl/gl/attribute.hpp>
+#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/size.hpp>
#include <mbgl/util/range.hpp>
diff --git a/src/mbgl/gl/vertex_array.cpp b/src/mbgl/gl/vertex_array.cpp
index d552a8292e..0892c3b08b 100644
--- a/src/mbgl/gl/vertex_array.cpp
+++ b/src/mbgl/gl/vertex_array.cpp
@@ -1,6 +1,5 @@
#include <mbgl/gl/vertex_array.hpp>
#include <mbgl/gl/context.hpp>
-#include <mbgl/gl/gl.hpp>
namespace mbgl {
namespace gl {
diff --git a/src/mbgl/gl/vertex_array_extension.hpp b/src/mbgl/gl/vertex_array_extension.hpp
index 707a20e6f0..8c6abdc609 100644
--- a/src/mbgl/gl/vertex_array_extension.hpp
+++ b/src/mbgl/gl/vertex_array_extension.hpp
@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/gl/extension.hpp>
-#include <mbgl/gl/gl.hpp>
+#include <mbgl/gl/defines.hpp>
namespace mbgl {
namespace gl {
@@ -25,11 +25,11 @@ public:
{ "GL_APPLE_vertex_array_object", "glGenVertexArraysAPPLE" } })) {
}
- const ExtensionFunction<void(GLuint array)> bindVertexArray;
+ const ExtensionFunction<void(platform::GLuint array)> bindVertexArray;
- const ExtensionFunction<void(GLsizei n, const GLuint* arrays)> deleteVertexArrays;
+ const ExtensionFunction<void(platform::GLsizei n, const platform::GLuint* arrays)> deleteVertexArrays;
- const ExtensionFunction<void(GLsizei n, GLuint* arrays)> genVertexArrays;
+ const ExtensionFunction<void(platform::GLsizei n, platform::GLuint* arrays)> genVertexArrays;
};
} // namespace extension
diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp
index 9e65830faf..22c1b4c5d2 100644
--- a/src/mbgl/renderer/layers/render_custom_layer.cpp
+++ b/src/mbgl/renderer/layers/render_custom_layer.cpp
@@ -3,9 +3,9 @@
#include <mbgl/renderer/backend_scope.hpp>
#include <mbgl/renderer/renderer_backend.hpp>
#include <mbgl/renderer/bucket.hpp>
+#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/style/layers/custom_layer_impl.hpp>
#include <mbgl/map/transform_state.hpp>
-#include <mbgl/gl/gl.hpp>
#include <mbgl/util/mat4.hpp>
namespace mbgl {
@@ -15,7 +15,7 @@ using namespace style;
RenderCustomLayer::RenderCustomLayer(Immutable<style::CustomLayer::Impl> _impl)
: RenderLayer(std::move(_impl)), host(impl().host) {
assert(BackendScope::exists());
- host->initialize();
+ MBGL_CHECK_ERROR(host->initialize());
}
RenderCustomLayer::~RenderCustomLayer() {
@@ -23,7 +23,7 @@ RenderCustomLayer::~RenderCustomLayer() {
if (contextDestroyed) {
host->contextLost();
} else {
- host->deinitialize();
+ MBGL_CHECK_ERROR(host->deinitialize());
}
}