ImGUI is now gone.
This commit is contained in:
parent
196b3098e8
commit
c821ab52a1
4 changed files with 1 additions and 112 deletions
103
vk_gui.cpp
103
vk_gui.cpp
|
|
@ -2,9 +2,6 @@
|
|||
#include "vk_initializers.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_sdl2.h>
|
||||
#include <imgui_impl_vulkan.h>
|
||||
#include "vk_engine.h"
|
||||
|
||||
struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent)
|
||||
|
|
@ -22,104 +19,6 @@ struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent)
|
|||
window_flags);
|
||||
}
|
||||
|
||||
void VkGUI::init_imgui(VulkanEngine& engine)
|
||||
{
|
||||
// 1. create descriptor pool for IMGUI
|
||||
// the size of the pool is very oversize, but it's copied from imgui demo
|
||||
// itself.
|
||||
VkDescriptorPoolSize pool_sizes[] = {
|
||||
{ VK_DESCRIPTOR_TYPE_SAMPLER, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 },
|
||||
{ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 }
|
||||
};
|
||||
|
||||
VkDescriptorPoolCreateInfo pool_info{
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||
.maxSets = 1000,
|
||||
.poolSizeCount = (uint32_t)std::size(pool_sizes),
|
||||
.pPoolSizes = pool_sizes,
|
||||
};
|
||||
|
||||
VkDescriptorPool imguiPool;
|
||||
VK_CHECK(vkCreateDescriptorPool(engine._device, &pool_info, nullptr, &imguiPool));
|
||||
|
||||
// 2: initialize the imgui library
|
||||
ImGui::CreateContext();
|
||||
|
||||
ImGui_ImplSDL2_InitForVulkan(engine._window);
|
||||
|
||||
ImGui_ImplVulkan_InitInfo init_info{
|
||||
.Instance = engine._instance,
|
||||
.PhysicalDevice = engine._chosenGPU,
|
||||
.Device = engine._device,
|
||||
.Queue = engine._graphicsQueue,
|
||||
.DescriptorPool = imguiPool,
|
||||
.MinImageCount = 3,
|
||||
.ImageCount = 3,
|
||||
.MSAASamples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.UseDynamicRendering = true,
|
||||
.PipelineRenderingCreateInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachmentFormats = &engine._swapchainImageFormat,
|
||||
},
|
||||
};
|
||||
|
||||
ImGui_ImplVulkan_Init(&init_info);
|
||||
ImGui_ImplVulkan_CreateFontsTexture();
|
||||
|
||||
engine._mainDeletionQueue.push_function([=,this]() {
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
vkDestroyDescriptorPool(engine._device, imguiPool, nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
void VkGUI::draw_imgui(VkExtent2D& swapchainExtent, VkCommandBuffer cmd, VkImageView targetImageView)
|
||||
{
|
||||
VkRenderingAttachmentInfo colorAttachment = vkinit::attachment_info(targetImageView, nullptr, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
|
||||
VkRenderingInfo renderInfo = vkinit::rendering_info(swapchainExtent, &colorAttachment, nullptr);
|
||||
|
||||
vkCmdBeginRendering(cmd, &renderInfo);
|
||||
|
||||
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmd);
|
||||
|
||||
vkCmdEndRendering(cmd);
|
||||
}
|
||||
|
||||
void VkGUI::render_imgui(std::vector<ComputeEffect>& backgroundEffects, int* currentBackgroundEffect)
|
||||
{
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
|
||||
ImGui::NewFrame();
|
||||
|
||||
if (ImGui::Begin("background")) {
|
||||
|
||||
ComputeEffect& selected = backgroundEffects[*currentBackgroundEffect];
|
||||
|
||||
ImGui::Text("Selected effect: %s", selected.name);
|
||||
|
||||
ImGui::SliderInt("Effect Index", currentBackgroundEffect,0, backgroundEffects.size() - 1);
|
||||
|
||||
ImGui::InputFloat4("data1",(float*)& selected.data.data1);
|
||||
ImGui::InputFloat4("data2",(float*)& selected.data.data2);
|
||||
ImGui::InputFloat4("data3",(float*)& selected.data.data3);
|
||||
ImGui::InputFloat4("data4",(float*)& selected.data.data4);
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Render();
|
||||
}
|
||||
|
||||
void VkGUI::destroy(struct SDL_Window* _window)
|
||||
{
|
||||
|
|
@ -145,7 +44,5 @@ void VkGUI::poll_event() {
|
|||
stop_rendering = false;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue