X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fcore%2Fframeformat.cpp;h=d80fca3d4bbacc419d7680b36fced8b83e7092cf;hp=30d7a47f36500d43172e8fece217e4ebb608c1ed;hb=HEAD;hpb=6353307898cd397e2bcde13e2448a8a678a60004 diff --git a/source/core/frameformat.cpp b/source/core/frameformat.cpp index 30d7a47f..d80fca3d 100644 --- a/source/core/frameformat.cpp +++ b/source/core/frameformat.cpp @@ -1,4 +1,3 @@ -#include "deviceinfo.h" #include "error.h" #include "frameformat.h" @@ -7,11 +6,6 @@ using namespace std; namespace Msp { namespace GL { -FrameFormat::FrameFormat(): - count(0), - samples(1) -{ } - FrameFormat::FrameFormat(FrameAttachment fa): count(1), samples(1) @@ -36,8 +30,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 +42,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; } @@ -84,12 +78,14 @@ FrameAttachment make_typed_attachment(FrameAttachment fa, PixelFormat pf) } else { - if(comp!=RED && comp!=RG && comp!=RGB && comp!=RGBA) + if(comp!=RED && comp!=RG && comp!=RGB && comp!=RGBA && comp!=BGR && comp!=BGRA) + throw invalid_argument("make_typed_attachment"); + if(get_required_swizzle(comp)) throw invalid_argument("make_typed_attachment"); } 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 | ((comp&0x20)>>2) | get_component_count(comp)); } FrameAttachment make_indexed_attachment(FrameAttachment fa, unsigned i) @@ -104,7 +100,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)) @@ -112,10 +108,10 @@ PixelFormat get_attachment_pixelformat(UInt16 fa) else if(get_attach_point(fa)==get_attach_point(STENCIL_ATTACHMENT)) comp = STENCIL_INDEX; else - comp = static_cast(fa&7); + comp = static_cast((fa&7) | (fa&8)<<2); DataType type; - if(fa&0x80) + if(fa&0x100) type = static_cast((fa&0x70)>>4 | 0x300); else type = static_cast((fa&0x70)>>4); @@ -123,15 +119,5 @@ PixelFormat get_attachment_pixelformat(UInt16 fa) return make_pixelformat(comp, type); } -GLenum get_gl_attachment(FrameAttachment fa) -{ - if(get_attach_point(fa)==get_attach_point(DEPTH_ATTACHMENT)) - return GL_DEPTH_ATTACHMENT; - else if(get_attach_point(fa)==get_attach_point(STENCIL_ATTACHMENT)) - return GL_STENCIL_ATTACHMENT; - else - return GL_COLOR_ATTACHMENT0+get_attach_point(fa); -} - } // namespace GL } // namespace Msp