Esempio n. 1
0
        public STB GetSTB(string name)
        {
            STB result;

            if (!this.STBs.Contains(name))
            {
                STB sTB = new STB();
                sTB.Load(ContentManager.rootPath + name, ClientType.IROSE);
                this.STBs.Add(name, sTB);
                result = sTB;
            }
            else
            {
                result = (STB)this.STBs[name];
            }
            return(result);
        }
Esempio n. 2
0
        void CreateTextureImage()
        {
            byte[] texData = File.ReadAllBytes(image);
            int    width;
            int    height;
            int    comp;
            var    pixels = STB.Load(texData, out width, out height, out comp, 4);

            long imageSize = width * height * 4;

            VkBuffer       stagingBuffer;
            VkDeviceMemory stagingBufferMemory;

            CreateBuffer(imageSize, VkBufferUsageFlags.TransferSrcBit,
                         VkMemoryPropertyFlags.HostVisibleBit | VkMemoryPropertyFlags.HostCoherentBit,
                         out stagingBuffer, out stagingBufferMemory);

            var data = stagingBufferMemory.Map(0, imageSize);

            Interop.Copy(pixels, data, (int)imageSize);
            stagingBufferMemory.Unmap();

            CreateImage(width, height,
                        VkFormat.R8G8B8A8_Unorm,
                        VkImageTiling.Optimal,
                        VkImageUsageFlags.TransferDstBit | VkImageUsageFlags.SampledBit,
                        VkMemoryPropertyFlags.DeviceLocalBit,
                        out textureImage, out textureImageMemory);

            TransitionImageLayout(textureImage, VkFormat.R8G8B8A8_Unorm,
                                  VkImageLayout.Undefined, VkImageLayout.TransferDstOptimal);
            CopyBufferToImage(stagingBuffer, textureImage, width, height);

            TransitionImageLayout(textureImage, VkFormat.R8G8B8A8_Unorm,
                                  VkImageLayout.TransferDstOptimal, VkImageLayout.ShaderReadOnlyOptimal);

            stagingBuffer.Dispose();
            stagingBufferMemory.Dispose();
        }
Esempio n. 3
0
 public STB GetSTB(string name)
 {
     STB result;
     if (!this.STBs.Contains(name))
     {
         STB sTB = new STB();
         sTB.Load(ContentManager.rootPath + name, ClientType.IROSE);
         this.STBs.Add(name, sTB);
         result = sTB;
     }
     else
     {
         result = (STB)this.STBs[name];
     }
     return result;
 }