3#include "spark/render/Export.h"
4#include "spark/render/IndexBuffer.h"
5#include "spark/render/VertexBuffer.h"
11namespace spark::render
16 enum class PrimitiveTopology
19 PointList = 0x00010001,
22 LineList = 0x00020001,
25 TriangleList = 0x00040001,
28 LineStrip = 0x00020002,
31 TriangleStrip = 0x00040002
43 [[nodiscard]] std::vector<const IVertexBufferLayout*>
vertexBufferLayouts() const noexcept {
return genericVertexBufferLayouts(); }
62 [[nodiscard]]
virtual PrimitiveTopology
topology() const noexcept = 0;
66 [[nodiscard]] virtual std::vector<const
IVertexBufferLayout*> genericVertexBufferLayouts() const noexcept = 0;
74 template <typename VertexBufferLayoutType, typename IndexBufferLayoutType>
78 using VertexBufferLayout = VertexBufferLayoutType;
79 using IndexBufferLayout = IndexBufferLayoutType;
83 [[nodiscard]]
virtual std::vector<const VertexBufferLayoutType*>
vertexBufferLayouts() const noexcept = 0;
86 [[nodiscard]] const VertexBufferLayoutType& vertexBufferLayout(
unsigned binding) const override = 0;
89 [[nodiscard]] const IndexBufferLayoutType& indexBufferLayout() const override = 0;
92 [[nodiscard]] std::vector<const
IVertexBufferLayout*> genericVertexBufferLayouts() const noexcept
override
94 auto tmp = vertexBufferLayouts();
95 std::vector<const IVertexBufferLayout*> vertex_buffer_layouts_vector;
96 vertex_buffer_layouts_vector.reserve(tmp.size());
97 std::ranges::transform(tmp,
98 std::back_inserter(vertex_buffer_layouts_vector),
99 [](
const auto& vertex_buffer_layout) {
return static_cast<const IVertexBufferLayout*
>(vertex_buffer_layout); });
100 return vertex_buffer_layouts_vector;
106struct std::formatter<spark::render::PrimitiveTopology> : std::formatter<std::string_view>
108 static constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
110 static constexpr auto format(
const spark::render::PrimitiveTopology topology,
auto& ctx)
114 case spark::render::PrimitiveTopology::PointList:
115 return std::format_to(ctx.out(),
"PointList");
116 case spark::render::PrimitiveTopology::LineList:
117 return std::format_to(ctx.out(),
"LineList");
118 case spark::render::PrimitiveTopology::TriangleList:
119 return std::format_to(ctx.out(),
"TriangleList");
120 case spark::render::PrimitiveTopology::LineStrip:
121 return std::format_to(ctx.out(),
"LineStrip");
122 case spark::render::PrimitiveTopology::TriangleStrip:
123 return std::format_to(ctx.out(),
"TriangleStrip");
125 return std::format_to(ctx.out(),
"Unknown");
Describes the layout of an index buffer.
Definition IndexBuffer.h:24
Describes the layout of a vertex buffer.
Definition VertexBuffer.h:14