RenderTarget Class
Represents a destination for rendering operations, such as a window's framebuffer. More...
Declaration
Public Constructors Index
| RenderTarget ()=default | |
|
Default constructor. More... | |
| RenderTarget (std::shared_ptr< helios::rendering::Viewport > viewport, unsigned int width=0, unsigned int height=0) | |
|
Constructs a RenderTarget with an initial viewport and dimensions. More... | |
Public Member Functions Index
| std::shared_ptr< helios::rendering::Viewport > | addViewport (std::shared_ptr< helios::rendering::Viewport > viewport) |
|
Adds a viewport to this render target and establishes a parent-child relationship. More... | |
| std::span< const std::shared_ptr< helios::rendering::Viewport > > | viewports () noexcept |
|
Returns a read-only view of all viewports owned by this RenderTarget. More... | |
| void | setSize (unsigned int width, unsigned int height) noexcept |
|
Resizes this RenderTarget to the specified dimensions and propagates the change to every viewport. More... | |
| unsigned int | width () const noexcept |
|
Gets the width of the render target. More... | |
| unsigned int | height () const noexcept |
|
Gets the height of the render target. More... | |
Private Member Attributes Index
| unsigned int | width_ = 0 |
|
The width of the render target in pixels. More... | |
| unsigned int | height_ = 0 |
|
The height of the render target in pixels. More... | |
| helios::rendering::ViewportKey | viewportKey_ {} |
|
Passkey instance to authorize `Viewport::setRenderTarget`. More... | |
| std::vector< std::shared_ptr< helios::rendering::Viewport > > | viewports_ |
|
A list of viewports owned by this render target. More... | |
Description
Represents a destination for rendering operations, such as a window's framebuffer.
A RenderTarget encapsulates a buffer (e.g., the default framebuffer or an off-screen texture) into which a scene can be rendered. It manages one or more `Viewport` objects, which define specific rectangular areas within the target.
When the RenderTarget is resized, it notifies all its associated viewports so they can update their states accordingly (e.g., camera aspect ratio).
- Todo
-
This implementation currently represents only the **default framebuffer**. Future extensions should allow it to represent arbitrary framebuffer objects (FBOs), using indices.
- See Also
glGenFramebuffers
Definition at line 33 of file RenderTarget.ixx.
Public Constructors
RenderTarget()
| default |
Default constructor.
Definition at line 61 of file RenderTarget.ixx.
RenderTarget()
| inline explicit |
Constructs a RenderTarget with an initial viewport and dimensions.
- Parameters
-
viewport The default viewport for this RenderTarget. The viewport defines the rectangular area where the image is drawn.
width The initial width of the render target in pixels.
height The initial height of the render target in pixels.
- Exceptions
-
std::invalid_argument if viewport is a nullptr.
- See Also
Definition at line 75 of file RenderTarget.ixx.
References addViewport, height and width.
Public Member Functions
addViewport()
| inline |
Adds a viewport to this render target and establishes a parent-child relationship.
Makes sure the viewport is informed about any possible bounds updates by calling onRenderTargetResize afterwards.
- Parameters
-
viewport A shared pointer to the `Viewport` to be added.
- Returns
The newly added viewport as a shared pointer.
- Exceptions
-
std::invalid_argument if viewport is a nullptr, or if the viewport already has a parent RenderTarget.
Definition at line 101 of file RenderTarget.ixx.
Referenced by RenderTarget.
height()
| inline nodiscard noexcept |
Gets the height of the render target.
- Returns
The height in pixels.
Definition at line 163 of file RenderTarget.ixx.
Referenced by helios::ext::opengl::rendering::OpenGLDevice::beginRenderPass, RenderTarget and setSize.
setSize()
| inline noexcept |
Resizes this RenderTarget to the specified dimensions and propagates the change to every viewport.
- Parameters
-
width The new width of the render target in pixels.
height The new height of the render target in pixels.
- Todo
-
A LayoutManager could be introduced to manage the arrangement of multiple viewports.
Definition at line 140 of file RenderTarget.ixx.
viewports()
| inline nodiscard noexcept |
Returns a read-only view of all viewports owned by this RenderTarget.
- Returns
A span of shared pointers to the viewports.
Definition at line 126 of file RenderTarget.ixx.
width()
| inline nodiscard noexcept |
Gets the width of the render target.
- Returns
The width in pixels.
Definition at line 154 of file RenderTarget.ixx.
Referenced by helios::ext::opengl::rendering::OpenGLDevice::beginRenderPass, RenderTarget and setSize.
Private Member Attributes
height_
|
The height of the render target in pixels.
Definition at line 43 of file RenderTarget.ixx.
viewportKey_
|
Passkey instance to authorize `Viewport::setRenderTarget`.
Definition at line 48 of file RenderTarget.ixx.
viewports_
|
A list of viewports owned by this render target.
- Todo
-
The list should be sorted after a meaningful key, like the viewport's z-Index.
Definition at line 55 of file RenderTarget.ixx.
width_
|
The width of the render target in pixels.
Definition at line 38 of file RenderTarget.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.