]> git.tdb.fi Git - libs/gl.git/commitdiff
Redesign OffscreenView to own the render target
authorMikko Rasa <tdb@tdb.fi>
Wed, 2 Aug 2023 20:33:30 +0000 (23:33 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 2 Aug 2023 20:33:30 +0000 (23:33 +0300)
Change RenderTarget::get_framebuffer to const to accommodate this;
outsiders should not modify the framebuffer's structure anyway.

source/render/offscreenview.cpp
source/render/offscreenview.h
source/render/rendertarget.h

index 71851c7266253814973b4866eea715a703011009..a79de1dbca94d2fe9c6b19cdd12b5208570405b6 100644 (file)
@@ -4,12 +4,8 @@
 namespace Msp {
 namespace GL {
 
-OffscreenView::OffscreenView(Framebuffer &t):
-       target(t)
-{ }
-
-OffscreenView::OffscreenView(RenderTarget &t):
-       target(t.get_framebuffer())
+OffscreenView::OffscreenView(unsigned w, unsigned h, const FrameFormat &f):
+       target(w, h, f)
 { }
 
 } // namespace GL
index e845aea2fd1a06cd53b0fb74b3b3d267b0b8e962..bd2e22e2971b1db4d5bd46b0ae0764d1c7baea48 100644 (file)
@@ -2,28 +2,28 @@
 #define MSP_GL_OFFSCREENVIEW_H_
 
 #include "mspgl_api.h"
+#include "rendertarget.h"
 #include "view.h"
 
 namespace Msp {
 namespace GL {
 
-class Framebuffer;
-class RenderTarget;
-
 /**
 A View targeting an offscreen framebuffer.
 */
 class MSPGL_API OffscreenView: public View
 {
 private:
-       Framebuffer &target;
+       RenderTarget target;
 
 public:
-       OffscreenView(Framebuffer &);
-       OffscreenView(RenderTarget &);
+       OffscreenView(unsigned, unsigned, const FrameFormat &);
+
+       const Texture2D &get_target_texture(unsigned i = 0) const { return target.get_target_texture(i); }
+       const Texture2D &get_target_texture(FrameAttachment a) const { return target.get_target_texture(a); }
 
 private:
-       virtual const Framebuffer &get_target() const { return target; }
+       virtual const Framebuffer &get_target() const { return target.get_framebuffer(); }
 };
 
 } // namespace GL
index 1646abceba7f2d4321e753b30770f8022c0a571a..f3406f0b051c6e7afbb15f26ce85d1509561a2e0 100644 (file)
@@ -34,7 +34,7 @@ public:
        unsigned get_width() const { return width; }
        unsigned get_height() const { return height; }
        const FrameFormat &get_format() const { return fbo.get_format(); }
-       Framebuffer &get_framebuffer() { return fbo; }
+       const Framebuffer &get_framebuffer() const { return fbo; }
        const Texture2D &get_target_texture(unsigned) const;
        const Texture2D &get_target_texture(FrameAttachment) const;