예제 #1
0
        public static Image Load2DFromFile(Device device, string path)
        {
            ImageDescription description = new();

            if (path.EndsWith(".ktx"))
            {
                description = KTXDecoder.LoadFromFile(path);
            }

            else
            {
                description = IMGLoader.LoadFromFile(path);
            }

            description.ImageType = VkImageType.Image2D;
            description.Flags     = ImageFlags.ShaderResource;
            description.Usage     = ResourceUsage.GPU_Only;


            Image text2d = new Image(device, description);

            text2d.Image2D();

            return(text2d);
        }
예제 #2
0
        public static Image Load2DFromBytes(Device device, byte[] data)
        {
            var tex2D = IMGLoader.LoadFromData(data);

            Image text2d = new Image(device, new ImageDescription
            {
                Flags     = ImageFlags.ShaderResource,
                Usage     = ResourceUsage.GPU_Only,
                Width     = tex2D.Width,
                Height    = tex2D.Height,
                Size      = tex2D.Size,
                Data      = tex2D.Data,
                Format    = tex2D.Format,
                ImageType = VkImageType.Image2D,
            });

            text2d.Image2D();

            return(text2d);
        }