From: Mikko Rasa Date: Wed, 10 Nov 2021 14:16:18 +0000 (+0200) Subject: Move WindowView::render to the backend X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9e63512930bc7dace6dc169c65161961e5dcfcf6;p=libs%2Fgl.git Move WindowView::render to the backend Presenting images work very differently in Vulkan so the swap_buffers call can't be in the common part. --- diff --git a/source/backends/opengl/windowview_backend.cpp b/source/backends/opengl/windowview_backend.cpp index 3bda4107..b388911e 100644 --- a/source/backends/opengl/windowview_backend.cpp +++ b/source/backends/opengl/windowview_backend.cpp @@ -1,8 +1,17 @@ +#include "device.h" +#include "windowview.h" #include "windowview_backend.h" namespace Msp { namespace GL { +void OpenGLWindowView::render(Renderer &renderer) +{ + View::render(renderer); + Device &device = static_cast(this)->device; + device.get_context().swap_buffers(); +} + void OpenGLWindowView::resize_framebuffer(unsigned w, unsigned h) { sys_framebuf.resize(w, h); diff --git a/source/backends/opengl/windowview_backend.h b/source/backends/opengl/windowview_backend.h index f51c4bb6..c21dee00 100644 --- a/source/backends/opengl/windowview_backend.h +++ b/source/backends/opengl/windowview_backend.h @@ -14,6 +14,7 @@ protected: OpenGLWindowView() = default; + virtual void render(Renderer &); virtual const Framebuffer &get_target() const { return sys_framebuf; } void resize_framebuffer(unsigned, unsigned); diff --git a/source/render/windowview.cpp b/source/render/windowview.cpp index 44e6187a..d08d4880 100644 --- a/source/render/windowview.cpp +++ b/source/render/windowview.cpp @@ -14,12 +14,6 @@ WindowView::WindowView(Graphics::Window &w): window_resized(window.get_width(), window.get_height()); } -void WindowView::render(Renderer &renderer) -{ - View::render(renderer); - device.get_context().swap_buffers(); -} - void WindowView::window_resized(unsigned w, unsigned h) { resize_framebuffer(w, h); diff --git a/source/render/windowview.h b/source/render/windowview.h index 93769f19..43b8d442 100644 --- a/source/render/windowview.h +++ b/source/render/windowview.h @@ -12,13 +12,15 @@ namespace GL { /** A view targeting a Graphics::Window. -After rendering, buffers are swapped to show the result in the window. +After rendering, the result is presented in the window. The aspect ratio of the view's Camera is automatically updated to match that of the window. */ class WindowView: public WindowViewBackend, public sigc::trackable { + friend WindowViewBackend; + private: Graphics::Window &window; Device &device; @@ -31,7 +33,6 @@ public: virtual unsigned get_height() const { return window.get_height(); } using View::render; - virtual void render(Renderer &); private: void window_resized(unsigned, unsigned);