Class Viewport

Inheritance Relationships

Base Type

Class Documentation

class Viewport : public portal::Panel

Editor viewport that renders the scene to a separate render target displayed in ImGui.

The Viewport class renders the scene to its own RenderTarget instead of directly to the swapchain. This rendered image is then displayed as an ImGui::Image within a “Viewport” window.

Public Functions

Viewport(const renderer::vulkan::VulkanSwapchain &swapchain, RuntimeModule &runtime_module)

Constructs a Viewport with initial dimensions from the swapchain.

Parameters:
  • swapchain – Used to determine initial viewport size and color format.

  • runtime_module – The runtime module that handles scene rendering.

~Viewport() override
virtual void on_gui_render(EditorContext &editor_context, FrameContext &frame, bool &is_open) override

Renders the viewport image in an ImGui window.

Handles viewport resizing when the ImGui window size changes, recreating the render target and updating the descriptor set as needed.

Parameters:
  • editor_context – The editor context containing viewport settings.

  • frame – The current frame context.

void render(FrameContext &frame) const

Renders the scene to the viewport’s render target.

Parameters:

frame – The current frame context.

inline bool focused() const
void set_gizmo_type(int type)