Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
ToyMaker::VertexLayout Struct Reference

A list of attribute descriptors that together define the layout and size of the vertex they make up in GPU memory. More...

#include <vertex.hpp>

Public Member Functions

 VertexLayout (std::vector< VertexAttributeDescriptor > attributeList)
 Create a vertex layout from a list of attribute descriptors.
 
std::vector< VertexAttributeDescriptorgetAttributeList () const
 Gets the list of attribute descriptors making up this layout.
 
std::size_t computeStride () const
 Computes the total space occupied by a single vertex including all its attributes in memory.
 
std::size_t computeRelativeOffset (std::size_t attributeIndex) const
 Given the index of an attribute descriptor within the layout, computes the offset to that attribute from the beginning of the vertex, in GPU memory.
 
bool isSubsetOf (const VertexLayout &other) const
 Tests whether this vertex layout is the subset of another.
 

Private Attributes

std::vector< VertexAttributeDescriptormAttributeList {}
 The list of attribute descriptors that define this layout.
 

Detailed Description

A list of attribute descriptors that together define the layout and size of the vertex they make up in GPU memory.

Todo
This isn't particularly intuitive or useful yet; expand on this so that shaders can declare their vertex layouts in their json headers maybe? At present we've just hardcoded this into the render stages.

Constructor & Destructor Documentation

◆ VertexLayout()

ToyMaker::VertexLayout::VertexLayout ( std::vector< VertexAttributeDescriptor > attributeList)
inline

Create a vertex layout from a list of attribute descriptors.

Parameters
attributeListThe list of attributes in the layout.

Member Function Documentation

◆ computeRelativeOffset()

std::size_t ToyMaker::VertexLayout::computeRelativeOffset ( std::size_t attributeIndex) const
inline

Given the index of an attribute descriptor within the layout, computes the offset to that attribute from the beginning of the vertex, in GPU memory.

Parameters
attributeIndexThe index of the attribute whose offset we want.
Returns
std::size_t The number of bytes from the start of the vertex data to the start of the attribute.

◆ computeStride()

std::size_t ToyMaker::VertexLayout::computeStride ( ) const
inline

Computes the total space occupied by a single vertex including all its attributes in memory.

Returns
std::size_t The total size of a single vertex in memory.

◆ getAttributeList()

std::vector< VertexAttributeDescriptor > ToyMaker::VertexLayout::getAttributeList ( ) const
inline

Gets the list of attribute descriptors making up this layout.

Returns
std::vector<VertexAttributeDescriptor> This layout's attribute descriptor.

◆ isSubsetOf()

bool ToyMaker::VertexLayout::isSubsetOf ( const VertexLayout & other) const
inline

Tests whether this vertex layout is the subset of another.

This vertex must have attributes in the same order as the other, but may skip any attributes present on the other.

Used mainly to determine whether the layout requested by a RenderStage is compatible with the layout describing some vertex data.

Parameters
otherThe layout this one is possibly a subset of.
Return values
trueThis layout is a subset of the other.
falseThis layout is not a subset of the other.

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