Ocular Engine
Ocular::Graphics::VertexBuffer Class Reference

#include <VertexBuffer.hpp>

Inheritance diagram for Ocular::Graphics::VertexBuffer:
Ocular::Graphics::D3D11VertexBuffer

Public Member Functions

virtual bool build ()
 
virtual void bind ()
 
virtual void unbind ()
 
virtual void addVertex (Vertex const &vertex)
 
virtual void addVertices (std::vector< Vertex > const &vertices)
 
virtual void addVertices (std::vector< Vertex > const &vertices, uint32_t count)
 
virtual void addVertices (Vertex const *vertices, uint32_t count)
 
Vertex const * getVertex (uint32_t index) const
 
std::vector< Vertex > const & getVertices () const
 
uint32_t getNumVertices () const
 

Protected Attributes

std::vector< Vertexm_Vertices
 

Detailed Description

Generic VertexBuffer 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, VertexBuffers should generally not be directly created (via new or other means), but instead be requested for with the current GraphicsDriver. Example:

Vertex vertices[3] = { ... };
//---------------------------------------------------------
// Build, Bind, and Unbind do nothing
VertexBuffer* badBuffer = new VertexBuffer();
badBuffer->addVertices(vertices, 3);
badBuffer->build();
badBuffer->bind();
delete badBuffer;
badBuffer = nullptr;
//---------------------------------------------------------
// Build, Bind, and Unbind work as expected
// Here the IndexBuffer is actually a D3D11VertexBuffer, etc.
VertexBuffer* goodBuffer = OcularGraphics->createVertexBuffer();
goodBuffer->addVertices(vertices, 3);
goodBuffer->build();
goodBuffer->bind();
delete goodBuffer;
goodBuffer = nullptr;

Member Function Documentation

void Ocular::Graphics::VertexBuffer::addVertex ( Vertex const &  vertex)
virtual

Adds (appends) a vertex to the internal vertex buffer.

Note
that VertexBuffer::build must be called in order for any changes to take effect.
Parameters
[in]vertex
void Ocular::Graphics::VertexBuffer::addVertices ( std::vector< Vertex > const &  vertices)
virtual

Adds (appends) a vector of vertices to the internal vertex buffer.

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

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

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

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

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

Binds the vertex buffer for use in rendering.

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

Reimplemented in Ocular::Graphics::D3D11VertexBuffer.

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

Builds the vertex 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 VertexBuffer and not a child implementation (ie D3D11VertexBuffer, 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::D3D11VertexBuffer.

uint32_t Ocular::Graphics::VertexBuffer::getNumVertices ( ) const
Returns
The number of vertices stored in this buffer
Vertex const * Ocular::Graphics::VertexBuffer::getVertex ( uint32_t  index) const
Parameters
[in]indexIndex of the vertex to retrieve on range [0, getNumVertices())
Returns
The vertex at the specified index.
std::vector< Vertex > const & Ocular::Graphics::VertexBuffer::getVertices ( ) const
Returns
Reference to a vector of all vertices stored within this buffer
void Ocular::Graphics::VertexBuffer::unbind ( )
virtual

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

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

Reimplemented in Ocular::Graphics::D3D11VertexBuffer.


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