RenderPrototype Class
An immutable, shared prototype of a renderable object. More...
Declaration
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()
| 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.
Public Destructor
~RenderPrototype()
| default |
Definition at line 76 of file RenderPrototype.ixx.
Public Member Functions
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.
Referenced by 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.
Referenced by RenderPrototype.
Private Member Attributes
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.
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.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.