1 #ifndef MSP_GL_FRAMEFORMAT_H_
2 #define MSP_GL_FRAMEFORMAT_H_
5 #include "pixelformat.h"
11 Describes a single attachment of a framebuffer, including the type and index
12 of the attachment point and the format of the attached texture.
14 The values are bitfields laid as follows:
17 │ │ │ │ └╴Number of components
18 │ │ │ └───╴Reverse order flag
19 │ │ └─────╴Size of one component
20 │ └──────────╴Floating-point flag
21 └────────────╴Attachment index
23 This information is presented for internal documentation purposes only; it is
24 inadvisable for applications to rely on it.
26 enum FrameAttachment: std::uint16_t
28 COLOR_ATTACHMENT = 0x0014,
29 DEPTH_ATTACHMENT = 0xF941,
30 STENCIL_ATTACHMENT = 0xFC11
34 Describes the complete format of a framebuffer. It can hold multiple
35 attachments (currently up to seven) as well as a sample count.
40 enum { MAX_ATTACHMENTS = 7 };
42 std::uint8_t count = 0;
43 std::uint8_t samples = 0;
44 FrameAttachment attachments[MAX_ATTACHMENTS];
47 FrameFormat() = default;
48 FrameFormat(FrameAttachment);
50 FrameFormat operator,(FrameAttachment) const;
51 FrameFormat operator,(PixelFormat) const;
52 FrameFormat operator,(unsigned) const;
54 FrameFormat &set_samples(unsigned);
55 unsigned get_samples() const { return samples; }
57 unsigned size() const { return count; }
58 bool empty() const { return !count; }
59 const FrameAttachment *begin() const { return attachments; }
60 const FrameAttachment *end() const { return attachments+count; }
61 int index(FrameAttachment) const;
64 inline FrameFormat operator,(FrameAttachment fa1, FrameAttachment fa2)
65 { return (FrameFormat(fa1), fa2); }
67 FrameAttachment make_typed_attachment(FrameAttachment, PixelFormat);
69 inline FrameAttachment operator,(FrameAttachment fa, PixelFormat pf)
70 { return make_typed_attachment(fa, pf); }
72 FrameAttachment make_indexed_attachment(FrameAttachment, unsigned);
74 inline FrameAttachment operator,(FrameAttachment fa, unsigned i)
75 { return make_indexed_attachment(fa, i); }
77 inline unsigned get_attach_point(FrameAttachment fa)
80 PixelFormat get_attachment_pixelformat(FrameAttachment);
85 #include "frameformat_backend.h"