35#ifndef TextureManager_h
36#define TextureManager_h
49 const vk::raii::Device& device,
50 const vk::ImageCreateInfo& imageInfo,
51 const vk::raii::Buffer& srcBuf,
55 const std::string& name =
"",
56 bool upsampleLinear =
true
60 const vk::raii::Device& device,
61 const vk::ImageCreateInfo& imageInfo,
63 const std::string& name =
""
68 ImTextureID GetTexture()
71 vk::ImageView GetView()
77 void SetName(
const std::string& name);
80 void LayoutTransition(
81 vk::raii::CommandBuffer& cmdBuf,
91 std::unique_ptr<vk::raii::ImageView>
m_view;
93 ImTextureID m_texture;
109 const std::string& name,
110 const std::string& path);
112 ImTextureID GetTexture(
const std::string& name)
114 auto it = m_textures.find(name);
115 if(it == m_textures.end())
118 "Texture \"%s\" not found. This is probably the result of a developer mistyping a texture ID.\n",
122 return it->second->GetTexture();
125 std::unique_ptr<vk::raii::Sampler>& GetSampler()
128 std::unique_ptr<vk::raii::Sampler>& GetNearestSampler()
129 {
return m_nearestSampler; }
132 { m_textures.clear(); }
134 vk::raii::CommandBuffer& GetCmdBuffer()
135 {
return *m_cmdBuf; }
137 std::shared_ptr<QueueHandle> GetQueue()
140 vk::ImageView GetView(
const std::string& name)
141 {
return m_textures[name]->GetView(); }
144 std::map<std::string, std::shared_ptr<Texture> > m_textures;
149 std::unique_ptr<vk::raii::Sampler> m_nearestSampler;
151 std::shared_ptr<QueueHandle> m_queue;
152 std::unique_ptr<vk::raii::CommandPool> m_cmdPool;
153 std::unique_ptr<vk::raii::CommandBuffer> m_cmdBuf;
Manages loading and saving texture resources to files.
Definition: TextureManager.h:103
std::unique_ptr< vk::raii::Sampler > m_sampler
Sampler for textures.
Definition: TextureManager.h:147
void LoadTexture(const std::string &name, const std::string &path)
Loads a texture from a file into a named resource.
Definition: TextureManager.cpp:346
Encapsulates the various Vulkan objects we need to represent texture image memory.
Definition: TextureManager.h:46
Texture(const vk::raii::Device &device, const vk::ImageCreateInfo &imageInfo, const vk::raii::Buffer &srcBuf, int width, int height, TextureManager *mgr, const std::string &name="", bool upsampleLinear=true)
Creates a texture from an externally supplied staging buffer.
Definition: TextureManager.cpp:48
std::unique_ptr< vk::raii::ImageView > m_view
View of the image.
Definition: TextureManager.h:91
std::unique_ptr< vk::raii::DeviceMemory > m_deviceMemory
Device memory backing the image.
Definition: TextureManager.h:96
vk::raii::Image m_image
Image object for our texture.
Definition: TextureManager.h:88