Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Graphics::VertexData Class Reference

Class for vertex data. More...

#include <vertex_data.h>

Public Types

enum  DATA_TYPE : unsigned int {
  GEOMETRY = 0, TEX_COORDS = 1, TEXTURE_UNIT = 2, NORMAL_COORDS = 3,
  RESERVED2 = 4, RESERVED3 = 5, RESERVED4 = 6, RESERVED5 = 7,
  RESERVED6 = 8, RESERVED7 = 9, RESERVED8 = 10, RESERVED9 = 11,
  ONE_WIDE = 12, TWO_WIDE = 13, THREE_WIDE = 14, FOUR_WIDE = 15
}
 VertexData possible types. More...
 

Public Member Functions

 VertexData (const GLenum primitive_type=GL_TRIANGLES)
 VertexData constructor. More...
 
 VertexData (const VertexData &vertex_data)
 VertexData copy constructor. More...
 
VertexData operator= (const VertexData &vertex_data)
 = operator More...
 
 ~VertexData ()
 Destroys the object. More...
 
bool operator== (const VertexData &other)
 == operator More...
 
bool operator!= (const VertexData &other)
 != operator More...
 
void addIndices (const std::vector< unsigned int > &indices)
 Adds indices. More...
 
template<typename T >
void addVec (DATA_TYPE data_type, const std::vector< T > &vec)
 Adds a vector of data for a certain data type. More...
 
unsigned int getIndexCount () const noexcept
 Gets the index count. More...
 
unsigned int getVertexCount () const noexcept
 Gets the vertex count. More...
 
template<typename T >
std::map< DATA_TYPE,
std::vector< T > > 
getCollapsedVectors () const
 Gets a map of collapsed type vectors to a data types. More...
 
std::vector< unsigned int > getIndices () const noexcept
 Gets the indices. More...
 
float highestZ () const noexcept
 Returns the highest Z value found in this vertex data. More...
 
unsigned int numberVertexBufferObjects () const noexcept
 Returns number of vertex buffer objects needed for this vertex data. More...
 
unsigned int generateVertexArrayObject () const
 Generates an opengl vertex array object. More...
 
std::string to_string () const noexcept
 Returns a string representation of the object. More...
 
template<>
void addVec (VertexData::DATA_TYPE data_type, const std::vector< float > &vec)
 
template<>
void addVec (VertexData::DATA_TYPE data_type, const std::vector< double > &vec)
 
template<>
void addVec (VertexData::DATA_TYPE data_type, const std::vector< int > &vec)
 
template<>
void addVec (VertexData::DATA_TYPE data_type, const std::vector< unsigned int > &vec)
 
template<>
std::map
< VertexData::DATA_TYPE,
std::vector< float > > 
getCollapsedVectors () const
 
template<>
std::map
< VertexData::DATA_TYPE,
std::vector< double > > 
getCollapsedVectors () const
 
template<>
std::map
< VertexData::DATA_TYPE,
std::vector< int > > 
getCollapsedVectors () const
 
template<>
std::map
< VertexData::DATA_TYPE,
std::vector< unsigned int > > 
getCollapsedVectors () const
 

Static Public Attributes

static const std::map
< DATA_TYPE, unsigned int > 
DataWidth
 

Detailed Description

Class for vertex data.

Member Enumeration Documentation

enum Graphics::VertexData::DATA_TYPE : unsigned int

VertexData possible types.

Enumerator
GEOMETRY 
TEX_COORDS 
TEXTURE_UNIT 
NORMAL_COORDS 
RESERVED2 
RESERVED3 
RESERVED4 
RESERVED5 
RESERVED6 
RESERVED7 
RESERVED8 
RESERVED9 
ONE_WIDE 
TWO_WIDE 
THREE_WIDE 
FOUR_WIDE 

Constructor & Destructor Documentation

Graphics::VertexData::VertexData ( const GLenum  primitive_type = GL_TRIANGLES)

VertexData constructor.

Parameters
[in]primitive_typeThe primitive type
Graphics::VertexData::VertexData ( const VertexData vertex_data)

VertexData copy constructor.

Parameters
[in]vertex_dataThe vertex data
Graphics::VertexData::~VertexData ( )

Destroys the object.

Member Function Documentation

void Graphics::VertexData::addIndices ( const std::vector< unsigned int > &  indices)

Adds indices.

If indices are added first, then they are used for min and divisibility validation otherwise, vertices added are used for min and divisibility validation

Parameters
[in]indicesThe indices

Referenced by Graphics::UI::FontGenerator::loadFont().

template<typename T >
void Graphics::VertexData::addVec ( DATA_TYPE  data_type,
const std::vector< T > &  vec 
)

Adds a vector of data for a certain data type.

Parameters
[in]data_typeThe data type
[in]vecThe vector
Template Parameters
TPhysical Type of data to add

Referenced by Graphics::UI::FontGenerator::loadFont().

template<>
void Graphics::VertexData::addVec ( VertexData::DATA_TYPE  data_type,
const std::vector< float > &  vec 
)
template<>
void Graphics::VertexData::addVec ( VertexData::DATA_TYPE  data_type,
const std::vector< double > &  vec 
)
template<>
void Graphics::VertexData::addVec ( VertexData::DATA_TYPE  data_type,
const std::vector< int > &  vec 
)
template<>
void Graphics::VertexData::addVec ( VertexData::DATA_TYPE  data_type,
const std::vector< unsigned int > &  vec 
)
unsigned int Graphics::VertexData::generateVertexArrayObject ( ) const

Generates an opengl vertex array object.

Returns
A handle to an opengl vao

References DataWidth, getIndices(), and numberVertexBufferObjects().

Referenced by Graphics::Renderable::create(), and Graphics::UI::FontGenerator::loadFont().

template<typename T >
std::map<DATA_TYPE, std::vector<T> > Graphics::VertexData::getCollapsedVectors ( ) const

Gets a map of collapsed type vectors to a data types.

Returns
Map of data types to vectors of type
template<>
std::map<VertexData::DATA_TYPE, std::vector<float> > Graphics::VertexData::getCollapsedVectors ( ) const
template<>
std::map<VertexData::DATA_TYPE, std::vector<int> > Graphics::VertexData::getCollapsedVectors ( ) const
template<>
std::map<VertexData::DATA_TYPE, std::vector<unsigned int> > Graphics::VertexData::getCollapsedVectors ( ) const
template<>
std::map<VertexData::DATA_TYPE, std::vector<double> > Graphics::VertexData::getCollapsedVectors ( ) const
unsigned int Graphics::VertexData::getIndexCount ( ) const
noexcept

Gets the index count.

Returns
The index count.

Referenced by Graphics::Renderable::onUpdate().

std::vector< unsigned int > Graphics::VertexData::getIndices ( ) const
noexcept

Gets the indices.

Returns
The indices.

Referenced by generateVertexArrayObject().

unsigned int Graphics::VertexData::getVertexCount ( ) const
noexcept

Gets the vertex count.

Returns
The vertex count.

Referenced by Graphics::Renderable::onUpdate().

float Graphics::VertexData::highestZ ( ) const
noexcept

Returns the highest Z value found in this vertex data.

Returns
float representing highest z value

Referenced by Graphics::Renderable::highestZ().

unsigned int Graphics::VertexData::numberVertexBufferObjects ( ) const
noexcept

Returns number of vertex buffer objects needed for this vertex data.

Returns
Number of vbos

Referenced by generateVertexArrayObject().

bool Graphics::VertexData::operator!= ( const VertexData other)

!= operator

Parameters
[in]otherThe other
Returns
True if not same vertexdata
VertexData Graphics::VertexData::operator= ( const VertexData vertex_data)

= operator

Parameters
[in]vertex_dataThe vertex data
Returns
this = other
bool Graphics::VertexData::operator== ( const VertexData other)

== operator

Parameters
[in]otherThe other
Returns
True if same vertexdata
std::string Graphics::VertexData::to_string ( ) const
noexcept

Returns a string representation of the object.

Returns
String representation of the object.

Member Data Documentation

const std::map< Graphics::VertexData::DATA_TYPE, unsigned int > Graphics::VertexData::DataWidth
static
Initial value:
= std::map<Graphics::VertexData::DATA_TYPE, unsigned int> {
{Graphics::VertexData::DATA_TYPE::GEOMETRY, 3},
{Graphics::VertexData::DATA_TYPE::TEX_COORDS, 2},
{Graphics::VertexData::DATA_TYPE::TEXTURE_UNIT, 1},
{Graphics::VertexData::DATA_TYPE::NORMAL_COORDS, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED2, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED3, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED4, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED5, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED6, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED7, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED8, 3},
{Graphics::VertexData::DATA_TYPE::RESERVED9, 3},
{Graphics::VertexData::DATA_TYPE::ONE_WIDE, 1},
{Graphics::VertexData::DATA_TYPE::TWO_WIDE, 2},
{Graphics::VertexData::DATA_TYPE::THREE_WIDE, 3},
{Graphics::VertexData::DATA_TYPE::FOUR_WIDE, 4}
}

Holds the different data widths possible for DATA_TYPE

Referenced by generateVertexArrayObject().


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