|
Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
Class that is responsible for taking an instance layout and correctly uploading it to the GPU. More...
#include <instance.hpp>
Public Member Functions | |
| BaseInstanceAllocator (const InstanceLayout &instanceLayout) | |
| Construct a new base instance allocator object. | |
| BaseInstanceAllocator (BaseInstanceAllocator &&other)=delete | |
| BaseInstanceAllocator (const BaseInstanceAllocator &other)=delete | |
| BaseInstanceAllocator & | operator= (BaseInstanceAllocator &&other)=delete |
| BaseInstanceAllocator & | operator= (const BaseInstanceAllocator &other)=delete |
| virtual | ~BaseInstanceAllocator () |
| Destroys the allocator object. | |
| InstanceLayout | getInstanceLayout () const |
| Gets the instance attribute layout for this object. | |
| void | bind (const InstanceLayout &shaderInstanceLayout) |
| Binds a (subset of) this object's instance attributes to the currently active shader. | |
| void | unbind () |
| Unbinds this object's instance attributes. | |
| bool | isUploaded () |
| Tests whether the attribute data associated with this allocator has been uploaded to memory. | |
Protected Member Functions | |
| virtual void | upload ()=0 |
| Uploads this object's attribute data to GPU memory. | |
Protected Attributes | |
| GLuint | mVertexBufferIndex {0} |
| The OpenGL handle associated with the buffer that this object's instance data has been storerd on. | |
Private Member Functions | |
| void | unload () |
| Deallocates instance data from GPU, deletes the associated vertex buffer. | |
| void | _upload () |
| Method which calls the override for upload() defined by a subclass. | |
| void | setAttributePointers (const InstanceLayout &shaderInstanceLayout, std::size_t startingOffset=0) |
| Sets attribute pointers per the data contained in the instance layout. | |
Private Attributes | |
| InstanceLayout | mInstanceLayout |
| The layout associated with this allocator. | |
| bool | mUploaded {false} |
| Whether or not the instance data associated with this allocator has been uploaded. | |
Class that is responsible for taking an instance layout and correctly uploading it to the GPU.
It is also responsible for binding attribute data as specified by a layout to some shader attribute.
|
inline |
Construct a new base instance allocator object.
| instanceLayout | The layout this instance allocator is responsible for. |
|
private |
| void BaseInstanceAllocator::bind | ( | const InstanceLayout & | shaderInstanceLayout | ) |
Binds a (subset of) this object's instance attributes to the currently active shader.
| shaderInstanceLayout | The instance layout requested by the shader, which is expected to be a subset of this allocator's layout. |
| InstanceLayout BaseInstanceAllocator::getInstanceLayout | ( | ) | const |
Gets the instance attribute layout for this object.
|
inline |
Tests whether the attribute data associated with this allocator has been uploaded to memory.
| true | Attribute data has been uploaded. |
| false | Attribute data has not been uploaded. |
|
private |
Sets attribute pointers per the data contained in the instance layout.
| shaderInstanceLayout | The layout for instance attributes as described by the shader. |
| startingOffset |
|
protectedpure virtual |
Uploads this object's attribute data to GPU memory.
Implemented in ToyMaker::BuiltinModelMatrixAllocator, and ToyMaker::LightInstanceAllocator.