]> git.tdb.fi Git - libs/gl.git/commitdiff
Have get_component_size return zero for unsized formats
authorMikko Rasa <tdb@tdb.fi>
Thu, 3 Nov 2016 08:27:50 +0000 (10:27 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 3 Nov 2016 08:27:50 +0000 (10:27 +0200)
Get_pixel_size still assumes a component size of at least one byte.

source/pixelformat.cpp

index ac2b1ea73dfde7818fab470b45565e1c5f5e32a2..320fef1f84dd16e447b106df64f1069275c55b89 100644 (file)
@@ -177,6 +177,17 @@ unsigned get_component_size(PixelFormat pf)
 {
        switch(pf)
        {
+       case R8:
+       case RG8:
+       case RGB8:
+       case RGBA8:
+       case SRGB8:
+       case SRGB8_ALPHA8:
+       case LUMINANCE8:
+       case LUMINANCE8_ALPHA8:
+       case SLUMINANCE8:
+       case SLUMINANCE8_ALPHA8:
+               return 1;
        case R16F:
        case RG16F:
        case RGB16F:
@@ -192,13 +203,13 @@ unsigned get_component_size(PixelFormat pf)
        case DEPTH_COMPONENT32:
                return 4;
        default:
-               return 1;
+               return 0;
        }
 }
 
 unsigned get_pixel_size(PixelFormat pf)
 {
-       return get_component_count(pf)*get_component_size(pf);
+       return get_component_count(pf)*max(get_component_size(pf), 1U);
 }
 
 void require_pixelformat(PixelFormat pf)