A class whose current main purpose is to store geometry related info, and to upload it to GPU memory when requested.
More...
#include <mesh.hpp>
|
void | setAttributePointers (const VertexLayout &shaderVertexLayout, std::size_t startingOffset=0) |
| Specifies the offsets of vertex attributes per the vertex layout requested by a shader.
|
|
void | upload () |
| Uploads the vertex and element data for this object to the GPU.
|
|
void | unload () |
| Deallocates vertex and element data belonging to this object from the GPU.
|
|
void | destroyResource () |
| Deallocates related GPU buffers and releases resources owned by this object.
|
|
void | releaseResource () |
| Loses references to resources owned by this object, allowing another object to take ownership of them (including GPU buffers)
|
|
|
std::vector< BuiltinVertexData > | mVertices {} |
| This object's vertex data.
|
|
std::vector< GLuint > | mElements {} |
| This object's element list.
|
|
VertexLayout | mVertexLayout |
| The vertex layout associated with this mesh, same as BuiltinVertexData's vertex layout.
|
|
bool | mIsUploaded { false } |
| Marker for whether the data in this object has been uploaded to the GPU.
|
|
GLuint | mVertexBuffer { 0 } |
| The OpenGL vertex buffer handle for this object, if it has been uploaded to GPU memory.
|
|
GLuint | mElementBuffer { 0 } |
| The OpenGL element buffer handle for this object, if it has been uploaded to GPU memory.
|
|
A class whose current main purpose is to store geometry related info, and to upload it to GPU memory when requested.
◆ StaticMesh()
StaticMesh::StaticMesh |
( |
const std::vector< BuiltinVertexData > & | mVertices, |
|
|
const std::vector< GLuint > & | mElements, |
|
|
GLuint | vertexBuffer = 0, |
|
|
GLuint | elementBuffer = 0, |
|
|
bool | isUploaded = false ) |
Constructs a new static mesh object.
- Parameters
-
mVertices | A list of vertex data. |
mElements | A list where each item is an index into the vertices array, and where every 3 contiguous elements describe a triangle of a mesh. |
vertexBuffer | The OpenGL vertex buffer handle, if one exists, associated with this object in GPU memory. |
elementBuffer | The OpenGL element buffer handle, if one exists, associated with this object in GPU memory. |
isUploaded | Whether this mesh's data has already been uploaded to the GPU. |
◆ bind()
void StaticMesh::bind |
( |
const VertexLayout & | shaderVertexLayout | ) |
|
Binds this object's vertex data according to the vertex layout specified by the shader program.
- Parameters
-
shaderVertexLayout | The requested vertex layout. |
◆ getElementCount()
GLuint ToyMaker::StaticMesh::getElementCount |
( |
| ) |
|
|
inline |
Returns number of elements in the elements array for this mesh.
- Returns
- GLuint The no. of elements.
◆ getResourceTypeName()
static std::string ToyMaker::StaticMesh::getResourceTypeName |
( |
| ) |
|
|
inlinestatic |
Gets the resource type string for this object.
- Returns
- std::string This object's resource type string.
◆ getVertexLayout()
◆ getVertexListBegin() [1/2]
Gets an iterator to the beginning of this object's vertex list.
- Returns
- std::vector<BuiltinVertexData>::iterator This object's vertex list's beginning iterator.
◆ getVertexListBegin() [2/2]
std::vector< BuiltinVertexData >::const_iterator StaticMesh::getVertexListBegin |
( |
| ) |
const |
Gets a const iterator to the beginning of this object's vertex list.
- Returns
- std::vector<BuiltinVertexData>::const_iterator This object's vertex list's beginning const iterator.
◆ getVertexListEnd() [1/2]
Gets an iterator to the end of this object's vertex list.
- Returns
- std::vector<BuiltinVertexData>::iterator This object's vertex list's ending iterator.
◆ getVertexListEnd() [2/2]
std::vector< BuiltinVertexData >::const_iterator StaticMesh::getVertexListEnd |
( |
| ) |
const |
Gets a const iterator to the end of this object's vertex list.
- Returns
- std::vector<BuiltinVertexData>::const_iterator This object's vertex lists' ending const iterator.
◆ setAttributePointers()
void StaticMesh::setAttributePointers |
( |
const VertexLayout & | shaderVertexLayout, |
|
|
std::size_t | startingOffset = 0 ) |
|
private |
Specifies the offsets of vertex attributes per the vertex layout requested by a shader.
- Parameters
-
shaderVertexLayout | The vertex layout required by a shader. |
startingOffset | The starting offset, in bytes, to the part of vertex and element arrays associated with this mesh. |
◆ mElements
std::vector<GLuint> ToyMaker::StaticMesh::mElements {} |
|
private |
This object's element list.
Each element corresponds to an index into mVertices. Every 3 elements defines one triangle of this mesh.
The documentation for this class was generated from the following files: