Skip to main content

RenderPrototype Class

An immutable, shared prototype of a renderable object. More...

Declaration

class helios::rendering::RenderPrototype { ... }

Public Constructors Index

RenderPrototype (std::shared_ptr< const helios::rendering::material::Material > material, std::shared_ptr< const helios::rendering::mesh::Mesh > mesh)

Creates a new RenderPrototype using the specified Material and Mesh. More...

Public Destructor Index

~RenderPrototype ()=default

Public Member Functions Index

const helios::rendering::mesh::Mesh &mesh () const noexcept

Returns a const reference to the immutable Mesh used by this RenderPrototype. More...

const helios::rendering::material::Material &material () const noexcept

Returns a const reference to the immutable Material used by this RenderPrototype. More...

Private Member Attributes Index

std::shared_ptr< const helios::rendering::material::Material >material_

A shared pointer to the base Material definition for this prototype. The Material contains shader information, default uniform values, and render states. It is shared and immutable. More...

std::shared_ptr< const helios::rendering::mesh::Mesh >mesh_

A shared pointer to the Mesh (geometry) used by this prototype. The Mesh defines the geometric shape of the object. It is shared and immutable. More...

Description

An immutable, shared prototype of a renderable object.

A `RenderPrototype` bundles a specific `Mesh` (geometry) with a specific `Material` (shader and default properties). It acts as a shared asset definition, serving as a key for efficient batching and instancing in the rendering pipeline.

## Design

  • **Immutable:** Instances are immutable once created, ensuring consistent behavior for all references.
  • **Shared:** Designed to be shared across multiple `Renderable` objects via `std::shared_ptr`.
  • **Batching Key:** Provides a stable base for per-instance overrides and efficient draw call batching.

## Ownership Model

Both `material_` and `mesh_` use `std::shared_ptr<const T>` to enable safe sharing across multiple prototypes and renderables. The const qualifier ensures immutability of the referenced assets.

## Usage

```cpp auto material = std::make_shared<Material>(shader, properties); auto mesh = std::make_shared<OpenGLMesh>(vertices, indices);

auto prototype = std::make_shared<RenderPrototype>(material, mesh);

// Share across multiple renderables MeshRenderable obj1(prototype); MeshRenderable obj2(prototype, colorOverride); ```

See Also

MeshRenderable

See Also

Material

See Also

Mesh

Definition at line 57 of file RenderPrototype.ixx.

Public Constructors

RenderPrototype()

helios::rendering::RenderPrototype::RenderPrototype (std::shared_ptr< const helios::rendering::material::Material > material, std::shared_ptr< const helios::rendering::mesh::Mesh > mesh)
inline explicit

Creates a new RenderPrototype using the specified Material and Mesh.

Both parameters are moved into the prototype to avoid unnecessary reference count increments. The prototype takes shared ownership of both assets.

Parameters
material

A shared pointer to the immutable Material this RenderPrototype uses.

mesh

A shared pointer to the immutable Mesh this RenderPrototype uses.

Exceptions
std::invalid_argument

If either material or mesh represent a nullptr.

Definition at line 89 of file RenderPrototype.ixx.

90 std::shared_ptr<const helios::rendering::material::Material> material,
91 std::shared_ptr<const helios::rendering::mesh::Mesh> mesh
92 ) :
93 material_(std::move(material)),
94 mesh_(std::move(mesh)) {
95
96 if (!material_) {
97 throw std::invalid_argument("RenderPrototype received material nullptr");
98 }
99 if (!mesh_) {
100 throw std::invalid_argument("RenderPrototype received mesh nullptr");
101 }
102
103 }

References material and mesh.

Public Destructor

~RenderPrototype()

helios::rendering::RenderPrototype::~RenderPrototype ()
default

Definition at line 76 of file RenderPrototype.ixx.

Public Member Functions

material()

const helios::rendering::material::Material & helios::rendering::RenderPrototype::material ()
inline nodiscard noexcept

Returns a const reference to the immutable Material used by this RenderPrototype.

The Material contains shader information and default properties. It is guaranteed to exist and be valid. This method returns a reference to avoid shared_ptr copy overhead.

Returns

A const reference to the Material object.

Definition at line 126 of file RenderPrototype.ixx.

126 [[nodiscard]] const helios::rendering::material::Material& material() const noexcept {
127 return *material_;
128 }

Referenced by RenderPrototype.

mesh()

const helios::rendering::mesh::Mesh & helios::rendering::RenderPrototype::mesh ()
inline nodiscard noexcept

Returns a const reference to the immutable Mesh used by this RenderPrototype.

The Mesh contains geometric data such as vertices and indices used for rendering. This method returns a reference to avoid shared_ptr copy overhead.

Returns

A const reference to the Mesh object.

Definition at line 113 of file RenderPrototype.ixx.

113 [[nodiscard]] const helios::rendering::mesh::Mesh& mesh() const noexcept {
114 return *mesh_;
115 }

Referenced by RenderPrototype.

Private Member Attributes

material_

std::shared_ptr<const helios::rendering::material::Material> helios::rendering::RenderPrototype::material_

A shared pointer to the base Material definition for this prototype. The Material contains shader information, default uniform values, and render states. It is shared and immutable.

Definition at line 65 of file RenderPrototype.ixx.

65 std::shared_ptr <const helios::rendering::material::Material> material_;

mesh_

std::shared_ptr<const helios::rendering::mesh::Mesh> helios::rendering::RenderPrototype::mesh_

A shared pointer to the Mesh (geometry) used by this prototype. The Mesh defines the geometric shape of the object. It is shared and immutable.

Definition at line 71 of file RenderPrototype.ixx.

71 std::shared_ptr<const helios::rendering::mesh::Mesh> mesh_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.