Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_imguistage.hpp
Go to the documentation of this file.
1#pragma once
3#include <functional>
4#include <sdl2/SDL.h>
5
6namespace foray::stages {
8 class ImguiStage : public RenderStage
9 {
10 public:
11 ImguiStage() = default;
12
16 virtual void Init(core::Context* context, core::ManagedImage* backgroundImage);
20 virtual void InitForImage(core::Context* context, core::ManagedImage* backgroundImage);
23 virtual void InitForSwapchain(core::Context* context);
24 virtual void RecordFrame(VkCommandBuffer cmdBuffer, base::FrameRenderInfo& renderInfo) override;
25 virtual void Destroy() override;
26
29 virtual void SetBackgroundImage(core::ManagedImage* backgroundImage);
30
32 void AddWindowDraw(std::function<void()> windowDraw) { mWindowDraws.push_back(windowDraw); }
33
35 virtual void Resize(const VkExtent2D& extent) override;
36
38 void ProcessSdlEvent(const SDL_Event* sdlEvent);
39
40 inline virtual ~ImguiStage() { Destroy(); }
41
42 protected:
43 VkClearValue mClearValue;
44
46 VkDescriptorPool mImguiPool{};
47 std::vector<std::function<void()>> mWindowDraws;
48
49 virtual void InitImgui();
50 virtual void PrepareRenderpass();
52
53
54 std::vector<VkFramebuffer> mFrameBuffers;
55 VkRenderPass mRenderPass = nullptr;
56 };
57} // namespace foray::stages
Context used for render processes. This object is rebuilt for every frame. /.
Definition foray_framerenderinfo.hpp:14
Wraps allocation and lifetime functionality of VkImage.
Definition foray_managedimage.hpp:13
The ImguiStage renders the imgui menu on top of an existing image or the swapchain....
Definition foray_imguistage.hpp:9
core::ManagedImage * mTargetImage
Definition foray_imguistage.hpp:45
VkDescriptorPool mImguiPool
Definition foray_imguistage.hpp:46
virtual void RecordFrame(VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo) override
Records a frame to cmdBuffer.
void AddWindowDraw(std::function< void()> windowDraw)
Add a function that renders an imgui window. Example:
Definition foray_imguistage.hpp:32
virtual void InitForImage(core::Context *context, core::ManagedImage *backgroundImage)
Init the imgui stage for rendering over a generic background image.
virtual ~ImguiStage()
Definition foray_imguistage.hpp:40
virtual void Init(core::Context *context, core::ManagedImage *backgroundImage)
Initializes and selects background image mode if set, swapchain mode otherwise.
virtual void Resize(const VkExtent2D &extent) override
When the window has been resized, update the target images.
virtual void InitForSwapchain(core::Context *context)
Init the imgui stage for rendering to the swapchain.
std::vector< VkFramebuffer > mFrameBuffers
Definition foray_imguistage.hpp:54
virtual void SetBackgroundImage(core::ManagedImage *backgroundImage)
Switch background image and between modes at runtime.
std::vector< std::function< void()> > mWindowDraws
Definition foray_imguistage.hpp:47
virtual void PrepareRenderpass()
VkRenderPass mRenderPass
Definition foray_imguistage.hpp:55
virtual void InitImgui()
void ProcessSdlEvent(const SDL_Event *sdlEvent)
Allows imgui to handle input events.
virtual void Destroy() override
Destroy the render stage. Finalizes all components.
VkClearValue mClearValue
Definition foray_imguistage.hpp:43
virtual void DestroyFrameBufferAndRenderPass()
Render stage base class giving a common interface for rendering processes.
Definition foray_renderstage.hpp:15
Definition foray_blitstage.hpp:4
Non owning context object.
Definition foray_context.hpp:16