]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pixelformat.cpp
Remove the deprecated ProgramBuilder class
[libs/gl.git] / source / pixelformat.cpp
index cc6a6d007067a671dd8e849ba8e9ad4951787e74..87191c3423122aefde6b7e38110daae5d28cb4d0 100644 (file)
@@ -64,6 +64,10 @@ void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
                fmt = SRGB8;
        else if(conv.get()=="SRGB8_ALPHA8")
                fmt = SRGB8_ALPHA8;
+       else if(conv.get()=="BGR8")
+               fmt = BGR8;
+       else if(conv.get()=="BGRA8")
+               fmt = BGRA8;
        else if(conv.get()=="LUMINANCE8")
                fmt = LUMINANCE8;
        else if(conv.get()=="LUMINANCE8_ALPHA8")
@@ -127,7 +131,7 @@ PixelFormat pixelformat_from_image(const Graphics::Image &image)
 
 PixelFormat make_pixelformat(PixelComponents comp, DataType type, bool srgb)
 {
-       if(srgb && type!=UNSIGNED_BYTE && comp!=RGB && comp!=RGBA)
+       if(srgb && type!=UNSIGNED_BYTE && comp!=RGB && comp!=RGBA && comp!=BGR && comp!=BGRA)
                throw invalid_argument("make_pixelformat");
 
        switch(comp)
@@ -164,6 +168,14 @@ PixelFormat make_pixelformat(PixelComponents comp, DataType type, bool srgb)
                case FLOAT: return RGBA32F;
                default: throw invalid_argument("make_pixelformat");
                }
+       case BGR:
+               if(type!=UNSIGNED_BYTE)
+                       throw invalid_argument("make_pixelformat");
+               return (srgb ? BGR8 : SBGR8);
+       case BGRA:
+               if(type!=UNSIGNED_BYTE)
+                       throw invalid_argument("make_pixelformat");
+               return (srgb ? BGRA8 : SBGR8_ALPHA8);
        case LUMINANCE:
                if(type!=UNSIGNED_BYTE)
                        throw invalid_argument("make_pixelformat");
@@ -217,6 +229,10 @@ PixelComponents get_components(PixelFormat pf)
        case RGBA16F:
        case RGBA32F:
        case SRGB8_ALPHA8: return RGBA;
+       case BGR8:
+       case SBGR8: return BGR;
+       case BGRA8:
+       case SBGR8_ALPHA8: return BGRA;
        case LUMINANCE8: return LUMINANCE;
        case LUMINANCE8_ALPHA8: return LUMINANCE_ALPHA;
        case STENCIL_INDEX8: return STENCIL_INDEX;
@@ -255,10 +271,10 @@ unsigned get_component_count(PixelComponents comp)
 {
        switch(comp)
        {
-       case STENCIL_INDEX:
-       case DEPTH_COMPONENT:
        case RED:
        case LUMINANCE:
+       case DEPTH_COMPONENT:
+       case STENCIL_INDEX:
                return 1;
        case RG:
        case LUMINANCE_ALPHA:
@@ -284,6 +300,10 @@ DataType get_component_type(PixelFormat pf)
        case RGBA8:
        case SRGB8:
        case SRGB8_ALPHA8:
+       case BGR8:
+       case BGRA8:
+       case SBGR8:
+       case SBGR8_ALPHA8:
        case LUMINANCE8:
        case LUMINANCE8_ALPHA8:
                return UNSIGNED_BYTE;