]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pixelformat.cpp
Pull in sized depth component formats from ARB_depth_texture
[libs/gl.git] / source / pixelformat.cpp
index cd3bb2aa78e30709293dd8dfb13f4d42cd4c481d..99f15307d1304bf41c36c80aa7af825fd41a7171 100644 (file)
@@ -54,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)
@@ -90,6 +96,9 @@ PixelFormat get_base_pixelformat(PixelFormat pf)
        case LUMINANCE_ALPHA32F:
        case SLUMINANCE_ALPHA:
        case SLUMINANCE8_ALPHA8: return LUMINANCE_ALPHA;
+       case DEPTH_COMPONENT16:
+       case DEPTH_COMPONENT24:
+       case DEPTH_COMPONENT32: return DEPTH_COMPONENT;
        default: return pf;
        }
 }
@@ -141,11 +150,15 @@ unsigned get_component_size(PixelFormat pf)
        case RGBA16F:
        case LUMINANCE16F:
        case LUMINANCE_ALPHA16F:
+       case DEPTH_COMPONENT16:
                return 2;
+       case DEPTH_COMPONENT24:
+               return 3;
        case RGB32F:
        case RGBA32F:
        case LUMINANCE32F:
        case LUMINANCE_ALPHA32F:
+       case DEPTH_COMPONENT32:
                return 4;
        default:
                return 1;
@@ -185,6 +198,12 @@ void require_pixelformat(PixelFormat pf)
        case BGRA:
                { static Require _req(EXT_bgra); }
                break;
+       case DEPTH_COMPONENT:
+       case DEPTH_COMPONENT16:
+       case DEPTH_COMPONENT24:
+       case DEPTH_COMPONENT32:
+               { static Require _req(ARB_depth_texture); }
+               break;
        default:
                break;
        }