SpiecsEngine
 
Loading...
Searching...
No Matches
SlateImage.cpp
Go to the documentation of this file.
1/**
2* @file SlateImage.cpp.
3* @brief The SlateImage Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
8#include "SlateImage.h"
9#include "Render/Vulkan/VulkanRenderBackend.h"
10#include "Resources/Material/Material.h"
11#include "Resources/ResourcePool/ResourcePool.h"
12
13namespace Spices {
14
15 SlateImage::SlateImage(const std::string& textureName, const std::string& materialName)
16 : m_TextureName(textureName)
17 , m_MaterialName(materialName)
18 , m_TextureID(0)
19 , m_Material(nullptr)
20 {
22
25 }
26
28 {
30
31 /**
32 * @brief Free old Texture image DescriptorSet.
33 */
34 if (m_TextureID)
35 {
36 ImGui_ImplVulkan_RemoveTexture(reinterpret_cast<VkDescriptorSet>(m_TextureID));
37 m_TextureID = 0;
38 }
39
40 /**
41 * @brief Unload useless material.
42 */
43 if (m_Material)
44 {
45 ResourcePool<Material>::UnLoad(m_Material->GetName());
46 }
47 }
48
50 {
52
53 /**
54 * @brief Free old Texture image DescriptorSet.
55 */
56 if (m_TextureID)
57 {
58 ImGui_ImplVulkan_RemoveTexture(reinterpret_cast<VkDescriptorSet>(m_TextureID));
59 m_TextureID = 0;
60 }
61
62 /**
63 * @brief Get Texture Info.
64 */
65 VkDescriptorImageInfo* info = VulkanRenderBackend::GetRendererResourcePool()->AccessResource({ m_TextureName });
66
67 /**
68 * @brief Create Texture DescriptorSet.
69 */
70 m_TextureID = reinterpret_cast<ImTextureID>(ImGui_ImplVulkan_AddTexture(info->sampler, info->imageView, info->imageLayout));
71 }
72
74 {
76
77 /**
78 * @brief Unload useless material.
79 */
80 if (m_Material)
81 {
82 ResourcePool<Material>::UnLoad(m_Material->GetName());
83 }
84
85 /**
86 * @brief Load material.
87 */
88 m_Material = ResourcePool<Material>::Load<Material>(m_MaterialName, m_MaterialName);
89 m_Material->BuildMaterial();
90 }
91}
#define SPICES_PROFILE_ZONE
SlateImage(const std::string &textureName, const std::string &materialName)
Constructor Function.
void ReBuildMaterial()
Rebuild this Material.
virtual ~SlateImage()
Destructor Function.
std::string m_TextureName
Texture name.
Definition SlateImage.h:70
void ReBuildTextureID()
Rebuild this ImTextureID.
std::string m_MaterialName
Material name.
Definition SlateImage.h:75
Slate image draw context.
Definition SlateImage.h:18