From 8e5214144ec4f3a4fb40b7a7e4d8f09fd10dbb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 27 Feb 2017 18:33:16 +0100 Subject: [core] Ensure that a BackendScope exists when doing GL calls --- platform/glfw/glfw_view.cpp | 2 ++ platform/ios/src/MGLMapView.mm | 4 ++++ platform/macos/src/MGLMapView.mm | 6 +++++- platform/node/src/node_map.cpp | 2 ++ platform/qt/src/qmapboxgl.cpp | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) (limited to 'platform') diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 39dca8080b..d73b147deb 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -462,6 +463,7 @@ void GLFWView::run() { const double started = glfwGetTime(); glfwMakeContextCurrent(window); + mbgl::BackendScope scope { *this, mbgl::BackendScope::ScopeType::Implicit }; updateViewBinding(); map->render(*this); diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 1ccd5ce355..6bd3092445 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -881,6 +882,9 @@ public: { if ( ! self.dormant) { + // The OpenGL implementation automatically enables the OpenGL context for us. + mbgl::BackendScope scope { *_mbglView, mbgl::BackendScope::ScopeType::Implicit }; + _mbglView->updateViewBinding(); _mbglMap->render(*_mbglView); diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 028d41ceda..ef1c0f3bc1 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -29,6 +29,7 @@ #import #import #import +#import #import #import #import @@ -780,6 +781,8 @@ public: return reinterpret_cast(symbol); }); + // The OpenGL implementation automatically enables the OpenGL context for us. + mbgl::BackendScope scope { *_mbglView, mbgl::BackendScope::ScopeType::Implicit }; _mbglView->updateViewBinding(); _mbglMap->render(*_mbglView); @@ -2872,7 +2875,8 @@ public: fbo = mbgl::gl::value::BindFramebuffer::Get(); getContext().bindFramebuffer.setCurrentValue(fbo); getContext().viewport.setCurrentValue(getViewport()); - assert(mbgl::gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); + auto actualViewport = mbgl::gl::value::Viewport::Get(); + assert(actualViewport == getContext().viewport.getCurrentValue()); } void bind() override { diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 881c1b2fb7..52d659b117 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -369,6 +370,7 @@ void NodeMap::startRender(NodeMap::RenderOptions options) { static_cast(options.height * pixelRatio) }; if (!view || view->getSize() != fbSize) { view.reset(); + mbgl::BackendScope scope { backend }; view = std::make_unique(backend.getContext(), fbSize); } diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 3d5da10c36..384bdc8ebf 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1495,6 +1496,9 @@ void QMapboxGL::render() } #endif + // The OpenGL implementation automatically enables the OpenGL context for us. + mbgl::BackendScope scope { *d_ptr, mbgl::BackendScope::ScopeType::Implicit }; + d_ptr->dirty = false; d_ptr->updateViewBinding(); d_ptr->mapObj->render(*d_ptr); -- cgit v1.2.1