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

Determines how a vertex buffer is laid out in memory. More...

#include <CeresEngine/Mesh/VertexDeclaration.hpp>

Public Member Functions

const VertexBufferLayoutElementgetElement (const VertexElementSemantic &semantic, UInt32 index=0) const noexcept
 Finds a VertexElement with the given semantic.
 
VertexBufferLayoutElementgetElement (const VertexElementSemantic &semantic, UInt32 index=0) noexcept
 Finds a VertexElement with the given semantic.
 
template<typename T >
StridedMemoryView< TgetElementView (const MemoryView< Byte > &data, const VertexElementSemantic &semantic, const UInt32 index=0)
 
template<typename T >
StridedMemoryView< const TgetElementView (const MemoryView< const Byte > &data, const VertexElementSemantic &semantic, const UInt32 index=0)
 
void validate ()
 
void resize (UInt64 newVertexCount)
 Resizes the vertex buffer layout to accommodate newVertexCount vertices.
 
void offsetBy (const Int64 offset) const
 Offsets the vertex buffer by the given amount.
 
std::size_t getSize () const noexcept
 Computes the size of a single vertex, in bytes.
 
std::size_t getVertexSize () const noexcept
 Computes the number of bytes in a single vertex.
 
String toString () const noexcept
 Gets a string representation of the VertexBufferLayout.
 
void toString (std::ostream &stream) const noexcept
 Writes a string representation of the VertexBufferLayout to the given stream.
 

Static Public Member Functions

static VertexBufferLayout separated (const Span< const VertexElement > &elements, UInt64 vertexCount)
 
static VertexBufferLayout separated (const VertexDeclaration &declaration, const UInt64 vertexCount)
 
static VertexBufferLayout interleaved (const Span< const VertexElement > &elements, UInt64 vertexCount)
 
static VertexBufferLayout interleaved (const VertexDeclaration &declaration, const UInt64 vertexCount)
 

Public Attributes

SmallVector< VertexBufferLayoutElement, 10 > elements
 The elements on the vertex stream layout.
 
UInt64 length
 The total number of vertices in the vertex buffer.
 

Friends

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

Detailed Description

Determines how a vertex buffer is laid out in memory.

Usually constructed from a VertexDeclaration using VertexBufferLayout::interleaved or VertexBufferLayout::separated helper static methods.

Member Function Documentation

◆ getElement() [1/2]

const VertexBufferLayoutElement * CeresEngine::VertexBufferLayout::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]

VertexBufferLayoutElement * CeresEngine::VertexBufferLayout::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.

◆ getElementView() [1/2]

template<typename T >
StridedMemoryView< T > CeresEngine::VertexBufferLayout::getElementView ( const MemoryView< Byte > &  data,
const VertexElementSemantic semantic,
const UInt32  index = 0 
)
inline

◆ getElementView() [2/2]

template<typename T >
StridedMemoryView< const T > CeresEngine::VertexBufferLayout::getElementView ( const MemoryView< const Byte > &  data,
const VertexElementSemantic semantic,
const UInt32  index = 0 
)
inline

◆ getSize()

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

Computes the size of a single vertex, in bytes.

◆ getVertexSize()

std::size_t CeresEngine::VertexBufferLayout::getVertexSize ( ) const
noexcept

Computes the number of bytes in a single vertex.

◆ interleaved() [1/2]

static VertexBufferLayout CeresEngine::VertexBufferLayout::interleaved ( const Span< const VertexElement > &  elements,
UInt64  vertexCount 
)
static

◆ interleaved() [2/2]

static VertexBufferLayout CeresEngine::VertexBufferLayout::interleaved ( const VertexDeclaration declaration,
const UInt64  vertexCount 
)
inlinestatic

◆ offsetBy()

void CeresEngine::VertexBufferLayout::offsetBy ( const Int64  offset) const

Offsets the vertex buffer by the given amount.

◆ resize()

void CeresEngine::VertexBufferLayout::resize ( UInt64  newVertexCount)

Resizes the vertex buffer layout to accommodate newVertexCount vertices.

The vertex data is not effectively moved, only the new offsets are computed based on the new vertex count. The user is responsible to copy and move data around such as that the new vertex buffer matches the layout.

◆ separated() [1/2]

static VertexBufferLayout CeresEngine::VertexBufferLayout::separated ( const Span< const VertexElement > &  elements,
UInt64  vertexCount 
)
static

◆ separated() [2/2]

static VertexBufferLayout CeresEngine::VertexBufferLayout::separated ( const VertexDeclaration declaration,
const UInt64  vertexCount 
)
inlinestatic

◆ toString() [1/2]

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

Gets a string representation of the VertexBufferLayout.

◆ toString() [2/2]

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

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

◆ validate()

void CeresEngine::VertexBufferLayout::validate ( )

Friends And Related Symbol Documentation

◆ operator!=

◆ operator<<

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

◆ operator==

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

Member Data Documentation

◆ elements

SmallVector<VertexBufferLayoutElement, 10> CeresEngine::VertexBufferLayout::elements

The elements on the vertex stream layout.

◆ length

UInt64 CeresEngine::VertexBufferLayout::length

The total number of vertices in the vertex buffer.


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