]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/frameformat.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / core / frameformat.cpp
index f56d13a68b27db15bd98c9fb97fa5e187bd23fe6..d80fca3d4bbacc419d7680b36fced8b83e7092cf 100644 (file)
@@ -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)
@@ -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<FrameAttachment>((fa&0xFC00) | (is_float(type)*0x100) | get_type_size(type)<<4 | get_component_count(comp));
+       return static_cast<FrameAttachment>((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)
@@ -112,7 +108,7 @@ PixelFormat get_attachment_pixelformat(FrameAttachment fa)
        else if(get_attach_point(fa)==get_attach_point(STENCIL_ATTACHMENT))
                comp = STENCIL_INDEX;
        else
-               comp = static_cast<PixelComponents>(fa&7);
+               comp = static_cast<PixelComponents>((fa&7) | (fa&8)<<2);
 
        DataType type;
        if(fa&0x100)
@@ -123,30 +119,5 @@ PixelFormat get_attachment_pixelformat(FrameAttachment 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);
-}
-
-GLenum get_gl_buffer_bits(const FrameFormat &format)
-{
-       GLenum 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