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::core
8{
9
14
17enum class VertexType
18{
19 // vertex based
27
28 // instance based
30};
31
32
34{
35 switch (v)
36 {
37 case VertexType::instance_transform: return true;
38 default: return false;
39 }
40}
41
44{
46 std::string name;
47};
48
51using ShaderVertexAttributes = std::vector<VertexElementDescription>;
52
53std::vector<VertexType> find_duplicates(const ShaderVertexAttributes& items);
54
57{
59 std::string name;
60 int index;
61};
62
69
70using VertexTypes = std::vector<VertexType>;
71
74{
75 std::vector<CompiledVertexElement> elements;
77};
78
81{
82 std::vector<CompiledVertexElementNoName> elements;
84};
85
88{
89 std::map<VertexType, int> indices;
92};
93
97{
99 std::string name;
100};
101
102[[nodiscard]]
104 const CompiledVertexTypeList& l,
105 const ShaderVertexAttributes& elements,
106 std::optional<InstanceProp> instance_prop,
107 std::optional<int> start_index
108);
109
110[[nodiscard]]
112
114 const std::vector<VertexType>& base_layout, const std::vector<ShaderVertexAttributes>& descriptions
115);
116
117CompiledVertexTypeList compile_attribute_layouts(const std::vector<ShaderVertexAttributes>& descriptions);
118
121
122} // namespace eu::core
123
125 EU_FMT_ENUM_VAL(instance_transform);
126 EU_FMT_ENUM_VAL(position2xy);
127 EU_FMT_ENUM_VAL(position2xz);
128 EU_FMT_ENUM_VAL(position3);
#define EU_FMT_ENUM_END()
Definition pch.public.h:32
#define EU_FMT_ENUM_VAL(V)
Definition pch.public.h:30
#define EU_FMT_ENUM_BEGIN(T, DEF)
Definition pch.public.h:23
CompiledGeomVertexAttributes get_geom_layout(const CompiledVertexTypeList &l)
CompiledVertexTypeList compile_attribute_layouts(const std::vector< VertexType > &base_layout, const std::vector< ShaderVertexAttributes > &descriptions)
CompiledShaderVertexAttributes compile_shader_layout(const CompiledVertexTypeList &l, const ShaderVertexAttributes &elements, std::optional< InstanceProp > instance_prop, std::optional< int > start_index)
std::vector< VertexType > VertexTypes
VertexType
Vertex source type, position, normal etc.
std::vector< VertexType > find_duplicates(const ShaderVertexAttributes &items)
std::vector< VertexElementDescription > ShaderVertexAttributes
Describes all vertex inputs a shader requires like [vec3 position, vec3 normal, vec2 uv].
constexpr bool is_instance_based(VertexType v)
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.