ImGUI is now gone.
This commit is contained in:
parent
196b3098e8
commit
c821ab52a1
4 changed files with 1 additions and 112 deletions
|
|
@ -118,7 +118,7 @@ dependencies += [
|
||||||
vma,
|
vma,
|
||||||
vkbootstrap,
|
vkbootstrap,
|
||||||
glm,
|
glm,
|
||||||
imgui,
|
# imgui,
|
||||||
sdl2,
|
sdl2,
|
||||||
fastgltf,
|
fastgltf,
|
||||||
simdjson,
|
simdjson,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ void VulkanEngine::init()
|
||||||
init_sync_structures();
|
init_sync_structures();
|
||||||
init_descriptors();
|
init_descriptors();
|
||||||
init_pipelines();
|
init_pipelines();
|
||||||
_gui.init_imgui(VulkanEngine::Get());
|
|
||||||
init_default_data();
|
init_default_data();
|
||||||
|
|
||||||
//everything went fine
|
//everything went fine
|
||||||
|
|
@ -169,9 +168,6 @@ void VulkanEngine::draw()
|
||||||
// ZED: ?
|
// ZED: ?
|
||||||
vkutil::transition_image(t.cmd, _swapchainImages[t.swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
vkutil::transition_image(t.cmd, _swapchainImages[t.swapchainImageIndex], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
// ZED: end drawing the things
|
|
||||||
_gui.draw_imgui(_swapchainExtent, t.cmd, _swapchainImageViews[t.swapchainImageIndex]);
|
|
||||||
|
|
||||||
// ZED: finalize image and commit command buffer
|
// ZED: finalize image and commit command buffer
|
||||||
vkutil::transition_image(t.cmd, _swapchainImages[t.swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
|
vkutil::transition_image(t.cmd, _swapchainImages[t.swapchainImageIndex], VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
|
||||||
|
|
||||||
|
|
@ -260,7 +256,6 @@ void VulkanEngine::run()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gui.render_imgui(backgroundEffects, ¤tBackgroundEffect);
|
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
103
vk_gui.cpp
103
vk_gui.cpp
|
|
@ -2,9 +2,6 @@
|
||||||
#include "vk_initializers.h"
|
#include "vk_initializers.h"
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_vulkan.h>
|
#include <SDL_vulkan.h>
|
||||||
#include <imgui.h>
|
|
||||||
#include <imgui_impl_sdl2.h>
|
|
||||||
#include <imgui_impl_vulkan.h>
|
|
||||||
#include "vk_engine.h"
|
#include "vk_engine.h"
|
||||||
|
|
||||||
struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent)
|
struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent)
|
||||||
|
|
@ -22,104 +19,6 @@ struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent)
|
||||||
window_flags);
|
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)
|
void VkGUI::destroy(struct SDL_Window* _window)
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +44,5 @@ void VkGUI::poll_event() {
|
||||||
stop_rendering = false;
|
stop_rendering = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplSDL2_ProcessEvent(&event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
vk_gui.h
3
vk_gui.h
|
|
@ -9,9 +9,6 @@ class VkGUI {
|
||||||
bool stop_rendering = false;
|
bool stop_rendering = false;
|
||||||
|
|
||||||
struct SDL_Window* init_window(VkExtent2D windowExtent);
|
struct SDL_Window* init_window(VkExtent2D windowExtent);
|
||||||
void init_imgui(VulkanEngine& engine);
|
|
||||||
void draw_imgui(VkExtent2D& swapchainExtent, VkCommandBuffer cmd, VkImageView targetImageView);
|
|
||||||
void render_imgui(std::vector<ComputeEffect>& backgroundEffects, int* currentBackgroundEffect);
|
|
||||||
void destroy(struct SDL_Window* _window);
|
void destroy(struct SDL_Window* _window);
|
||||||
|
|
||||||
void poll_event();
|
void poll_event();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue