... | ... |
@@ -9,26 +9,22 @@ |
9 | 9 |
template< |
10 | 10 |
typename T, |
11 | 11 |
typename Value, |
12 |
- typename... Values |
|
12 |
+ std::size_t offset, |
|
13 |
+ typename... Members |
|
13 | 14 |
> |
14 | 15 |
void vertex_setup( |
15 |
- GLTraits::Members<T, Value, Values...>, |
|
16 |
- std::size_t offset = 0, |
|
17 |
- GLint location = 0 |
|
16 |
+ GLTraits::Members<T, GLTraits::Member<Value, offset>, Members...>, |
|
17 |
+ GLint location = 0 |
|
18 | 18 |
) |
19 | 19 |
{ |
20 |
- auto unaligned = offset % alignof(Value); |
|
21 |
- if (unaligned) |
|
22 |
- offset += alignof(Value) - unaligned; |
|
23 | 20 |
GLTraits::Value<Value>::vertex_attrib_pointer(location, offset, sizeof(T)); |
24 | 21 |
vertex_setup( |
25 |
- GLTraits::Members<T, Values...>{}, |
|
26 |
- offset + sizeof(Value), |
|
22 |
+ GLTraits::Members<T, Members...>{}, |
|
27 | 23 |
location + GLTraits::Value<Value>::columns |
28 | 24 |
); |
29 | 25 |
} |
30 | 26 |
template<typename T> |
31 |
-void vertex_setup(GLTraits::Members<T>, std::size_t, GLint) |
|
27 |
+void vertex_setup(GLTraits::Members<T>, GLint) |
|
32 | 28 |
{} |
33 | 29 |
|
34 | 30 |
|
... | ... |
@@ -7,12 +7,12 @@ |
7 | 7 |
|
8 | 8 |
|
9 | 9 |
template< |
10 |
+ typename T, |
|
10 | 11 |
typename Value, |
11 | 12 |
typename... Values |
12 | 13 |
> |
13 | 14 |
void vertex_setup( |
14 |
- GLTraits::Members<Value, Values...>, |
|
15 |
- std::size_t stride, |
|
15 |
+ GLTraits::Members<T, Value, Values...>, |
|
16 | 16 |
std::size_t offset = 0, |
17 | 17 |
GLint location = 0 |
18 | 18 |
) |
... | ... |
@@ -20,15 +20,15 @@ void vertex_setup( |
20 | 20 |
auto unaligned = offset % alignof(Value); |
21 | 21 |
if (unaligned) |
22 | 22 |
offset += alignof(Value) - unaligned; |
23 |
- GLTraits::Value<Value>::vertex_attrib_pointer(location, offset, stride); |
|
23 |
+ GLTraits::Value<Value>::vertex_attrib_pointer(location, offset, sizeof(T)); |
|
24 | 24 |
vertex_setup( |
25 |
- GLTraits::Members<Values...>{}, |
|
26 |
- stride, |
|
25 |
+ GLTraits::Members<T, Values...>{}, |
|
27 | 26 |
offset + sizeof(Value), |
28 | 27 |
location + GLTraits::Value<Value>::columns |
29 | 28 |
); |
30 | 29 |
} |
31 |
-void vertex_setup(GLTraits::Members<>, std::size_t, std::size_t, GLint) |
|
30 |
+template<typename T> |
|
31 |
+void vertex_setup(GLTraits::Members<T>, std::size_t, GLint) |
|
32 | 32 |
{} |
33 | 33 |
|
34 | 34 |
|
... | ... |
@@ -44,5 +44,5 @@ int main() |
44 | 44 |
GLubyte flags; |
45 | 45 |
GLdouble unaligned; |
46 | 46 |
}; |
47 |
- vertex_setup(GLTraits::members<Vertex>(), sizeof(Vertex)); |
|
47 |
+ vertex_setup(GLTraits::members<Vertex>()); |
|
48 | 48 |
} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,48 @@ |
1 |
+#include <cstddef> |
|
2 |
+ |
|
3 |
+#include <glm/glm.hpp> |
|
4 |
+ |
|
5 |
+#include <glbase.hpp> |
|
6 |
+#include <gltraits.hpp> |
|
7 |
+ |
|
8 |
+ |
|
9 |
+template< |
|
10 |
+ typename Value, |
|
11 |
+ typename... Values |
|
12 |
+> |
|
13 |
+void vertex_setup( |
|
14 |
+ GLTraits::Members<Value, Values...>, |
|
15 |
+ std::size_t stride, |
|
16 |
+ std::size_t offset = 0, |
|
17 |
+ GLint location = 0 |
|
18 |
+) |
|
19 |
+{ |
|
20 |
+ auto unaligned = offset % alignof(Value); |
|
21 |
+ if (unaligned) |
|
22 |
+ offset += alignof(Value) - unaligned; |
|
23 |
+ GLTraits::Value<Value>::vertex_attrib_pointer(location, offset, stride); |
|
24 |
+ vertex_setup( |
|
25 |
+ GLTraits::Members<Values...>{}, |
|
26 |
+ stride, |
|
27 |
+ offset + sizeof(Value), |
|
28 |
+ location + GLTraits::Value<Value>::columns |
|
29 |
+ ); |
|
30 |
+} |
|
31 |
+void vertex_setup(GLTraits::Members<>, std::size_t, std::size_t, GLint) |
|
32 |
+{} |
|
33 |
+ |
|
34 |
+ |
|
35 |
+int main() |
|
36 |
+{ |
|
37 |
+ struct Vertex |
|
38 |
+ { |
|
39 |
+ glm::vec3 position; |
|
40 |
+ glm::vec2 tex_coord; |
|
41 |
+ glm::mat3 tbn; |
|
42 |
+ glm::ivec4 bone_indices; |
|
43 |
+ glm::vec4 bone_weights; |
|
44 |
+ GLubyte flags; |
|
45 |
+ GLdouble unaligned; |
|
46 |
+ }; |
|
47 |
+ vertex_setup(GLTraits::members<Vertex>(), sizeof(Vertex)); |
|
48 |
+} |