Add imgui
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <destrum/Graphics/GfxDevice.h>
|
||||
#include <destrum/Graphics/Renderer.h>
|
||||
#include <destrum/Graphics/Pipelines/ImguiPass.h>
|
||||
|
||||
#include <destrum/Input/InputManager.h>
|
||||
|
||||
|
||||
@@ -40,6 +42,7 @@ protected:
|
||||
AppParams m_params{};
|
||||
|
||||
GfxDevice gfxDevice;
|
||||
ImguiPass imguiPass;
|
||||
|
||||
Camera camera{glm::vec3(0.f, 0.f, -5.f), glm::vec3(0, 1, 0)};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "Util.h"
|
||||
|
||||
class MeshCache;
|
||||
class ImguiPass;
|
||||
|
||||
|
||||
namespace {
|
||||
using ImmediateExecuteFunction = std::function<void(VkCommandBuffer)>;
|
||||
@@ -54,6 +56,7 @@ public:
|
||||
struct EndFrameProps {
|
||||
const VkClearColorValue clearColor{{0.f, 0.f, 0.f, 1.f}};
|
||||
glm::ivec4 drawImageBlitRect{}; // where to blit draw image to
|
||||
ImguiPass* imguiPass = nullptr;
|
||||
};
|
||||
|
||||
void endFrame(VkCommandBuffer cmd, const GPUImage& drawImage, const EndFrameProps& props);
|
||||
@@ -110,6 +113,19 @@ public:
|
||||
|
||||
[[nodiscard]] ImageID getWhiteTextureID() const { return whiteImageId; }
|
||||
|
||||
VkInstance getVkInstance() const { return instance; }
|
||||
VkPhysicalDevice getVkPhysicalDevice() const { return physicalDevice; }
|
||||
VkDevice getVkDevice() const { return device; }
|
||||
|
||||
std::uint32_t getGraphicsQueueFamily() const { return graphicsQueueFamily; }
|
||||
VkQueue getGraphicsQueue() const { return graphicsQueue; }
|
||||
|
||||
VkFormat getSwapchainFormat() const { return swapchainFormat; }
|
||||
std::uint32_t getSwapchainImageCount() const { return swapchain.getImageCount(); }
|
||||
VkImageView getSwapchainImageView(std::uint32_t imageIndex) const {
|
||||
return swapchain.getImageView(imageIndex);
|
||||
}
|
||||
|
||||
private:
|
||||
vkb::Instance instance;
|
||||
vkb::PhysicalDevice physicalDevice;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef DESTRUM_IMGUI_PASS_H
|
||||
#define DESTRUM_IMGUI_PASS_H
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <SDL.h>
|
||||
|
||||
class GfxDevice;
|
||||
|
||||
class ImguiPass {
|
||||
public:
|
||||
ImguiPass() = default;
|
||||
ImguiPass(const ImguiPass&) = delete;
|
||||
ImguiPass& operator=(const ImguiPass&) = delete;
|
||||
|
||||
void init(SDL_Window* window, GfxDevice& gfxDevice);
|
||||
void handleEvent(const SDL_Event& event);
|
||||
|
||||
void beginFrame();
|
||||
void endFrame();
|
||||
|
||||
void render(
|
||||
VkCommandBuffer cmd,
|
||||
VkImage targetImage,
|
||||
VkImageView targetImageView,
|
||||
VkImageLayout& targetImageLayout,
|
||||
VkExtent2D targetExtent
|
||||
);
|
||||
|
||||
void onSwapchainRecreated();
|
||||
void cleanup();
|
||||
|
||||
[[nodiscard]] bool isInitialized() const { return initialized; }
|
||||
[[nodiscard]] bool wantsMouse() const;
|
||||
[[nodiscard]] bool wantsKeyboard() const;
|
||||
|
||||
private:
|
||||
void transitionToColorAttachment(
|
||||
VkCommandBuffer cmd,
|
||||
VkImage image,
|
||||
VkImageLayout oldLayout,
|
||||
VkImageLayout newLayout
|
||||
) const;
|
||||
|
||||
private:
|
||||
GfxDevice* gfx = nullptr;
|
||||
SDL_Window* sdlWindow = nullptr;
|
||||
|
||||
VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
|
||||
VkFormat colorFormat = VK_FORMAT_UNDEFINED;
|
||||
|
||||
bool initialized = false;
|
||||
bool frameBegun = false;
|
||||
};
|
||||
|
||||
#endif // DESTRUM_IMGUI_PASS_H
|
||||
@@ -35,6 +35,11 @@ public:
|
||||
|
||||
[[nodiscard]] VkImageView getImageView(int index) const { return imageViews[index]; }
|
||||
|
||||
|
||||
VkImageView getImageView(std::uint32_t imageIndex) const {
|
||||
return imageViews.at(imageIndex);
|
||||
}
|
||||
|
||||
private:
|
||||
struct FrameData {
|
||||
VkSemaphore swapchainSemaphore;
|
||||
|
||||
Reference in New Issue
Block a user