Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::BaseInstanceAllocator Class Referenceabstract

Class that is responsible for taking an instance layout and correctly uploading it to the GPU. More...

#include <instance.hpp>

Inheritance diagram for ToyMaker::BaseInstanceAllocator:
ToyMaker::BuiltinModelMatrixAllocator ToyMaker::LightInstanceAllocator

Public Member Functions

 BaseInstanceAllocator (const InstanceLayout &instanceLayout)
 Construct a new base instance allocator object.
 
 BaseInstanceAllocator (BaseInstanceAllocator &&other)=delete
 
 BaseInstanceAllocator (const BaseInstanceAllocator &other)=delete
 
BaseInstanceAllocatoroperator= (BaseInstanceAllocator &&other)=delete
 
BaseInstanceAllocatoroperator= (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BaseInstanceAllocator()

ToyMaker::BaseInstanceAllocator::BaseInstanceAllocator ( const InstanceLayout & instanceLayout)
inline

Construct a new base instance allocator object.

Parameters
instanceLayoutThe layout this instance allocator is responsible for.

Member Function Documentation

◆ _upload()

void BaseInstanceAllocator::_upload ( )
private

Method which calls the override for upload() defined by a subclass.

Todo
I'm actually at a loss as to what I was trying to accomplish here.

◆ bind()

void BaseInstanceAllocator::bind ( const InstanceLayout & shaderInstanceLayout)

Binds a (subset of) this object's instance attributes to the currently active shader.

Parameters
shaderInstanceLayoutThe instance layout requested by the shader, which is expected to be a subset of this allocator's layout.

◆ getInstanceLayout()

InstanceLayout BaseInstanceAllocator::getInstanceLayout ( ) const

Gets the instance attribute layout for this object.

Returns
InstanceLayout This object's instance layout.

◆ isUploaded()

bool ToyMaker::BaseInstanceAllocator::isUploaded ( )
inline

Tests whether the attribute data associated with this allocator has been uploaded to memory.

Return values
trueAttribute data has been uploaded.
falseAttribute data has not been uploaded.

◆ setAttributePointers()

void BaseInstanceAllocator::setAttributePointers ( const InstanceLayout & shaderInstanceLayout,
std::size_t startingOffset = 0 )
private

Sets attribute pointers per the data contained in the instance layout.

Parameters
shaderInstanceLayoutThe layout for instance attributes as described by the shader.
startingOffset

◆ upload()

virtual void ToyMaker::BaseInstanceAllocator::upload ( )
protectedpure virtual

Uploads this object's attribute data to GPU memory.

Implemented in ToyMaker::BuiltinModelMatrixAllocator, and ToyMaker::LightInstanceAllocator.


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