diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-02 14:11:37 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-05-15 11:57:43 -0700 |
commit | 179c5fe83ba4ebe593208db9ca41f409024824ef (patch) | |
tree | c54be0d8debe9d7ed3a7f4fd4be21af041b5bc88 /platform/glfw | |
parent | da5bd4d6e3a0202cc4f9e4d3d17e159eb90acba6 (diff) | |
download | qtlocation-mapboxgl-179c5fe83ba4ebe593208db9ca41f409024824ef.tar.gz |
[core] add gfx::CommandEncoder::present()
Diffstat (limited to 'platform/glfw')
-rw-r--r-- | platform/glfw/glfw_gl_backend.cpp | 17 | ||||
-rw-r--r-- | platform/glfw/glfw_gl_backend.hpp | 4 | ||||
-rw-r--r-- | platform/glfw/glfw_view.cpp | 13 |
3 files changed, 20 insertions, 14 deletions
diff --git a/platform/glfw/glfw_gl_backend.cpp b/platform/glfw/glfw_gl_backend.cpp index 2d622fc193..4d9d87dd72 100644 --- a/platform/glfw/glfw_gl_backend.cpp +++ b/platform/glfw/glfw_gl_backend.cpp @@ -15,11 +15,15 @@ public: backend.setViewport(0, 0, backend.getSize()); } + void swap() override { + backend.swap(); + } + private: GLFWGLBackend& backend; }; -GLFWGLBackend::GLFWGLBackend(GLFWwindow* window_) +GLFWGLBackend::GLFWGLBackend(GLFWwindow* window_, const bool capFrameRate) : mbgl::gl::RendererBackend(mbgl::gfx::ContextMode::Unique), mbgl::gfx::Renderable( [window_] { @@ -29,6 +33,13 @@ GLFWGLBackend::GLFWGLBackend(GLFWwindow* window_) }(), std::make_unique<GLFWGLRenderableResource>(*this)), window(window_) { + glfwMakeContextCurrent(window); + if (!capFrameRate) { + // Disables vsync on platforms that support it. + glfwSwapInterval(0); + } else { + glfwSwapInterval(1); + } } GLFWGLBackend::~GLFWGLBackend() = default; @@ -57,3 +68,7 @@ mbgl::Size GLFWGLBackend::getSize() const { void GLFWGLBackend::setSize(const mbgl::Size newSize) { size = newSize; } + +void GLFWGLBackend::swap() { + glfwSwapBuffers(window); +} diff --git a/platform/glfw/glfw_gl_backend.hpp b/platform/glfw/glfw_gl_backend.hpp index ba4f6fa788..5971bbd0c5 100644 --- a/platform/glfw/glfw_gl_backend.hpp +++ b/platform/glfw/glfw_gl_backend.hpp @@ -11,9 +11,11 @@ class GLFWGLBackend final : public GLFWBackend, public mbgl::gl::RendererBackend, public mbgl::gfx::Renderable { public: - GLFWGLBackend(GLFWwindow*); + GLFWGLBackend(GLFWwindow*, bool capFrameRate); ~GLFWGLBackend() override; + void swap(); + // GLFWRendererBackend implementation public: mbgl::gfx::RendererBackend& getRendererBackend() override { diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index cd979822c4..91e2345bb6 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -91,15 +91,6 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) } glfwSetWindowUserPointer(window, this); - glfwMakeContextCurrent(window); - if (benchmark) { - // Disables vsync on platforms that support it. - glfwSwapInterval(0); - } else { - glfwSwapInterval(1); - } - - glfwSetCursorPosCallback(window, onMouseMove); glfwSetMouseButtonCallback(window, onMouseClick); glfwSetWindowSizeCallback(window, onWindowResize); @@ -109,7 +100,7 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) glfwGetWindowSize(window, &width, &height); - backend = std::make_unique<GLFWGLBackend>(window); + backend = std::make_unique<GLFWGLBackend>(window, benchmark); pixelRatio = static_cast<float>(backend->getSize().width) / width; @@ -585,8 +576,6 @@ void GLFWView::run() { rendererFrontend->render(); - glfwSwapBuffers(window); - report(1000 * (glfwGetTime() - started)); if (benchmark) { invalidate(); |