]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/rendertarget.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / render / rendertarget.h
index 7d796a3cefe80540a409f5e6b80a6535aefa87f0..a59e382c105f81ad18916056deab8a94e27f333c 100644 (file)
@@ -1,86 +1,43 @@
 #ifndef RENDERTARGET_H_
 #define RENDERTARGET_H_
 
+#include <msp/core/noncopyable.h>
 #include "framebuffer.h"
-#include "texture2d.h"
 
 namespace Msp {
 namespace GL {
 
-enum RenderOutput
-{
-       RENDER_COLOR = 0|3,
-       RENDER_DEPTH = 192|12
-};
-
-class RenderTargetFormat
-{
-private:
-       enum { MAX_OUTPUTS = 7 };
+class Texture;
+class Texture2D;
 
-       unsigned char count;
-       unsigned char outputs[MAX_OUTPUTS];
-
-public:
-       RenderTargetFormat();
-       RenderTargetFormat(RenderOutput);
-
-       RenderTargetFormat operator,(RenderOutput) const;
-       RenderTargetFormat operator,(PixelFormat) const;
-
-       bool empty() const { return !count; }
-       const unsigned char *begin() const { return outputs; }
-       const unsigned char *end() const { return outputs+count; }
-       int index(RenderOutput) const;
-};
+/**
+Wraps a Framebuffer and its attachments for easier management.
 
-inline RenderTargetFormat operator,(RenderOutput o1, RenderOutput o2)
-{ return (RenderTargetFormat(o1), o2); }
-
-inline RenderTargetFormat operator,(RenderOutput o, PixelFormat f)
-{ return (RenderTargetFormat(o), f); }
-
-inline unsigned get_output_type(unsigned char o)
-{ return o>>4; }
-
-PixelFormat get_output_pixelformat(unsigned char);
-
-
-class RenderTarget
+All attachments will be created as 2D or 2D multisample textures, depending on
+the sample count of the format.  For multisampled formats, resolve attachments
+are also created.
+*/
+class RenderTarget: public NonCopyable
 {
 private:
-       union TargetBuffer
-       {
-               Texture2D *texture;
-               Renderbuffer *buffer;
-       };
-
        unsigned width;
        unsigned height;
-       unsigned samples;
-       RenderTargetFormat format;
-       std::vector<TargetBuffer> buffers;
+       std::vector<Texture *> textures;
        Framebuffer fbo;
 
 public:
-       RenderTarget(unsigned, unsigned, RenderOutput);
-       RenderTarget(unsigned, unsigned, const RenderTargetFormat & = (RENDER_COLOR, RENDER_DEPTH));
-       RenderTarget(unsigned, unsigned, unsigned, const RenderTargetFormat & = (RENDER_COLOR, RENDER_DEPTH));
-private:
-       RenderTarget(const RenderTarget &);
-       RenderTarget &operator=(const RenderTarget &);
-       void init(unsigned, unsigned, unsigned, const RenderTargetFormat &);
-public:
+       RenderTarget(unsigned, unsigned, const FrameFormat & = (COLOR_ATTACHMENT, DEPTH_ATTACHMENT));
+       RenderTarget(RenderTarget &&) = default;
        ~RenderTarget();
 
        unsigned get_width() const { return width; }
        unsigned get_height() const { return height; }
-       const RenderTargetFormat &get_format() const { return format; }
+       const FrameFormat &get_format() const { return fbo.get_format(); }
        Framebuffer &get_framebuffer() { return fbo; }
-       void set_texture_filter(TextureFilter);
        const Texture2D &get_target_texture(unsigned) const;
-       const Texture2D &get_target_texture(RenderOutput) const;
-       void blit_from(const RenderTarget &);
+       const Texture2D &get_target_texture(FrameAttachment) const;
+
+       void set_debug_name(const std::string &);
 };
 
 } // namespace GL