-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvertex_format_test.cpp
135 lines (118 loc) · 2.42 KB
/
vertex_format_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "graphics/scalar.hpp"
#include "graphics/vec2.hpp"
#include "graphics/shader/variable.hpp"
#include "graphics/shader/value_type_impl.hpp"
#include <sge/renderer/vf/make_unspecified_tag.hpp>
#include <sge/renderer/vf/vector.hpp>
#include <sge/renderer/vf/format.hpp>
#include <sge/renderer/vf/unspecified.hpp>
#include <sge/renderer/vf/vertex_size.hpp>
#include <fcppt/string.hpp>
#include <fcppt/text.hpp>
#include <fcppt/format.hpp>
#include <fcppt/lexical_cast.hpp>
#include <fcppt/io/cout.hpp>
#include <boost/mpl/vector/vector10.hpp>
namespace
{
namespace vf_tags
{
SGE_RENDERER_VF_MAKE_UNSPECIFIED_TAG(position)
SGE_RENDERER_VF_MAKE_UNSPECIFIED_TAG(texcoord)
}
typedef
sge::renderer::vf::unspecified
<
sge::renderer::vf::vector
<
insula::graphics::scalar,
3
>,
vf_tags::position
>
vf_position;
typedef
sge::renderer::vf::unspecified
<
sge::renderer::vf::vector
<
insula::graphics::scalar,
2
>,
vf_tags::texcoord
>
vf_texcoord;
typedef
sge::renderer::vf::format
<
boost::mpl::vector2
<
vf_position,
vf_texcoord
>
>
vertex_format;
}
template<typename T,sge::renderer::vf::vertex_size N>
fcppt::string const
vec_to_string()
{
return FCPPT_TEXT("vec")+fcppt::lexical_cast<fcppt::string>(N);
}
//template<typename T,typename Tag,sge::renderer::vf::vertex_size N>
struct format_printer
{
fcppt::string &s;
explicit
format_printer(
fcppt::string &s) : s(s) {}
template<typename T,typename Tag,sge::renderer::vf::vertex_size N>
void
operator()(
sge::renderer::vf::unspecified
<
sge::renderer::vf::vector<T,N>,Tag>)
{
s +=
(fcppt::format(FCPPT_TEXT("in %s %s;\n"))
% vec_to_string<T,N>()
% Tag::name()).str();
}
template<typename T>
void
operator()(T const &t) const
{
}
};
template<typename Format>
fcppt::string const
vf_to_string()
{
fcppt::string s;
boost::mpl::for_each<typename Format::elements>(
format_printer(
s));
return s;
}
int main()
{
fcppt::string s;
fcppt::io::cout
<< FCPPT_TEXT("Testing vec_to_string:\n")
<<
vec_to_string
<
vf_position::subelement_type,
vf_position::num_subelements
>()
<< FCPPT_TEXT("\n");
fcppt::io::cout
<< FCPPT_TEXT("Testing format_printer:\n")
<< vf_to_string<vertex_format>()
<< FCPPT_TEXT("\n");
fcppt::io::cout <<
insula::graphics::shader::variable(
FCPPT_TEXT("hier_name"),
insula::graphics::shader::variable_type::const_,
insula::graphics::vec2(1,2)).declaration() << FCPPT_TEXT("\n");
}