All Classes Files Functions Variables Typedefs Pages
VertexAttribute.hpp
1 #pragma once
2 
3 #include "VertexAttribute.fpp"
4 #include "../util/VectorCore.hpp"
5 #include <bitset>
6 
7 
8 namespace lumina {
9 
10 enum class VAttr {
11  Position,
12  Normal,
13  Tangent,
14  TexUV
15 };
16 
17 class VLayoutChans {
18 public:
19  VLayoutChans() = default;
20  VLayoutChans(VAttr chan);
21 
22  VLayoutChans operator|(VAttr chan);
23  bool operator&(VAttr chan);
24 
25  int count() const;
26 
27 private:
28  std::bitset<32> m_chans;
29 };
30 
31 VLayoutChans operator|(VAttr a, VAttr b);
32 
33 namespace internal {
34 
35 template <VAttr C>
36 struct VAttrHelper;
37 
38 #define X(CHAN_, TYPE_) \
39  template <> struct VAttrHelper<VAttr::CHAN_> { using type = TYPE_; };
40 
41 X(Position, Vec3f)
42 X(Normal, Vec3f)
43 X(Tangent, Vec3f)
44 X(TexUV, Vec2f)
45 
46 #undef X
47 
48 template <VAttr H, VAttr... Cs> struct VAttrsHelper {
49  static constexpr int size = sizeof(typename VAttrHelper<H>::type) / 4
51 
52  template <VAttr S>
53  static constexpr bool contains() {
54  return ((H == S) || VAttrsHelper<Cs...>::contains());
55  }
56 };
57 
58 template <VAttr C> struct VAttrsHelper<C> {
59  static constexpr int size = sizeof(typename VAttrHelper<C>::type) / 4;
60 
61  template <VAttr S> static constexpr bool contains() {
62  return (C == S);
63  }
64 };
65 
66 
67 } // namespace internal
68 } // namespace lumina
69 
70 #include "VertexAttribute.tpp"
Definition: VertexAttribute.hpp:48
Definition: VertexAttribute.hpp:36