Viewport.ixx File
Defines the Viewport class, which represents a rectangular area for rendering within a RenderTarget. More...
Included Headers
#include <cassert>
#include <format>
#include <memory>
#include <helios.scene.CameraSceneNode>
#include <helios.util.log.LogManager>
#include <helios.math.types>
#include <helios.util.log.Logger>
#include <helios.rendering.Viewport:RenderTargetFwd>
#include <helios.engine.core.data.ViewportId>
#include <helios.core.types>
#include <helios.rendering.ClearFlags>
#include <helios.rendering.ViewportSnapshot>
Namespaces Index
| namespace | helios |
| namespace | rendering |
|
Graphics rendering infrastructure. More... | |
Classes Index
| struct | ViewportKey |
|
A passkey used to establish a parent-child relationship between a RenderTarget and a Viewport. More... | |
| class | Viewport |
|
Represents a rectangular area within a RenderTarget where a scene is rendered. More... | |
Macro Definitions Index
| #define | HELIOS_LOG_SCOPE "helios::rendering::Viewport" |
Description
Defines the Viewport class, which represents a rectangular area for rendering within a RenderTarget.
Macro Definitions
HELIOS_LOG_SCOPE
|
Definition at line 26 of file Viewport.ixx.
26#define HELIOS_LOG_SCOPE "helios::rendering::Viewport"
File Listing
The file content with the documentation metadata removed is:
4 * @brief Defines the Viewport class, which represents a rectangular area for rendering within a RenderTarget.
26#define HELIOS_LOG_SCOPE "helios::rendering::Viewport"
27export namespace helios::rendering {
33 * @brief A passkey used to establish a parent-child relationship between a RenderTarget and a Viewport.
42 struct ViewportKey {
44 friend class helios::rendering::RenderTarget;
51 * A Viewport defines the 2D rectangle into which a 3D scene is projected. Its dimensions are specified
52 * in normalized coordinates relative to its parent `RenderTarget`. It is associated with a `CameraSceneNode`,
53 * which provides the view and projection matrices. The viewport automatically updates the CameraSceneNode
56 * Since a Viewport only stores normalized values for its location and dimensions relative to the owning RenderTarget,
65 inline static const helios::util::log::Logger& logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE);
71 const helios::rendering::RenderTarget* renderTarget_ = nullptr;
78 int clearFlags_ = std::to_underlying(ClearFlags::Color);
83 helios::math::vec4f clearColor_ = helios::math::vec4f(0.0f, 0.0f, 0.0f, 1.0f);
106 helios::math::vec2ui renderTargetSize_{};
111 helios::scene::CameraSceneNode* cameraSceneNode_ = nullptr;
121 mutable helios::math::vec4f bounds_;
135 const helios::engine::core::data::ViewportId viewportId_{helios::core::types::no_init};
140 mutable helios::math::vec4f absoluteBounds_{};
171 mutable ViewportSnapshot snapshot_{};
174 * @brief Updates this Viewport's CameraSceneNode and its associated Camera based on the dimension of the RenderTarget.
186 logger_.warn("updateCamera: Viewport was not configured with a CameraSceneNode, nothing to do here.");
198 * @brief Constructs a Viewport with normalized bounds set to (0.0f, 0.0f, 1.0f, 1.0f) and z-index 0
215 const helios::engine::core::data::ViewportId viewportId = helios::engine::core::data::ViewportId{helios::core::types::no_init},
219 viewportId_(viewportId),
221 setBounds(x, y, width, height);
231 [[nodiscard]] const helios::rendering::RenderTarget* renderTarget() const noexcept {
240 [[nodiscard]] helios::engine::core::data::ViewportId viewportId() const noexcept {
257 cameraSceneNode_ = cameraSceneNode;
266 [[nodiscard]] const helios::scene::CameraSceneNode* cameraSceneNode() const noexcept {
285 Viewport& setRenderTarget(const helios::rendering::RenderTarget* renderTarget, ViewportKey key) noexcept {
286 renderTarget_ = renderTarget;
295 [[nodiscard]] const helios::math::vec4f& bounds() const noexcept {
305 [[nodiscard]] const helios::math::vec4f& absoluteBounds() const noexcept {
319 [[nodiscard]] ViewportSnapshot snapshot() const noexcept {
346 assert((height_ >= 0.0f && height_ <= 1.0f) && "setBounds received unexpected value for height");
354 [[nodiscard]] int clearFlags() const noexcept {
363 [[nodiscard]] const helios::math::vec4f& clearColor() const noexcept {
374 Viewport& setClearFlags(int clearFlags) noexcept {
375 clearFlags_ = clearFlags;
388 Viewport& setClearColor(const helios::math::vec4f& color) noexcept {
417 void onRenderTargetResize(const unsigned int width, const unsigned int height) noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.