]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pixelformat.cpp
Cosmetic tweaks
[libs/gl.git] / source / pixelformat.cpp
index 7647717a44ad3d047e7bfbc0d386a575f5564701..679c6467503e3d4d059668890b1eb2922eb54426 100644 (file)
@@ -10,20 +10,10 @@ namespace GL {
 
 void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
 {
-       if(conv.get()=="COLOR_INDEX")
-               fmt = COLOR_INDEX;
-       else if(conv.get()=="STENCIL_INDEX")
+       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")
@@ -52,7 +42,6 @@ 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;
@@ -65,16 +54,22 @@ PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf)
        }
 }
 
-PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat pf)
+PixelFormat storage_pixelformat_from_graphics(Graphics::PixelFormat pf, bool srgb)
 {
+       PixelFormat result;
        switch(pf)
        {
        case Graphics::RGBX:
        case Graphics::BGR:
-       case Graphics::BGRX: return RGB;
-       case Graphics::BGRA: return RGBA;
-       default: return pixelformat_from_graphics(pf);
+       case Graphics::BGRX: result = RGB; break;
+       case Graphics::BGRA: result = RGBA; break;
+       default: result = pixelformat_from_graphics(pf);
        }
+
+       if(srgb)
+               return get_srgb_pixelformat(result);
+       else
+               return result;
 }
 
 PixelFormat get_base_pixelformat(PixelFormat pf)
@@ -125,12 +120,8 @@ 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:
        case SLUMINANCE:
                return 1;
@@ -144,7 +135,7 @@ unsigned get_component_count(PixelFormat pf)
        case BGRA:
                return 4;
        default:
-               throw invalid_argument("get_pixelformat_component_count");
+               throw invalid_argument("get_component_count");
        }
 }