Exemple #1
0
        public static int GetSizeInBytes(this Texture texture)
        {
            int width  = texture.get_width();
            int height = texture.get_height();

            if (texture is Texture2D)
            {
                Texture2D texture2D    = texture as Texture2D;
                int       bitsPerPixel = TextureEx.GetBitsPerPixel(texture2D.get_format());
                int       mipmapCount  = texture2D.get_mipmapCount();
                int       num1         = 1;
                int       num2         = 0;
                for (; num1 <= mipmapCount; ++num1)
                {
                    num2   += width * height * bitsPerPixel / 8;
                    width  /= 2;
                    height /= 2;
                }
                return(num2);
            }
            if (texture is Texture2DArray)
            {
                Texture2DArray texture2Darray = texture as Texture2DArray;
                int            bitsPerPixel   = TextureEx.GetBitsPerPixel(texture2Darray.get_format());
                int            num1           = 10;
                int            num2           = 1;
                int            num3           = 0;
                int            depth          = texture2Darray.get_depth();
                for (; num2 <= num1; ++num2)
                {
                    num3   += width * height * bitsPerPixel / 8;
                    width  /= 2;
                    height /= 2;
                }
                return(num3 * depth);
            }
            if (!(texture is Cubemap))
            {
                return(0);
            }
            int bitsPerPixel1 = TextureEx.GetBitsPerPixel((texture as Cubemap).get_format());

            return(width * height * bitsPerPixel1 / 8 * 6);
        }