Euphoria
vertex_layout.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <set>
5#include <optional>
6
7namespace eu::render
8{
9
17enum class VertexType
18{
19 // vertex based
23 normal3,
24 color3,
25 color4,
27
28 // instance based
30};
31
33{
34 switch (v)
35 {
36 case VertexType::instance_transform: return true;
37 default: return false;
38 }
39}
40
43{
45 std::string name;
46};
47
50using ShaderVertexAttributes = std::vector<VertexElementDescription>;
51
52std::vector<VertexType> find_duplicates(const ShaderVertexAttributes& items);
53
56{
58 std::string name;
59 int index;
60};
61
68
69using VertexTypes = std::vector<VertexType>;
70
73{
74 std::vector<CompiledVertexElement> elements;
76};
77
80{
81 std::vector<CompiledVertexElementNoName> elements;
83};
84
87{
88 std::map<VertexType, int> indices;
91};
92
96{
98 std::string name;
99};
100
101[[nodiscard]]
103 const CompiledVertexTypeList& l,
104 const ShaderVertexAttributes& elements,
105 std::optional<InstanceProp> instance_prop,
106 std::optional<int> start_index
107);
108
109[[nodiscard]]
111
113 const std::vector<VertexType>& base_layout, const std::vector<ShaderVertexAttributes>& descriptions
114);
115
116CompiledVertexTypeList compile_attribute_layouts(const std::vector<ShaderVertexAttributes>& descriptions);
117
121} // namespace klotter
CompiledVertexTypeList compile_attribute_layouts(const std::vector< VertexType > &base_layout, const std::vector< ShaderVertexAttributes > &descriptions)
std::vector< VertexType > find_duplicates(const ShaderVertexAttributes &items)
CompiledGeomVertexAttributes get_geom_layout(const CompiledVertexTypeList &l)
CompiledShaderVertexAttributes compile_shader_layout(const CompiledVertexTypeList &l, const ShaderVertexAttributes &elements, std::optional< InstanceProp > instance_prop, std::optional< int > start_index)
constexpr bool is_instance_based(VertexType v)
VertexType
Vertex source type, position, normal etc.
std::vector< VertexType > VertexTypes
std::vector< VertexElementDescription > ShaderVertexAttributes
Describes all vertex inputs a shader requires like [vec3 position, vec3 normal, vec2 uv]
A (inclusive) range between two values.
Definition range.h:19
A list of CompiledVertexLayoutNoNameList (for geom)
std::vector< CompiledVertexElementNoName > elements
A list of CompiledVertexElement (for shader)
std::vector< CompiledVertexElement > elements
A realized VertexElementDescription without name like vec3 at gl shader position 3.
A realized VertexElementDescription like vec3 position at gl shader position 3.
A mapping of the vertex type (position...) to the actual shader id (for more than one shader)
std::map< VertexType, int > indices
A property for a shader used in instanced rendering.
A not-yet-realised binding to a shader variable like vec3 position