13 #ifndef OGLPLUS_SHAPES_VERT_ATTR_INFO_1107121519_HPP
14 #define OGLPLUS_SHAPES_VERT_ATTR_INFO_1107121519_HPP
23 template <
class ShapeBuilder,
class VertexAttributeTag>
24 struct VertexAttribInfo;
26 #define OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(ATTR_NAME, GETTER_NAME) \
27 struct Vertex ## GETTER_NAME ## Tag { }; \
29 template <class ShapeBuilder> \
30 struct VertexAttribInfo<ShapeBuilder, Vertex ## GETTER_NAME ## Tag> \
33 static const GLchar* _name(void) \
38 template <typename T> \
41 typedef GLuint (*type)(const ShapeBuilder&, std::vector<T>&); \
44 template <typename T> \
45 static GLuint _getter_wrapper( \
46 const ShapeBuilder& make, \
47 std::vector<T>& dest \
50 return make.GETTER_NAME(dest); \
53 template <typename T> \
54 static typename _getter_proc<T>::type _getter(T*) \
56 return &VertexAttribInfo::_getter_wrapper<T>; \
60 OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(Position, Positions)
61 OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(Normal, Normals)
62 OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(Tangent, Tangents)
63 OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(Bitangent, Bitangents)
64 OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(TexCoord, TexCoordinates)
65 OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO(Material, MaterialNumbers)
67 #undef OGLPLUS_SHAPES_HLPR_MAKE_VERT_ATTR_INFO
69 #if OGLPLUS_DOCUMENTATION_ONLY
73 class VertexAttribsInfo<ShapeBuiler>
77 bool MakesVertexAttrib(
StrCRef name)
const;
91 static GetterFunction VertexAttribGetter(
StrCRef name);
94 template <
class ShapeBuilder,
class VertexAttribTags, std::
size_t N>
95 class VertexAttribsInfoBase
98 static bool _has_vertex_attrib(
100 std::integral_constant<std::size_t, N>,
101 std::integral_constant<std::size_t, N>
107 template <std::
size_t I>
108 static bool _has_vertex_attrib(
110 std::integral_constant<std::size_t, I>,
111 std::integral_constant<std::size_t, N>
114 auto info = VertexAttribInfo<
116 typename std::tuple_element<I, VertexAttribTags>::type
118 if(name == info._name())
return true;
119 else return _has_vertex_attrib(
121 std::integral_constant<std::size_t, I+1>(),
122 std::integral_constant<std::size_t, N>()
126 static bool _has_vertex_attrib(
StrCRef name)
128 return _has_vertex_attrib(
130 std::integral_constant<std::size_t, 0>(),
131 std::integral_constant<std::size_t, N>()
135 template <
typename T>
138 typedef GLuint (*type)(
const ShapeBuilder&, std::vector<T>&);
141 template <
typename T>
142 static typename _getter_proc<T>::type
146 std::integral_constant<std::size_t, N>,
147 std::integral_constant<std::size_t, N>
153 template <
typename T, std::
size_t I>
154 static typename _getter_proc<T>::type
158 std::integral_constant<std::size_t, I>,
159 std::integral_constant<std::size_t, N>
162 auto info = VertexAttribInfo<
164 typename std::tuple_element<I, VertexAttribTags>::type
166 if(std::strcmp(name.
c_str(), info._name()) == 0)
168 return info._getter(selector);
173 std::integral_constant<std::size_t, I+1>(),
174 std::integral_constant<std::size_t, N>()
179 template <
typename T>
180 static typename _getter_proc<T>::type
181 _find_getter(
T* selector,
StrCRef name)
186 std::integral_constant<std::size_t, 0>(),
187 std::integral_constant<std::size_t, N>()
192 template <
class ShapeBuilder,
class VertexAttribTags>
193 class VertexAttribsInfo
194 :
public VertexAttribsInfoBase<
197 std::tuple_size<VertexAttribTags>::value
201 typedef VertexAttribsInfoBase<
204 std::tuple_size<VertexAttribTags>::value
207 bool MakesVertexAttrib(
StrCRef name)
const
209 return _base::_has_vertex_attrib(name);
212 template <
typename T>
213 static typename _base::template _getter_proc<T>::type
215 const std::vector<T>& ,
219 return _base::_find_getter((
T*)
nullptr, name);
227 #endif // include guard
const Char * c_str(void) const
Returns the null-terminated c-string.
Definition: ref_tpl.hpp:200
String const reference wrapper template.
Definition: ref_tpl.hpp:72