forked from Shell4026/ShellEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUITexture.cpp
More file actions
47 lines (40 loc) · 1.08 KB
/
Copy pathGUITexture.cpp
File metadata and controls
47 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "PCH.h"
#include "GUITexture.h"
#include "Render/Texture.h"
#include "Render/VulkanImpl/VulkanTextureBuffer.h"
namespace sh::game
{
SH_GAME_API GUITexture::GUITexture() :
tex(nullptr)
{
}
GUITexture::~GUITexture()
{
Clean();
}
SH_GAME_API void GUITexture::Create(const render::Renderer& renderer, const render::Texture& texture)
{
this->renderer = &renderer;
if (renderer.apiType == render::RenderAPI::Vulkan)
{
auto buffer = static_cast<render::vk::VulkanTextureBuffer*>(texture.GetBuffer())->GetImageBuffer();
tex = ImGui_ImplVulkan_AddTexture(buffer->GetSampler(), buffer->GetImageView(), VkImageLayout::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
}
SH_GAME_API void GUITexture::Clean()
{
if (tex == nullptr || renderer == nullptr)
return;
if (renderer->apiType == render::RenderAPI::Vulkan)
ImGui_ImplVulkan_RemoveTexture(reinterpret_cast<VkDescriptorSet>(tex));
tex = nullptr;
}
SH_GAME_API GUITexture::operator ImTextureID() const
{
return tex;
}
SH_GAME_API bool GUITexture::IsValid() const
{
return tex != nullptr;
}
}//namespace