155 return "vertexcoord";
172 template<
typename... Args>
217 template<
typename First,
typename... Rest>
218 constexpr void processArgs(First&& first, Rest&&... rest)
noexcept {
231 template<
typename... Elements>
257 return static_cast<int>(i);
266 return static_cast<int>(i);
274 return (index >= 0) ? &
m_elements[index] :
nullptr;
279 return (index >= 0) ? &
m_elements[index] :
nullptr;
311 template<
typename... Args>
350 return static_cast<int>(i);
359 return static_cast<int>(i);
367 return (index >= 0) ? &
m_elements[index] :
nullptr;
372 return (index >= 0) ? &
m_elements[index] :
nullptr;
402 for (
int i = posIndex; i > 0; --i) {
414 template<
typename... Rest>
420 template<
typename... Rest>
438 const auto* element =
m_layout.getElementByType(type);
440 size_t offset =
m_layout.getElementOffsetByType(type);
441 return *
reinterpret_cast<T*
>(
m_data + offset);
449 const auto* element =
m_layout.getElementBySemantic(semantic);
451 size_t offset =
m_layout.getElementOffsetBySemantic(semantic);
452 return *
reinterpret_cast<T*
>(
m_data + offset);
460 const auto* element =
m_layout.getElementByType(type);
462 size_t offset =
m_layout.getElementOffsetByType(type);
463 *
reinterpret_cast<T*
>(
m_data + offset) = value;
468 if (elementIndex <
m_layout.getElementCount()) {
469 size_t offset =
m_layout.getElementOffset(elementIndex);
470 *
reinterpret_cast<T*
>(
m_data + offset) = value;
476 const auto* element =
m_layout.getElementBySemantic(semantic);
478 size_t offset =
m_layout.getElementOffsetBySemantic(semantic);
479 *
reinterpret_cast<T*
>(
m_data + offset) = value;
510 const auto* element =
m_layout.getElementByType(type);
512 size_t offset =
m_layout.getElementOffsetByType(type);
513 return *
reinterpret_cast<const T*
>(
m_data + offset);
515 static const T dummy{};
521 const auto* element =
m_layout.getElementBySemantic(semantic);
523 size_t offset =
m_layout.getElementOffsetBySemantic(semantic);
524 return *
reinterpret_cast<const T*
>(
m_data + offset);
526 static const T dummy{};
600 assert(!
m_data.empty() &&
"Vertex buffer is empty");
605 assert(!
m_data.empty() &&
"Vertex buffer is empty");
610 assert(!
m_data.empty() &&
"Vertex buffer is empty");
615 assert(!
m_data.empty() &&
"Vertex buffer is empty");
619 template<
typename... Args>
621 static_assert(
sizeof...(args) > 0,
"At least one attribute must be provided");
624 Vertex vertex = (*this)[index];
633 if (elementIndex <
m_layout.getElementCount()) {
634 vertex.
setAttribute(elementIndex, std::forward<T>(value));
638 template<
typename T,
typename... Rest>
640 if (elementIndex <
m_layout.getElementCount()) {
641 vertex.
setAttribute(elementIndex, std::forward<T>(first));
642 setAttributes(vertex, elementIndex + 1, std::forward<Rest>(rest)...);
const VertexLayout & getLayout() const noexcept
const T & getAttribute(const char *semantic) const noexcept
const VertexLayout & m_layout
const uint8_t * getData() const noexcept
ConstVertex(const Vertex &vertex) noexcept
const T & getAttribute(VtxType type) const noexcept
constexpr const VertexElement * getElementByType(VtxType type) const noexcept
constexpr void addElements(const VertexElement &element, Rest &&... rest) noexcept
constexpr size_t getElementCount() const noexcept
constexpr size_t getElementOffsetBySemantic(const char *semantic) const noexcept
constexpr const VertexElement & getElement(size_t index) const noexcept
constexpr size_t getElementOffset(size_t index) const noexcept
constexpr void addElements(const VertexLayout &layout, Rest &&... rest) noexcept
VertexElement m_elements[MaxElements]
constexpr void ensurePositionFirst() noexcept
constexpr void addElement(const VertexElement &element) noexcept
static constexpr size_t MaxElements
constexpr void addElements() noexcept
constexpr const VertexElement * getElementBySemantic(const char *semantic) const noexcept
constexpr int getElementIndexBySemantic(const char *semantic) const noexcept
constexpr size_t getElementOffsetByType(VtxType type) const noexcept
constexpr PixelLayout(Args &&... args) noexcept
constexpr int getElementIndexByType(VtxType type) const noexcept
constexpr void addElements(const PixelLayout &layout) noexcept
constexpr void addElements(const VertexLayout &layout) noexcept
constexpr size_t getStride() const noexcept
VertexBuffer(const VertexLayout &layout) noexcept
void emplaceBack(Args &&... args)
void reserve(size_t vertexCount)
size_t getStride() const noexcept
ConstVertex front() const noexcept
const void * getData() const noexcept
void setAttributes(Vertex &vertex, size_t elementIndex, T &&first, Rest &&... rest)
size_t getDataSize() const noexcept
std::vector< uint8_t > m_data
void setAttributes(Vertex &vertex, size_t elementIndex, T &&value)
size_t getVertexCount() const noexcept
ConstVertex back() const noexcept
Vertex operator[](size_t index) noexcept
const VertexLayout & getLayout() const noexcept
void resize(size_t vertexCount)
constexpr void processArgs(First &&first, Rest &&... rest) noexcept
constexpr VtxType getType() const noexcept
constexpr void processArgs(VtxType type) noexcept
constexpr Format getFormat() const noexcept
constexpr void processArgs(Format format) noexcept
constexpr void processArgs(ModelVertexAttribute attr) noexcept
constexpr VertexElement() noexcept
constexpr size_t getSize() const noexcept
constexpr const char * getSemantic() const noexcept
constexpr ModelVertexAttribute getModelAttribute() const noexcept
constexpr void processArgs(const char *semantic) noexcept
constexpr VertexElement(Args &&... args) noexcept
ModelVertexAttribute m_modelAttribute
constexpr void processArgs() noexcept
void setAttribute(const char *semantic, const T &value) noexcept
void setAttribute(size_t elementIndex, const T &value) noexcept
uint8_t * getData() noexcept
void setAttribute(VtxType type, const T &value) noexcept
const VertexLayout & getLayout() const noexcept
Vertex(uint8_t *data, const VertexLayout &layout) noexcept
friend class VertexBuffer
T & getAttribute(const char *semantic) noexcept
T & getAttribute(VtxType type) noexcept
const uint8_t * getData() const noexcept
const VertexLayout & m_layout
constexpr const VertexElement * getElementByType(VtxType type) const noexcept
VertexElement m_elements[MaxElements]
constexpr size_t getElementOffset(size_t index) const noexcept
constexpr size_t getStride() const noexcept
constexpr int getElementIndexByType(VtxType type) const noexcept
constexpr size_t getElementOffsetBySemantic(const char *semantic) const noexcept
constexpr size_t getElementOffsetByType(VtxType type) const noexcept
constexpr int getElementIndexBySemantic(const char *semantic) const noexcept
static constexpr size_t MaxElements
constexpr void addElement(const VertexElement &element) noexcept
constexpr size_t getElementCount() const noexcept
constexpr const VertexElement & getElement(size_t index) const noexcept
constexpr const VertexElement * getElementBySemantic(const char *semantic) const noexcept
constexpr VertexLayout(const Elements &... elements) noexcept
constexpr const char * GetDefaultSemantic(VtxType type) noexcept
constexpr bool StringEquals(const char *a, const char *b) noexcept
constexpr bool isPositionType(VtxType type) noexcept
constexpr ModelVertexAttribute GetDefaultModelAttribute(VtxType type) noexcept
constexpr Format GetDefaultFormat(VtxType type) noexcept
constexpr size_t FormatSize(Format format) noexcept