X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fframeformat.cpp;h=3568dffa4b11ee7d29e0fe01c94e23e9fc8c1cb6;hb=24b24e2203c776aacd9744bb947f5cf47b03d328;hp=30d7a47f36500d43172e8fece217e4ebb608c1ed;hpb=6353307898cd397e2bcde13e2448a8a678a60004;p=libs%2Fgl.git diff --git a/source/core/frameformat.cpp b/source/core/frameformat.cpp index 30d7a47f..3568dffa 100644 --- a/source/core/frameformat.cpp +++ b/source/core/frameformat.cpp @@ -1,6 +1,7 @@ #include "deviceinfo.h" #include "error.h" #include "frameformat.h" +#include "gl.h" using namespace std; @@ -36,8 +37,8 @@ FrameFormat FrameFormat::operator,(PixelFormat pf) const throw invalid_operation("FrameFormat::operator,"); FrameFormat r = *this; - UInt16 &fa = r.attachments[r.count-1]; - fa = make_typed_attachment(static_cast(fa), pf); + FrameAttachment &fa = r.attachments[r.count-1]; + fa = make_typed_attachment(fa, pf); return r; } @@ -48,8 +49,8 @@ FrameFormat FrameFormat::operator,(unsigned index) const throw invalid_operation("FrameFormat::operator,"); FrameFormat r = *this; - UInt16 &fa = r.attachments[r.count-1]; - fa = make_indexed_attachment(static_cast(fa), index); + FrameAttachment &fa = r.attachments[r.count-1]; + fa = make_indexed_attachment(fa, index); return r; } @@ -89,7 +90,7 @@ FrameAttachment make_typed_attachment(FrameAttachment fa, PixelFormat pf) } DataType type = get_component_type(pf); - return static_cast((fa&0xFC00) | (is_float(type)*0x80) | get_type_size(type)<<4 | get_component_count(comp)); + return static_cast((fa&0xFC00) | (is_float(type)*0x100) | get_type_size(type)<<4 | get_component_count(comp)); } FrameAttachment make_indexed_attachment(FrameAttachment fa, unsigned i) @@ -104,7 +105,7 @@ FrameAttachment make_indexed_attachment(FrameAttachment fa, unsigned i) throw invalid_argument("make_indexed_attachment"); } -PixelFormat get_attachment_pixelformat(UInt16 fa) +PixelFormat get_attachment_pixelformat(FrameAttachment fa) { PixelComponents comp; if(get_attach_point(fa)==get_attach_point(DEPTH_ATTACHMENT)) @@ -115,7 +116,7 @@ PixelFormat get_attachment_pixelformat(UInt16 fa) comp = static_cast(fa&7); DataType type; - if(fa&0x80) + if(fa&0x100) type = static_cast((fa&0x70)>>4 | 0x300); else type = static_cast((fa&0x70)>>4); @@ -123,7 +124,7 @@ PixelFormat get_attachment_pixelformat(UInt16 fa) return make_pixelformat(comp, type); } -GLenum get_gl_attachment(FrameAttachment fa) +unsigned get_gl_attachment(FrameAttachment fa) { if(get_attach_point(fa)==get_attach_point(DEPTH_ATTACHMENT)) return GL_DEPTH_ATTACHMENT; @@ -133,5 +134,20 @@ GLenum get_gl_attachment(FrameAttachment fa) return GL_COLOR_ATTACHMENT0+get_attach_point(fa); } +unsigned get_gl_buffer_bits(const FrameFormat &format) +{ + unsigned bits = 0; + for(FrameAttachment a: format) + { + if(get_attach_point(a)==get_attach_point(DEPTH_ATTACHMENT)) + bits |= GL_DEPTH_BUFFER_BIT; + else if(get_attach_point(a)==get_attach_point(STENCIL_ATTACHMENT)) + bits |= GL_STENCIL_BUFFER_BIT; + else + bits |= GL_COLOR_BUFFER_BIT; + } + return bits; +} + } // namespace GL } // namespace Msp