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 =
""
59 const vk::raii::Device& device,
60 const vk::ImageCreateInfo& imageInfo,
62 const std::string& name =
""
67 ImTextureID GetTexture()
70 vk::ImageView GetView()
76 void SetName(
const std::string& name);
79 void LayoutTransition(
80 vk::raii::CommandBuffer& cmdBuf,
90 std::unique_ptr<vk::raii::ImageView>
m_view;
92 ImTextureID m_texture;
108 const std::string& name,
109 const std::string& path);
111 ImTextureID GetTexture(
const std::string& name)
113 auto it = m_textures.find(name);
114 if(it == m_textures.end())
117 "Texture \"%s\" not found. This is probably the result of a developer mistyping a texture ID.\n",
121 return it->second->GetTexture();
124 std::unique_ptr<vk::raii::Sampler>& GetSampler()
128 { m_textures.clear(); }
130 vk::raii::CommandBuffer& GetCmdBuffer()
131 {
return *m_cmdBuf; }
133 std::shared_ptr<QueueHandle> GetQueue()
136 vk::ImageView GetView(
const std::string& name)
137 {
return m_textures[name]->GetView(); }
140 std::map<std::string, std::shared_ptr<Texture> > m_textures;
145 std::shared_ptr<QueueHandle> m_queue;
146 std::unique_ptr<vk::raii::CommandPool> m_cmdPool;
147 std::unique_ptr<vk::raii::CommandBuffer> m_cmdBuf;
Manages loading and saving texture resources to files.
Definition: TextureManager.h:102
std::unique_ptr< vk::raii::Sampler > m_sampler
Sampler for textures.
Definition: TextureManager.h:143
void LoadTexture(const std::string &name, const std::string &path)
Loads a texture from a file into a named resource.
Definition: TextureManager.cpp:323
Encapsulates the various Vulkan objects we need to represent texture image memory.
Definition: TextureManager.h:46
std::unique_ptr< vk::raii::ImageView > m_view
View of the image.
Definition: TextureManager.h:90
std::unique_ptr< vk::raii::DeviceMemory > m_deviceMemory
Device memory backing the image.
Definition: TextureManager.h:95
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="")
Creates a texture from an externally supplied staging buffer.
Definition: TextureManager.cpp:48
vk::raii::Image m_image
Image object for our texture.
Definition: TextureManager.h:87