diff --git a/xo-imgui/include/xo/imgui/VulkanApp.hpp b/xo-imgui/include/xo/imgui/VulkanApp.hpp index 73097ce6..1fa56ca4 100644 --- a/xo-imgui/include/xo/imgui/VulkanApp.hpp +++ b/xo-imgui/include/xo/imgui/VulkanApp.hpp @@ -2,13 +2,20 @@ #pragma once -#include #include +#include +#include //#include #include +#include class VulkanApp { public: + using ImguiDrawFn = std::function; + +public: + VulkanApp() = default; + void run(); private: @@ -39,6 +46,7 @@ private: private: SDL_Window* window = nullptr; + ImGuiContext* imgui_cx_ = nullptr; VkInstance instance; VkPhysicalDevice physical_device_; VkDevice device_; diff --git a/xo-imgui/src/imgui/VulkanApp.cpp b/xo-imgui/src/imgui/VulkanApp.cpp index 1dcfb6bd..c3c40f07 100644 --- a/xo-imgui/src/imgui/VulkanApp.cpp +++ b/xo-imgui/src/imgui/VulkanApp.cpp @@ -2,7 +2,6 @@ #include "VulkanApp.hpp" #include -#include #include #include #include @@ -419,7 +418,8 @@ VulkanApp::init_imgui() { // Setup Dear ImGui context IMGUI_CHECKVERSION(); - ImGui::CreateContext(); + this->imgui_cx_ = ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; // Setup Dear ImGui style @@ -564,33 +564,33 @@ VulkanApp::draw_frame() vkQueuePresentKHR(graphics_queue_, &presentInfo); - current_frame_ = (current_frame_ + 1) % c_max_frames_in_flight; + this->current_frame_ = (current_frame_ + 1) % c_max_frames_in_flight; } /*draw_frame*/ void VulkanApp::record_command_buffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { - VkCommandBufferBeginInfo beginInfo{}; - beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + VkCommandBufferBeginInfo begin_info{}; + begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - if (vkBeginCommandBuffer(commandBuffer, &beginInfo) != VK_SUCCESS) { + if (vkBeginCommandBuffer(commandBuffer, &begin_info) != VK_SUCCESS) { throw std::runtime_error("Failed to begin recording command buffer!"); } - VkRenderPassBeginInfo renderPassInfo{}; - renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - renderPassInfo.renderPass = render_pass_; - renderPassInfo.framebuffer = framebuffers_[imageIndex]; - renderPassInfo.renderArea.offset = {0, 0}; - renderPassInfo.renderArea.extent = swapchain_extent_; + VkRenderPassBeginInfo render_pass_info{}; + render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; + render_pass_info.renderPass = render_pass_; + render_pass_info.framebuffer = framebuffers_[imageIndex]; + render_pass_info.renderArea.offset = {0, 0}; + render_pass_info.renderArea.extent = swapchain_extent_; - VkClearValue clearColor = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; - renderPassInfo.clearValueCount = 1; - renderPassInfo.pClearValues = &clearColor; + VkClearValue clear_color = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; + render_pass_info.clearValueCount = 1; + render_pass_info.pClearValues = &clear_color; vkCmdBeginRenderPass(commandBuffer, - &renderPassInfo, + &render_pass_info, VK_SUBPASS_CONTENTS_INLINE); // Start the Dear ImGui frame