OpenGLMesh Class
Representative of an OpenGLMesh. This class manages the OpenGL Vertex Array Object (VAO), the Vertex Buffer Object (VBO) and Element Buffer Object (EBO) handles. The raw mesh data is uploaded to the GPU, preparing it for subsequent rendering commands / draw calls. More...
Declaration
Base class
| class | Mesh |
|
Representative of a renderable 3D mesh. More... | |
Public Constructors Index
| OpenGLMesh (const OpenGLMesh &)=delete | |
|
Rule of three. More... | |
| OpenGLMesh (std::shared_ptr< const std::vector< helios::rendering::Vertex > > vertices, std::shared_ptr< const std::vector< unsigned int > > indices, std::shared_ptr< const helios::rendering::mesh::MeshConfig > meshConfig) | |
|
Constructs a new OpenGLMesh instance from raw mesh data. More... | |
| OpenGLMesh (const helios::rendering::asset::shape::Shape &shape, std::shared_ptr< const helios::rendering::mesh::MeshConfig > meshConfig) | |
|
Creates a new OpenGLMesh instance from the specified Shape. More... | |
Public Destructor Index
| ~OpenGLMesh () override | |
|
Frees allocated resources bv this instance. If an instance of this class is destructed, `glDeleteBuffers`/`glDeleteVertexArrays` is called to free the associated resources. More... | |
Public Operators Index
| OpenGLMesh & | operator= (const OpenGLMesh &)=delete |
Public Member Functions Index
| const unsigned int & | vao () const noexcept |
|
Returns the OpenGL Vertex Array Object Handle. More... | |
| const unsigned int & | vbo () const noexcept |
|
Returns the OpenGL Vertex Buffer Object handle. More... | |
| const unsigned int & | ebo () const noexcept |
|
Returns the OpenGL Element Buffer Object handle for indexed rendering. More... | |
Protected Member Functions Index
| void | init () override |
|
Initializes all buffer objects required by OpenGL from the provided mesh data. The current implementation generates all VAO, VBO and EBO handles, loads the vertex and index data to the GPU. It follows [Vri20, 162] in this regard. More... | |
Protected Member Attributes Index
| const unsigned int | vao_ |
|
Vertex Array Object handle. More... | |
| const unsigned int | vbo_ |
|
Vertex Buffer Object handle. Stores vertex attributes such as normals and texture coordinates. More... | |
| const unsigned int | ebo_ |
|
Element Buffer Object handle. Stores the indices used for indexed drawing. More... | |
Protected Static Functions Index
| static unsigned int | generateGLVertexArray () noexcept |
|
Helper function for generating a Vertex Array Object identifier. More... | |
| static unsigned int | generateGLBuffer () noexcept |
|
Helper function for generating a Buffer Object identifier, to be used with vertex buffer or element buffer. More... | |
Description
Representative of an OpenGLMesh. This class manages the OpenGL Vertex Array Object (VAO), the Vertex Buffer Object (VBO) and Element Buffer Object (EBO) handles. The raw mesh data is uploaded to the GPU, preparing it for subsequent rendering commands / draw calls.
Definition at line 29 of file OpenGLMesh.ixx.
Public Constructors
OpenGLMesh()
| delete |
Rule of three.
Definition at line 134 of file OpenGLMesh.ixx.
Reference OpenGLMesh.
Referenced by OpenGLMesh and operator=.
OpenGLMesh()
| inline explicit |
Constructs a new OpenGLMesh instance from raw mesh data.
- Parameters
-
vertices A shared pointer to a vector of const Vertex
indices A shared pointer to a vector of indices
meshConfig A shared ptr to the const MeshConfig used with this Mesh.
- Exceptions
-
std::invalid_argument if either "vertices", "indices" or meshConfig is a null shared pointer
Definition at line 147 of file OpenGLMesh.ixx.
References ebo_, generateGLBuffer, generateGLVertexArray, helios::rendering::mesh::Mesh::indices, helios::rendering::mesh::Mesh::indices_, init, helios::rendering::mesh::Mesh::logger_, helios::rendering::mesh::Mesh::Mesh, helios::rendering::mesh::Mesh::meshConfig, helios::rendering::mesh::Mesh::meshConfig_, vao_, vbo_, helios::rendering::mesh::Mesh::vertices and helios::rendering::mesh::Mesh::vertices_.
OpenGLMesh()
| inline explicit |
Creates a new OpenGLMesh instance from the specified Shape.
- Parameters
-
shape A const reference to the Shape.
meshConfig A shared ptr to the const MeshConfig used with this OpenGLMesh.
- Exceptions
-
std::invalid_argument if meshConfig is a null shared pointer, or if the shape contained null data
Definition at line 182 of file OpenGLMesh.ixx.
References ebo_, generateGLBuffer, generateGLVertexArray, helios::rendering::mesh::Mesh::indices_, init, helios::rendering::mesh::Mesh::logger_, helios::rendering::mesh::Mesh::Mesh, helios::rendering::mesh::Mesh::meshConfig, helios::rendering::mesh::Mesh::meshConfig_, vao_, vbo_ and helios::rendering::mesh::Mesh::vertices_.
Public Destructor
~OpenGLMesh()
| inline |
Frees allocated resources bv this instance. If an instance of this class is destructed, `glDeleteBuffers`/`glDeleteVertexArrays` is called to free the associated resources.
Definition at line 216 of file OpenGLMesh.ixx.
Public Operators
operator=()
| delete |
Definition at line 135 of file OpenGLMesh.ixx.
Reference OpenGLMesh.
Public Member Functions
ebo()
| inline nodiscard noexcept |
vao()
| inline nodiscard noexcept |
Returns the OpenGL Vertex Array Object Handle.
- Returns
VAO handle
Definition at line 227 of file OpenGLMesh.ixx.
Reference vao_.
Referenced by generateGLVertexArray.
vbo()
| inline nodiscard noexcept |
Returns the OpenGL Vertex Buffer Object handle.
- Returns
VBO handle
Definition at line 236 of file OpenGLMesh.ixx.
Reference vbo_.
Referenced by generateGLBuffer.
Protected Member Functions
init()
| inline protected virtual |
Initializes all buffer objects required by OpenGL from the provided mesh data. The current implementation generates all VAO, VBO and EBO handles, loads the vertex and index data to the GPU. It follows [Vri20, 162] in this regard.
- See Also
[Vri20, 162]
Definition at line 86 of file OpenGLMesh.ixx.
References ebo_, helios::rendering::mesh::Mesh::indices_, vao_, vbo_ and helios::rendering::mesh::Mesh::vertices_.
Referenced by OpenGLMesh and OpenGLMesh.
Protected Member Attributes
ebo_
| protected |
Element Buffer Object handle. Stores the indices used for indexed drawing.
Definition at line 51 of file OpenGLMesh.ixx.
Referenced by ebo, init, OpenGLMesh, OpenGLMesh and ~OpenGLMesh.
vao_
| protected |
Vertex Array Object handle.
Definition at line 37 of file OpenGLMesh.ixx.
Referenced by init, OpenGLMesh, OpenGLMesh, vao and ~OpenGLMesh.
vbo_
| protected |
Vertex Buffer Object handle. Stores vertex attributes such as normals and texture coordinates.
Definition at line 44 of file OpenGLMesh.ixx.
Referenced by init, OpenGLMesh, OpenGLMesh, vbo and ~OpenGLMesh.
Protected Static Functions
generateGLBuffer()
| inline noexcept protected static |
Helper function for generating a Buffer Object identifier, to be used with vertex buffer or element buffer.
- Returns
Vertex Array Object handle.
Definition at line 72 of file OpenGLMesh.ixx.
Reference vbo.
Referenced by OpenGLMesh and OpenGLMesh.
generateGLVertexArray()
| inline noexcept protected static |
Helper function for generating a Vertex Array Object identifier.
- Returns
Vertex Array Object handle.
Definition at line 59 of file OpenGLMesh.ixx.
Reference vao.
Referenced by OpenGLMesh and OpenGLMesh.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.