X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fframeformat.h;fp=source%2Fcore%2Fframeformat.h;h=45ea9198cd772b1adc3f370307df1ee4a9b17971;hb=6353307898cd397e2bcde13e2448a8a678a60004;hp=0000000000000000000000000000000000000000;hpb=cd5f37b066352119cf92d53d0001af7ff99be437;p=libs%2Fgl.git diff --git a/source/core/frameformat.h b/source/core/frameformat.h new file mode 100644 index 00000000..45ea9198 --- /dev/null +++ b/source/core/frameformat.h @@ -0,0 +1,84 @@ +#ifndef MSP_GL_FRAMEFORMAT_H_ +#define MSP_GL_FRAMEFORMAT_H_ + +#include +#include "pixelformat.h" + +namespace Msp { +namespace GL { + +/** +Describes a single attachment of a framebuffer. The values are bitfields laid +as follows: + +nnnn nn__ fsss _ccc + │ │ │ └╴Number of components + │ │ └─────╴Size of one component + │ └────────╴Floating-point flag + └────────────╴Attachment index + +This information is presented for internal documentation purposes only; it is +inadvisable for programs to rely on it. +*/ +enum FrameAttachment +{ + COLOR_ATTACHMENT = 0x0014, + DEPTH_ATTACHMENT = 0xF8C1, + STENCIL_ATTACHMENT = 0xFC11 +}; + +/** +Describes the complete format of a framebuffer. It can hold multiple +attachments (currently up to seven) as well as a sample count. +*/ +class FrameFormat +{ +private: + enum { MAX_ATTACHMENTS = 7 }; + + UInt8 count; + UInt8 samples; + UInt16 attachments[MAX_ATTACHMENTS]; + +public: + FrameFormat(); + FrameFormat(FrameAttachment); + + FrameFormat operator,(FrameAttachment) const; + FrameFormat operator,(PixelFormat) const; + FrameFormat operator,(unsigned) const; + + FrameFormat &set_samples(unsigned); + unsigned get_samples() const { return samples; } + + unsigned size() const { return count; } + bool empty() const { return !count; } + const UInt16 *begin() const { return attachments; } + const UInt16 *end() const { return attachments+count; } + int index(FrameAttachment) const; +}; + +inline FrameFormat operator,(FrameAttachment fa1, FrameAttachment fa2) +{ return (FrameFormat(fa1), fa2); } + +FrameAttachment make_typed_attachment(FrameAttachment, PixelFormat); + +inline FrameAttachment operator,(FrameAttachment fa, PixelFormat pf) +{ return make_typed_attachment(fa, pf); } + +FrameAttachment make_indexed_attachment(FrameAttachment, unsigned); + +inline FrameAttachment operator,(FrameAttachment fa, unsigned i) +{ return make_indexed_attachment(fa, i); } + +inline unsigned get_attach_point(UInt16 fa) +{ return fa>>10; } + +PixelFormat get_attachment_pixelformat(UInt16); + +GLenum get_gl_attachment(FrameAttachment); + +} // namespace GL +} // namespace Msp + +#endif