Added VkImages

This commit is contained in:
antopilo
2024-12-07 13:28:01 -05:00
parent 39a0273595
commit cd2e603733
4 changed files with 43 additions and 38 deletions

View File

@@ -232,14 +232,14 @@ namespace Nuake {
const float padY = (buttonHeight - (float)iconHeight) / 2.0f;
if (ImGui::InvisibleButton("Minimize", ImVec2(iconWidth, iconHeight)))
{
glfwIconifyWindow(Window::Get()->GetHandle());
}
auto rect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
UI::DrawButtonImage(MinimizeTexture, buttonColN, buttonColH, buttonColP);
//const float padY = (buttonHeight - (float)iconHeight) / 2.0f;
//if (ImGui::InvisibleButton("Minimize", ImVec2(iconWidth, iconHeight)))
//{
// glfwIconifyWindow(Window::Get()->GetHandle());
//}
//
//auto rect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
//UI::DrawButtonImage(MinimizeTexture, buttonColN, buttonColH, buttonColP);
}
ImGui::SameLine();
@@ -251,20 +251,20 @@ namespace Nuake {
const bool isMaximized = Window::Get()->IsMaximized();
if (ImGui::InvisibleButton("Maximize", ImVec2(buttonWidth, buttonHeight)))
{
const auto window = Window::Get()->GetHandle();
if (isMaximized)
{
glfwRestoreWindow(window);
}
else
{
glfwMaximizeWindow(window);
}
}
auto rect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
UI::DrawButtonImage(isMaximized ? RestoreTexture : MaximizeTexture, buttonColN, buttonColH, buttonColP);
//if (ImGui::InvisibleButton("Maximize", ImVec2(buttonWidth, buttonHeight)))
//{
// const auto window = Window::Get()->GetHandle();
// if (isMaximized)
// {
// glfwRestoreWindow(window);
// }
// else
// {
// glfwMaximizeWindow(window);
// }
//}
//auto rect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
//UI::DrawButtonImage(isMaximized ? RestoreTexture : MaximizeTexture, buttonColN, buttonColH, buttonColP);
}
// Close Button
@@ -272,12 +272,12 @@ namespace Nuake {
{
int iconWidth = std::max(CloseIconTexture ->GetWidth(), 24);
int iconHeight = std::max(CloseIconTexture->GetHeight(), 24);
if (ImGui::InvisibleButton("Close", ImVec2(buttonWidth, buttonHeight)))
{
glfwSetWindowShouldClose(Window::Get()->GetHandle(), true);
}
UI::DrawButtonImage(CloseIconTexture, UI::TextCol, UI::TextCol, buttonColP);
//if (ImGui::InvisibleButton("Close", ImVec2(buttonWidth, buttonHeight)))
//{
// glfwSetWindowShouldClose(Window::Get()->GetHandle(), true);
//}
//
//UI::DrawButtonImage(CloseIconTexture, UI::TextCol, UI::TextCol, buttonColP);
}
// Second bar with play stop pause etc
@@ -655,7 +655,6 @@ namespace Nuake {
Input::SetEditorViewportSize(m_ViewportPos, viewportPanelSize);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
m_ViewportPos = { imagePos.x, imagePos.y };
ImGui::Text("pointer = %p", VkRenderer::Get().GetDrawImage()->GetImGuiDescriptorSet());
ImGui::Image(VkRenderer::Get().GetDrawImage()->GetImGuiDescriptorSet(), regionAvail);
ImGui::PopStyleVar();

View File

@@ -42,6 +42,12 @@ VulkanImage::VulkanImage(ImageFormat inFormat, Vector2 inSize) :
VK_CALL(vkCreateImageView(VkRenderer::Get().GetDevice(), &imageViewCreateInfo, nullptr, &ImageView));
}
VulkanImage::VulkanImage(void* inData, ImageFormat inFormat, Vector2 inSize)
{
size_t data_size = inSize.x * inSize.y * 4;
}
VkDescriptorSet& VulkanImage::GetImGuiDescriptorSet()
{
if (!ImGuiDescriptorSetGenerated)

View File

@@ -41,6 +41,7 @@ namespace Nuake
public:
VulkanImage(ImageFormat format, Vector2 size);
VulkanImage(void* data, ImageFormat format, Vector2 size);
~VulkanImage() = default;
Vector2 GetSize() const { return Vector2(Extent.x, Extent.y); }

View File

@@ -21,7 +21,7 @@
using namespace Nuake;
bool NKUseValidationLayer = false;
bool NKUseValidationLayer = true;
VkRenderer::~VkRenderer()
{
@@ -528,6 +528,7 @@ void VkRenderer::Draw()
return;
}
VK_CALL(vkResetFences(Device, 1, &GetCurrentFrame().RenderFence));
// Note: this will be the meat of the engine that should be here.
@@ -557,18 +558,19 @@ void VkRenderer::Draw()
//VulkanUtil::TransitionImage(cmd, DrawImage->GetImage(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
// Execute a copy from the rendering image into the swapchain
//VulkanUtil::CopyImageToImage(cmd, DrawImage->GetImage(), SwapchainImages[swapchainImageIndex], DrawExtent, SwapchainExtent);
VulkanUtil::TransitionImage(cmd, DrawImage->GetImage(), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
{
}
//draw imgui into the swapchain image
DrawImgui(cmd, SwapchainImageViews[swapchainImageIndex]);
// set swapchain image layout to Attachment Optimal so we can draw it
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
// set swapchain image layout to Present so we can draw it
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
// Transition the swapchain image to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR for presentation
VulkanUtil::TransitionImage(cmd, SwapchainImages[swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
@@ -659,9 +661,6 @@ void VkRenderer::ImmediateSubmit(std::function<void(VkCommandBuffer cmd)>&& func
VK_CALL(vkWaitForFences(Device, 1, &ImguiFence, true, 9999999999));
}
void DescriptorLayoutBuilder::AddBinding(uint32_t binding, VkDescriptorType type)
{
VkDescriptorSetLayoutBinding newbind{};