Euphoria
shaderattribute.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "render/gltypes.h"
4 
5 
6 namespace eu::render
7 {
8  enum class ShaderAttributeType
9  {
10  float1,
11  float2,
12  float3,
13  float4,
14  float33,
15  float44
16  };
17 
19  {
20  unknown,
21  vertex,
22  normal,
23  uv,
24  color
25  };
26 
30  {
31  // todo(Gustav): can this be made into a constexpr?
32  constexpr ShaderAttribute
33  (
34  gl::Int a_id,
35  ShaderAttributeType a_type,
36  std::string_view a_name,
37  ShaderAttributeSource a_source,
38  bool a_normalize = false
39  )
40  : id(a_id)
41  , type(a_type)
42  , name(a_name)
43  , source(a_source)
44  , normalize(a_normalize)
45  {
46  }
47 
48  [[nodiscard]] int
49  get_element_count() const;
50 
51  [[nodiscard]] int
52  get_byte_size() const;
53 
56 
59 
61  std::string_view name;
62 
65 
66  // true if the attribute is normalized
67  bool normalize;
68  };
69 
70  bool
71  operator==(const ShaderAttribute& lhs, const ShaderAttribute& rhs);
72 }
bool operator==(const ShaderAttribute &lhs, const ShaderAttribute &rhs)
Represents a shader attribute like vertex, normal or uv coord.
gl::Int id
the id of the attribute
std::string_view name
the name of the shader attribute
constexpr ShaderAttribute(gl::Int a_id, ShaderAttributeType a_type, std::string_view a_name, ShaderAttributeSource a_source, bool a_normalize=false)
ShaderAttributeType type
the type of the attribute
ShaderAttributeSource source
the source of the shader attribute