CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::VertexDeclaration Struct Referencefinal

Determines how vertices are laid-out on a vertex buffer or a mesh data. More...

#include <CeresEngine/Mesh/VertexDeclaration.hpp>

Public Member Functions

const VertexElementgetElement (const VertexElementSemantic &semantic, UInt32 index=0) const noexcept
 Finds a VertexElement with the given semantic.
 
VertexElementgetElement (const VertexElementSemantic &semantic, UInt32 index=0) noexcept
 Finds a VertexElement with the given semantic.
 
VertexElementaddElement (const VertexElementSemantic &semantic, const VertexElementType &type, const VertexElementComponentType &componentType=VertexElementComponentType::Float32, bool normalized=false)
 Adds a new element to the declaration.
 
template<typename T >
VertexElementaddElement (const VertexElementSemantic &semantic, bool normalized=false)
 Adds a new element to the declaration by automatically deducing the VertexElementType and VertexElementComponentType based on the C++ type T.
 
bool removeElement (const VertexElementSemantic &semantic, UInt32 index=0) noexcept
 Removes a vertex element from the declaration.
 
std::size_t getSize () const noexcept
 Computes the size of a single vertex, in bytes.
 
std::size_t getElementOffset (const VertexElementSemantic &semantic, UInt32 index=0) const noexcept
 Computes the offset of the given element, in bytes.
 
String toString () const noexcept
 Gets a string representation of the VertexDeclaration.
 
void toString (std::ostream &stream) const noexcept
 Writes a string representation of the VertexDeclaration to the given stream.
 

Public Attributes

SmallVector< VertexElement, 10 > elements
 

Friends

std::ostream & operator<< (std::ostream &stream, const VertexDeclaration &object)
 
bool operator== (const VertexDeclaration &lhs, const VertexDeclaration &rhs) noexcept
 
bool operator!= (const VertexDeclaration &lhs, const VertexDeclaration &rhs) noexcept
 

Detailed Description

Determines how vertices are laid-out on a vertex buffer or a mesh data.

Member Function Documentation

◆ addElement() [1/2]

template<typename T >
VertexElement & CeresEngine::VertexDeclaration::addElement ( const VertexElementSemantic semantic,
bool  normalized = false 
)

Adds a new element to the declaration by automatically deducing the VertexElementType and VertexElementComponentType based on the C++ type T.

Template Parameters
TThe type to be used for deducing the type and component type from.
Parameters
semanticThe semantic to create the new element with.
normalizedIf true, the element will have it's values normalized.
Returns
A reference to the newly added element.

◆ addElement() [2/2]

VertexElement & CeresEngine::VertexDeclaration::addElement ( const VertexElementSemantic semantic,
const VertexElementType type,
const VertexElementComponentType componentType = VertexElementComponentType::Float32,
bool  normalized = false 
)

Adds a new element to the declaration.

Parameters
semanticThe semantic to create the new element with.
typeThe type of element to be created.
componentTypeThe element component data type.
normalizedIf true, the element will have it's values normalized.
Returns
A reference to the newly added element.

◆ getElement() [1/2]

const VertexElement * CeresEngine::VertexDeclaration::getElement ( const VertexElementSemantic semantic,
UInt32  index = 0 
) const
noexcept

Finds a VertexElement with the given semantic.

If multiple elements with the same semantics exists, they can be queried using index.

Parameters
semanticThe semantic to find a vertex element for.
indexAn optional index. If multiple elements with the same semantic exists, this allows querying the index-th element with the given semantic.
Returns
The matching VertexElement or nullptr if no such vertex element exists.

◆ getElement() [2/2]

VertexElement * CeresEngine::VertexDeclaration::getElement ( const VertexElementSemantic semantic,
UInt32  index = 0 
)
noexcept

Finds a VertexElement with the given semantic.

If multiple elements with the same semantics exists, they can be queried using index.

Parameters
semanticThe semantic to find a vertex element for.
indexAn optional index. If multiple elements with the same semantic exists, this allows querying the index-th element with the given semantic.
Returns
The matching VertexElement or nullptr if no such vertex element exists.

◆ getElementOffset()

std::size_t CeresEngine::VertexDeclaration::getElementOffset ( const VertexElementSemantic semantic,
UInt32  index = 0 
) const
noexcept

Computes the offset of the given element, in bytes.

The offset is given relative to the beginning of the vertex memory.

◆ getSize()

std::size_t CeresEngine::VertexDeclaration::getSize ( ) const
noexcept

Computes the size of a single vertex, in bytes.

◆ removeElement()

bool CeresEngine::VertexDeclaration::removeElement ( const VertexElementSemantic semantic,
UInt32  index = 0 
)
noexcept

Removes a vertex element from the declaration.

Parameters
semanticThe semantic of the vertex element to be removed.
indexAn optional index. If multiple elements with the same semantic exists, this allows querying the index-th element with the given semantic.
Returns
True if the element was found and removed; false otherwise.

◆ toString() [1/2]

String CeresEngine::VertexDeclaration::toString ( ) const
noexcept

Gets a string representation of the VertexDeclaration.

◆ toString() [2/2]

void CeresEngine::VertexDeclaration::toString ( std::ostream &  stream) const
noexcept

Writes a string representation of the VertexDeclaration to the given stream.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const VertexDeclaration lhs,
const VertexDeclaration rhs 
)
friend

◆ operator<<

std::ostream & operator<< ( std::ostream &  stream,
const VertexDeclaration object 
)
friend

◆ operator==

bool operator== ( const VertexDeclaration lhs,
const VertexDeclaration rhs 
)
friend

Member Data Documentation

◆ elements

SmallVector<VertexElement, 10> CeresEngine::VertexDeclaration::elements

The documentation for this struct was generated from the following file: