Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
foray::stages::ImguiStage Class Reference

The ImguiStage renders the imgui menu on top of an existing image or the swapchain. This image is passed via the backgroundImage. More...

#include <foray_imguistage.hpp>

Inheritance diagram for foray::stages::ImguiStage:
foray::stages::RenderStage

Public Member Functions

 ImguiStage ()=default
 
virtual void Init (core::Context *context, core::ManagedImage *backgroundImage)
 Initializes and selects background image mode if set, swapchain mode otherwise.
 
virtual void InitForImage (core::Context *context, core::ManagedImage *backgroundImage)
 Init the imgui stage for rendering over a generic background image.
 
virtual void InitForSwapchain (core::Context *context)
 Init the imgui stage for rendering to the swapchain.
 
virtual void RecordFrame (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo) override
 Records a frame to cmdBuffer.
 
virtual void Destroy () override
 Destroy the render stage. Finalizes all components.
 
virtual void SetBackgroundImage (core::ManagedImage *backgroundImage)
 Switch background image and between modes at runtime.
 
void AddWindowDraw (std::function< void()> windowDraw)
 Add a function that renders an imgui window. Example:
 
virtual void Resize (const VkExtent2D &extent) override
 When the window has been resized, update the target images.
 
void ProcessSdlEvent (const SDL_Event *sdlEvent)
 Allows imgui to handle input events.
 
virtual ~ImguiStage ()
 
- Public Member Functions inherited from foray::stages::RenderStage
 RenderStage ()=default
 
std::vector< core::ManagedImage * > GetImageOutputs ()
 Gets a vector to all color attachments that will be included in a texture array and can be referenced in the shader pass.
 
core::ManagedImageGetImageOutput (std::string_view name, bool noThrow=false)
 Gets an image output.
 
virtual void OnShadersRecompiled (const std::unordered_set< uint64_t > &recompiled)
 Notifies the stage that the shader compiler instance has recompiled a shader.
 
virtual ~RenderStage ()
 

Protected Member Functions

virtual void InitImgui ()
 
virtual void PrepareRenderpass ()
 
virtual void DestroyFrameBufferAndRenderPass ()
 
- Protected Member Functions inherited from foray::stages::RenderStage
virtual void ReloadShaders ()
 Override this to reload all shaders and rebuild pipelines after a registered shader has been recompiled.
 
virtual void DestroyOutputImages ()
 Calls Destroy() on any image in mImageOutputs and clears mImageOutputs.
 

Protected Attributes

VkClearValue mClearValue
 
core::ManagedImagemTargetImage = nullptr
 
VkDescriptorPool mImguiPool {}
 
std::vector< std::function< void()> > mWindowDraws
 
std::vector< VkFramebuffer > mFrameBuffers
 
VkRenderPass mRenderPass = nullptr
 
- Protected Attributes inherited from foray::stages::RenderStage
std::unordered_map< std::string, core::ManagedImage * > mImageOutputs
 Inheriting types should emplace their images onto this collection to provide them in GetImageOutput interface.
 
std::vector< uint64_t > mShaderKeys
 Inheriting types should emplace their shader keys onto this collection such that if a shader has been recompiled, ReloadShaders() will be called.
 
core::ContextmContext = nullptr
 Context object the renderstage is built upon.
 

Detailed Description

The ImguiStage renders the imgui menu on top of an existing image or the swapchain. This image is passed via the backgroundImage.

Constructor & Destructor Documentation

◆ ImguiStage()

foray::stages::ImguiStage::ImguiStage ( )
default

◆ ~ImguiStage()

virtual foray::stages::ImguiStage::~ImguiStage ( )
inlinevirtual

Member Function Documentation

◆ AddWindowDraw()

void foray::stages::ImguiStage::AddWindowDraw ( std::function< void()>  windowDraw)
inline

Add a function that renders an imgui window. Example:

◆ Destroy()

virtual void foray::stages::ImguiStage::Destroy ( )
overridevirtual

Destroy the render stage. Finalizes all components.

Reimplemented from foray::stages::RenderStage.

◆ DestroyFrameBufferAndRenderPass()

virtual void foray::stages::ImguiStage::DestroyFrameBufferAndRenderPass ( )
protectedvirtual

◆ Init()

virtual void foray::stages::ImguiStage::Init ( core::Context context,
core::ManagedImage backgroundImage 
)
virtual

Initializes and selects background image mode if set, swapchain mode otherwise.

Parameters
contextRequires Device (Swapchain & SwapchainImages if no background image is set)
backgroundImageManaged Image Background Image to render over. If set to nullptr, will use swapchain mode.

◆ InitForImage()

virtual void foray::stages::ImguiStage::InitForImage ( core::Context context,
core::ManagedImage backgroundImage 
)
virtual

Init the imgui stage for rendering over a generic background image.

Parameters
contextRequires Device
backgroundImageManaged Image Background Image to render over

◆ InitForSwapchain()

virtual void foray::stages::ImguiStage::InitForSwapchain ( core::Context context)
virtual

Init the imgui stage for rendering to the swapchain.

Parameters
contextRequires Device, Swapchain & SwapchainImages

◆ InitImgui()

virtual void foray::stages::ImguiStage::InitImgui ( )
protectedvirtual

◆ PrepareRenderpass()

virtual void foray::stages::ImguiStage::PrepareRenderpass ( )
protectedvirtual

◆ ProcessSdlEvent()

void foray::stages::ImguiStage::ProcessSdlEvent ( const SDL_Event *  sdlEvent)

Allows imgui to handle input events.

◆ RecordFrame()

virtual void foray::stages::ImguiStage::RecordFrame ( VkCommandBuffer  cmdBuffer,
base::FrameRenderInfo renderInfo 
)
overridevirtual

Records a frame to cmdBuffer.

Parameters
cmdBufferCommand buffer to record to
renderInfoAdditional information about the current frame being rendered

Inheriting

  • Any resources accessed (images, buffers) must be protected by pipeline barriers, unless the providing entity defines them as constants
  • All commands must be submitted to cmdBuffer

Reimplemented from foray::stages::RenderStage.

◆ Resize()

virtual void foray::stages::ImguiStage::Resize ( const VkExtent2D &  extent)
overridevirtual

When the window has been resized, update the target images.

Reimplemented from foray::stages::RenderStage.

◆ SetBackgroundImage()

virtual void foray::stages::ImguiStage::SetBackgroundImage ( core::ManagedImage backgroundImage)
virtual

Switch background image and between modes at runtime.

Parameters
backgroundImageManaged Image Background Image to render over. If set to nullptr, will use swapchain mode.

Member Data Documentation

◆ mClearValue

VkClearValue foray::stages::ImguiStage::mClearValue
protected

◆ mFrameBuffers

std::vector<VkFramebuffer> foray::stages::ImguiStage::mFrameBuffers
protected

◆ mImguiPool

VkDescriptorPool foray::stages::ImguiStage::mImguiPool {}
protected

◆ mRenderPass

VkRenderPass foray::stages::ImguiStage::mRenderPass = nullptr
protected

◆ mTargetImage

core::ManagedImage* foray::stages::ImguiStage::mTargetImage = nullptr
protected

◆ mWindowDraws

std::vector<std::function<void()> > foray::stages::ImguiStage::mWindowDraws
protected

The documentation for this class was generated from the following file: