From f70f604e5b99062a24764716ccdeda64c36320be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 22 Mar 2017 14:56:43 +0100 Subject: [core] Privatize gl/gl.hpp --- cmake/core-files.cmake | 2 +- include/mbgl/gl/gl.hpp | 50 ---------------------------------------- platform/glfw/glfw_view.cpp | 20 ++++++++-------- platform/glfw/glfw_view.hpp | 1 - platform/macos/src/MGLMapView.mm | 4 ++-- src/mbgl/gl/gl.hpp | 50 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 64 deletions(-) delete mode 100644 include/mbgl/gl/gl.hpp create mode 100644 src/mbgl/gl/gl.hpp diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index f9636a2564..7fb5329adf 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -49,7 +49,6 @@ set(MBGL_CORE_FILES src/mbgl/geometry/line_atlas.hpp # gl - include/mbgl/gl/gl.hpp src/mbgl/gl/attribute.cpp src/mbgl/gl/attribute.hpp src/mbgl/gl/color_mode.cpp @@ -67,6 +66,7 @@ set(MBGL_CORE_FILES src/mbgl/gl/features.hpp src/mbgl/gl/framebuffer.hpp src/mbgl/gl/gl.cpp + src/mbgl/gl/gl.hpp src/mbgl/gl/index_buffer.hpp src/mbgl/gl/object.cpp src/mbgl/gl/object.hpp diff --git a/include/mbgl/gl/gl.hpp b/include/mbgl/gl/gl.hpp deleted file mode 100644 index 3a577b289b..0000000000 --- a/include/mbgl/gl/gl.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#pragma once - -#include -#include - -#if __APPLE__ - #include "TargetConditionals.h" - #if TARGET_OS_IPHONE - #include - #include - #elif TARGET_IPHONE_SIMULATOR - #include - #include - #elif TARGET_OS_MAC - #include - #include - #include - #else - #error Unsupported Apple platform - #endif -#elif __ANDROID__ || MBGL_USE_GLES2 - #define GL_GLEXT_PROTOTYPES - #include - #include -#elif __QT_ && QT_VERSION >= 0x050000 - #define GL_GLEXT_PROTOTYPES - #include -#else - #define GL_GLEXT_PROTOTYPES - #include - #include -#endif - -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/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index e833478795..498b021bff 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -559,9 +559,9 @@ void showDebugImage(std::string name, const char *data, size_t width, size_t hei glfwGetFramebufferSize(debugWindow, &fbWidth, &fbHeight); float scale = static_cast(fbWidth) / static_cast(width); - MBGL_CHECK_ERROR(glPixelZoom(scale, -scale)); - MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f)); - MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data)); + glPixelZoom(scale, -scale); + glRasterPos2f(-1.0f, 1.0f); + glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); glfwSwapBuffers(debugWindow); @@ -591,13 +591,13 @@ void showColorDebugImage(std::string name, const char *data, size_t logicalWidth float xScale = static_cast(fbWidth) / static_cast(width); float yScale = static_cast(fbHeight) / static_cast(height); - MBGL_CHECK_ERROR(glClearColor(0.8, 0.8, 0.8, 1)); - MBGL_CHECK_ERROR(glClear(GL_COLOR_BUFFER_BIT)); - MBGL_CHECK_ERROR(glEnable(GL_BLEND)); - MBGL_CHECK_ERROR(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); - MBGL_CHECK_ERROR(glPixelZoom(xScale, -yScale)); - MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f)); - MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data)); + glClearColor(0.8, 0.8, 0.8, 1); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPixelZoom(xScale, -yScale); + glRasterPos2f(-1.0f, 1.0f); + glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data); glfwSwapBuffers(debugWindow); diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index 1cadae2e0f..bc50eba819 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 3bf3909c8e..49d7509fc7 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -28,7 +28,6 @@ #import #import #import -#import #import #import #import @@ -55,6 +54,7 @@ #import "NSPredicate+MGLAdditions.h" #import +#import class MGLMapViewImpl; class MGLAnnotationContext; @@ -2866,7 +2866,7 @@ public: } void updateAssumedState() override { - MBGL_CHECK_ERROR(glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo)); + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo); assumeFramebufferBinding(fbo); assumeViewportSize(nativeView.framebufferSize); } diff --git a/src/mbgl/gl/gl.hpp b/src/mbgl/gl/gl.hpp new file mode 100644 index 0000000000..3a577b289b --- /dev/null +++ b/src/mbgl/gl/gl.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include +#include + +#if __APPLE__ + #include "TargetConditionals.h" + #if TARGET_OS_IPHONE + #include + #include + #elif TARGET_IPHONE_SIMULATOR + #include + #include + #elif TARGET_OS_MAC + #include + #include + #include + #else + #error Unsupported Apple platform + #endif +#elif __ANDROID__ || MBGL_USE_GLES2 + #define GL_GLEXT_PROTOTYPES + #include + #include +#elif __QT_ && QT_VERSION >= 0x050000 + #define GL_GLEXT_PROTOTYPES + #include +#else + #define GL_GLEXT_PROTOTYPES + #include + #include +#endif + +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 -- cgit v1.2.1