]> git.tdb.fi Git - libs/gl.git/commitdiff
Move WindowView::render to the backend
authorMikko Rasa <tdb@tdb.fi>
Wed, 10 Nov 2021 14:16:18 +0000 (16:16 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 10 Nov 2021 17:56:43 +0000 (19:56 +0200)
Presenting images work very differently in Vulkan so the swap_buffers
call can't be in the common part.

source/backends/opengl/windowview_backend.cpp
source/backends/opengl/windowview_backend.h
source/render/windowview.cpp
source/render/windowview.h

index 3bda4107e7760029e5056d53bf057a0c0b23a6df..b388911e421caaef06a6b1ee6c1461a4106f7236 100644 (file)
@@ -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<WindowView *>(this)->device;
+       device.get_context().swap_buffers();
+}
+
 void OpenGLWindowView::resize_framebuffer(unsigned w, unsigned h)
 {
        sys_framebuf.resize(w, h);
index f51c4bb60597f7600dbd05d180da896dd786d74c..c21dee00cc0323eeb1421c2a9ee4d1dfaa621fbd 100644 (file)
@@ -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);
index 44e6187aee23558e3faf2bba71c895c36f1d625e..d08d48809892f01f35d2125fcc1f4dcfb196d4ee 100644 (file)
@@ -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);
index 93769f19217ed35f3b3fbcfd277e7cf6cccd1363..43b8d442ea85dd47fbf8745a0265f3c1d5086a68 100644 (file)
@@ -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);