X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fpixelformat.cpp;h=0b13f3ccefa7fe53cf2e5868b157a7d0c0e5588b;hp=26600b33661fca3c7e73729702278f0aa4664feb;hb=HEAD;hpb=055f553b1a75f44e72f3c2b5a1c98c1e1e8f3f30 diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp deleted file mode 100644 index 26600b33..00000000 --- a/source/pixelformat.cpp +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include -#include "pixelformat.h" - -using namespace std; - -namespace Msp { -namespace GL { - -void operator>>(const LexicalConverter &conv, PixelFormat &fmt) -{ - if(conv.get()=="COLOR_INDEX") - fmt = COLOR_INDEX; - else if(conv.get()=="STENCIL_INDEX") - fmt = STENCIL_INDEX; - else if(conv.get()=="DEPTH_COMPONENT") - fmt = DEPTH_COMPONENT; - else if(conv.get()=="RED") - fmt = RED; - else if(conv.get()=="GREEN") - fmt = GREEN; - else if(conv.get()=="BLUE") - fmt = BLUE; - else if(conv.get()=="ALPHA") - fmt = ALPHA; - else if(conv.get()=="RGB") - fmt = RGB; - else if(conv.get()=="RGBA") - fmt = RGBA; - else if(conv.get()=="BGR") - fmt = BGR; - else if(conv.get()=="BGRA") - fmt = BGRA; - else if(conv.get()=="LUMINANCE") - fmt = LUMINANCE; - else if(conv.get()=="LUMINANCE_ALPHA") - fmt = LUMINANCE_ALPHA; - else - throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get())); -} - -PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf) -{ - switch(pf) - { - case Graphics::COLOR_INDEX: return COLOR_INDEX; - case Graphics::LUMINANCE: return LUMINANCE; - case Graphics::LUMINANCE_ALPHA: return LUMINANCE_ALPHA; - case Graphics::RGB: return RGB; - case Graphics::RGBX: - case Graphics::RGBA: return RGBA; - case Graphics::BGR: return BGR; - case Graphics::BGRX: - case Graphics::BGRA: return BGRA; - default: throw invalid_argument("pixelformat_from_graphics"); - } -} - -PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat pf) -{ - switch(pf) - { - case Graphics::RGBX: - case Graphics::BGR: - case Graphics::BGRX: return RGB; - case Graphics::BGRA: return RGBA; - default: return pixelformat_from_graphics(pf); - } -} - -PixelFormat get_base_pixelformat(PixelFormat pf) -{ - switch(pf) - { - case RGB8: - case RGB16F: - case RGB32F: return RGB; - case RGBA8: - case RGBA16F: - case RGBA32F: return RGBA; - case LUMINANCE8: - case LUMINANCE16F: - case LUMINANCE32F: return LUMINANCE; - case LUMINANCE_ALPHA8: - case LUMINANCE_ALPHA16F: - case LUMINANCE_ALPHA32F: return LUMINANCE_ALPHA; - default: return pf; - } -} - -unsigned get_component_count(PixelFormat pf) -{ - switch(get_base_pixelformat(pf)) - { - case COLOR_INDEX: - case STENCIL_INDEX: - case DEPTH_COMPONENT: - case RED: - case GREEN: - case BLUE: - case LUMINANCE: - return 1; - case LUMINANCE_ALPHA: - return 2; - case RGB: - case BGR: - return 3; - case RGBA: - case BGRA: - return 4; - default: - throw invalid_argument("get_pixelformat_component_count"); - } -} - -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