X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpixelformat.cpp;h=836012f9d0c7cfd294e542bcbb0c10d3cc932c69;hb=619aae12e01f25e79626a94c973927e5599e99a5;hp=4744ebbdfbad3a61c209be9085a01e15c8e4b1bc;hpb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;p=libs%2Fgl.git diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp index 4744ebbd..836012f9 100644 --- a/source/pixelformat.cpp +++ b/source/pixelformat.cpp @@ -1,4 +1,6 @@ -#include "except.h" +#include +#include +#include #include "pixelformat.h" using namespace std; @@ -6,41 +8,36 @@ using namespace std; namespace Msp { namespace GL { -istream &operator>>(istream &in, PixelFormat &fmt) +void operator>>(const LexicalConverter &conv, PixelFormat &fmt) { - string word; - - in>>word; - if(word=="COLOR_INDEX") + if(conv.get()=="COLOR_INDEX") fmt = COLOR_INDEX; - else if(word=="STENCIL_INDEX") + else if(conv.get()=="STENCIL_INDEX") fmt = STENCIL_INDEX; - else if(word=="DEPTH_COMPONENT") + else if(conv.get()=="DEPTH_COMPONENT") fmt = DEPTH_COMPONENT; - else if(word=="RED") + else if(conv.get()=="RED") fmt = RED; - else if(word=="GREEN") + else if(conv.get()=="GREEN") fmt = GREEN; - else if(word=="BLUE") + else if(conv.get()=="BLUE") fmt = BLUE; - else if(word=="ALPHA") + else if(conv.get()=="ALPHA") fmt = ALPHA; - else if(word=="RGB") + else if(conv.get()=="RGB") fmt = RGB; - else if(word=="RGBA") + else if(conv.get()=="RGBA") fmt = RGBA; - else if(word=="BGR") + else if(conv.get()=="BGR") fmt = BGR; - else if(word=="BGRA") + else if(conv.get()=="BGRA") fmt = BGRA; - else if(word=="LUMINANCE") + else if(conv.get()=="LUMINANCE") fmt = LUMINANCE; - else if(word=="LUMINANCE_ALPHA") + else if(conv.get()=="LUMINANCE_ALPHA") fmt = LUMINANCE_ALPHA; else - in.setstate(ios_base::failbit); - - return in; + throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get())); } PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf) @@ -54,7 +51,7 @@ PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf) case Graphics::RGBA: return RGBA; case Graphics::BGR: return BGR; case Graphics::BGRA: return BGRA; - default: throw InvalidParameterValue("Unknown Graphics::PixelFormat"); + default: throw invalid_argument("pixelformat_from_graphics"); } } @@ -78,5 +75,28 @@ PixelFormat get_base_pixelformat(PixelFormat pf) } } +void require_pixelformat(PixelFormat pf) +{ + switch(pf) + { + case RGB16F: + case RGB32F: + case RGBA16F: + case RGBA32F: + case LUMINANCE16F: + case LUMINANCE32F: + case LUMINANCE_ALPHA16F: + case LUMINANCE_ALPHA32F: + { static Require _req(ARB_texture_float); } + break; + case BGR: + case BGRA: + { static Require _req(EXT_bgra); } + break; + default: + break; + } +} + } // namespace GL } // namespace Msp