]> git.tdb.fi Git - libs/gl.git/blob - source/render/rendertarget.h
Rework multisample resolve to use resolve attachments
[libs/gl.git] / source / render / rendertarget.h
1 #ifndef RENDERTARGET_H_
2 #define RENDERTARGET_H_
3
4 #include <msp/core/noncopyable.h>
5 #include "framebuffer.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Texture;
11 class Texture2D;
12
13 /**
14 Wraps a Framebuffer and its attachments for easier management.
15
16 All attachments will be created as 2D or 2D multisample textures, depending on
17 the sample count of the format.  For multisampled formats, resolve attachments
18 are also created.
19 */
20 class RenderTarget: public NonCopyable
21 {
22 private:
23         unsigned width;
24         unsigned height;
25         std::vector<Texture *> textures;
26         Framebuffer fbo;
27
28 public:
29         RenderTarget(unsigned, unsigned, const FrameFormat & = (COLOR_ATTACHMENT, DEPTH_ATTACHMENT));
30         RenderTarget(RenderTarget &&) = default;
31         ~RenderTarget();
32
33         unsigned get_width() const { return width; }
34         unsigned get_height() const { return height; }
35         const FrameFormat &get_format() const { return fbo.get_format(); }
36         Framebuffer &get_framebuffer() { return fbo; }
37         const Texture2D &get_target_texture(unsigned) const;
38         const Texture2D &get_target_texture(FrameAttachment) const;
39
40         void set_debug_name(const std::string &);
41 };
42
43 } // namespace GL
44 } // namespace Msp
45
46 #endif