Ocular Engine
Ocular::Graphics::IndexBuffer Class Reference

#include <IndexBuffer.hpp>

Inheritance diagram for Ocular::Graphics::IndexBuffer:
Ocular::Graphics::D3D11IndexBuffer

Public Member Functions

virtual bool build ()
 
virtual void bind ()
 
virtual void unbind ()
 
virtual void addIndex (uint32_t index)
 
virtual void addIndices (std::vector< uint32_t > const &indices)
 
virtual void addIndices (std::vector< uint32_t > const &indices, uint32_t count)
 
virtual void addIndices (uint32_t const *indices, uint32_t count)
 
uint32_t getIndex (uint32_t index)
 
std::vector< uint32_t > const & getIndices () const
 
uint32_t getNumIndices () const
 

Protected Attributes

std::vector< uint32_t > m_Indices
 

Detailed Description

Generic IndexBuffer for use in rendering meshes and other geometric objects.

It should be noted that attempting to build, bind, or unbind an instance of this parent class will have no effect. Because of this, IndexBuffers should generally not be directly created (via new or other means), but instead be requested for with the current GraphicsDriver. Example:

uint32_t indices[3] = { 0, 1, 2 };
//---------------------------------------------------------
// Build, Bind, and Unbind do nothing
IndexBuffer* badBuffer = new IndexBuffer();
badBuffer->addIndices(indices, 3);
badBuffer->build();
badBuffer->bind();
delete badBuffer;
badBuffer = nullptr;
//---------------------------------------------------------
// Build, Bind, and Unbind work as expected
// Here the IndexBuffer is actually a D3D11IndexBuffer, etc.
IndexBuffer* goodBuffer = OcularGraphics->createIndexBuffer();
goodBuffer->addIndices(indices, 3);
goodBuffer->build();
goodBuffer->bind();
delete goodBuffer;
goodBuffer = nullptr;

Member Function Documentation

void Ocular::Graphics::IndexBuffer::addIndex ( uint32_t  index)
virtual

Adds (appends) an index to the internal index buffer.

Note
that IndexBuffer::build must be called in order for any changes to take effect.
Parameters
[in]index
void Ocular::Graphics::IndexBuffer::addIndices ( std::vector< uint32_t > const &  indices)
virtual

Adds (appends) a vector of indices to the internal index buffer.

Note
that IndexBuffer::build must be called in order for any changes to take effect.
Parameters
[in]indices
void Ocular::Graphics::IndexBuffer::addIndices ( std::vector< uint32_t > const &  indices,
uint32_t  count 
)
virtual

Adds (appends) a vector of indices to the internal index buffer.

Note
that IndexBuffer::build must be called in order for any changes to take effect.
Parameters
[in]indices
[in]countThe number of indices to append from the provided vector
void Ocular::Graphics::IndexBuffer::addIndices ( uint32_t const *  indices,
uint32_t  count 
)
virtual

Adds (appends) an array of indices to the internal index buffer.

Note
that IndexBuffer::build must be called in order for any changes to take effect.
Parameters
[in]indices
[in]countThe number of indices to append from the provided vector
void Ocular::Graphics::IndexBuffer::bind ( )
virtual

Binds the index buffer for use in rendering.

Note
If this is an instance of IndexBuffer and not a child implementation (ie D3D11IndexBuffer, etc.) then this call will do nothing.

Reimplemented in Ocular::Graphics::D3D11IndexBuffer.

bool Ocular::Graphics::IndexBuffer::build ( )
virtual

Builds the index buffer. Must be called prior to first use, or after any changes to the contents of the buffer.

Note
If this is an instance of IndexBuffer and not a child implementation (ie D3D11IndexBuffer, etc.) then this call will do nothing and always return FALSE.
Returns
TRUE if the buffer was successfully built. Will return FALSE if there was an error.

Reimplemented in Ocular::Graphics::D3D11IndexBuffer.

uint32_t Ocular::Graphics::IndexBuffer::getIndex ( uint32_t  index)
Parameters
[in]indexIndex of the index to retrieve on range [0, getNumIndices())
Returns
The index at the specified index.
std::vector< uint32_t > const & Ocular::Graphics::IndexBuffer::getIndices ( ) const
Returns
Reference to a vector of all indices stored within this buffer
uint32_t Ocular::Graphics::IndexBuffer::getNumIndices ( ) const
Returns
The number of indices stored in this buffer
void Ocular::Graphics::IndexBuffer::unbind ( )
virtual

Unbinds the index buffer and sets the currently bound index buffer to NULL.
This has no effect if this buffer is not the currently bound buffer.

Note
If this is an instance of IndexBuffer and not a child implementation (ie D3D11IndexBuffer, etc.) then this call will do nothing.

Reimplemented in Ocular::Graphics::D3D11IndexBuffer.


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