rays 0.1.11 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.doc/ext/rays/bitmap.cpp +22 -76
- data/.doc/ext/rays/bounds.cpp +95 -125
- data/.doc/ext/rays/camera.cpp +88 -0
- data/.doc/ext/rays/color.cpp +223 -45
- data/.doc/ext/rays/color_space.cpp +146 -46
- data/.doc/ext/rays/defs.cpp +183 -0
- data/.doc/ext/rays/font.cpp +69 -21
- data/.doc/ext/rays/image.cpp +26 -37
- data/.doc/ext/rays/matrix.cpp +186 -29
- data/.doc/ext/rays/native.cpp +14 -8
- data/.doc/ext/rays/noise.cpp +53 -0
- data/.doc/ext/rays/painter.cpp +187 -292
- data/.doc/ext/rays/point.cpp +96 -77
- data/.doc/ext/rays/polygon.cpp +313 -0
- data/.doc/ext/rays/polygon_line.cpp +96 -0
- data/.doc/ext/rays/polyline.cpp +167 -0
- data/.doc/ext/rays/rays.cpp +103 -12
- data/.doc/ext/rays/shader.cpp +83 -9
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/Rakefile +24 -9
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +22 -80
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/camera.cpp +94 -0
- data/ext/rays/color.cpp +231 -51
- data/ext/rays/color_space.cpp +149 -47
- data/ext/rays/defs.cpp +183 -0
- data/ext/rays/defs.h +26 -2
- data/ext/rays/extconf.rb +2 -3
- data/ext/rays/font.cpp +74 -24
- data/ext/rays/image.cpp +28 -40
- data/ext/rays/matrix.cpp +198 -30
- data/ext/rays/native.cpp +14 -8
- data/ext/rays/noise.cpp +55 -0
- data/ext/rays/painter.cpp +203 -298
- data/ext/rays/point.cpp +105 -81
- data/ext/rays/polygon.cpp +329 -0
- data/ext/rays/polygon_line.cpp +99 -0
- data/ext/rays/polyline.cpp +176 -0
- data/ext/rays/rays.cpp +103 -13
- data/ext/rays/shader.cpp +84 -9
- data/include/rays.h +10 -2
- data/include/rays/bitmap.h +14 -26
- data/include/rays/bounds.h +21 -4
- data/include/rays/camera.h +49 -0
- data/include/rays/color.h +25 -14
- data/include/rays/color_space.h +15 -10
- data/include/rays/coord.h +114 -0
- data/include/rays/debug.h +22 -0
- data/include/rays/defs.h +36 -0
- data/include/rays/exception.h +6 -2
- data/include/rays/font.h +4 -4
- data/include/rays/image.h +12 -18
- data/include/rays/matrix.h +50 -24
- data/include/rays/noise.h +42 -0
- data/include/rays/opengl.h +2 -50
- data/include/rays/painter.h +89 -93
- data/include/rays/point.h +44 -51
- data/include/rays/polygon.h +198 -0
- data/include/rays/polyline.h +71 -0
- data/include/rays/rays.h +3 -0
- data/include/rays/ruby.h +7 -1
- data/include/rays/ruby/bounds.h +1 -1
- data/include/rays/ruby/camera.h +41 -0
- data/include/rays/ruby/color.h +1 -1
- data/include/rays/ruby/color_space.h +1 -1
- data/include/rays/ruby/font.h +1 -1
- data/include/rays/ruby/matrix.h +1 -1
- data/include/rays/ruby/point.h +1 -1
- data/include/rays/ruby/polygon.h +52 -0
- data/include/rays/ruby/polyline.h +41 -0
- data/include/rays/ruby/rays.h +8 -0
- data/include/rays/ruby/shader.h +1 -1
- data/include/rays/shader.h +36 -8
- data/lib/rays.rb +7 -2
- data/lib/rays/bitmap.rb +0 -15
- data/lib/rays/bounds.rb +17 -23
- data/lib/rays/camera.rb +21 -0
- data/lib/rays/color.rb +20 -47
- data/lib/rays/color_space.rb +13 -13
- data/lib/rays/image.rb +3 -7
- data/lib/rays/matrix.rb +28 -0
- data/lib/rays/module.rb +4 -19
- data/lib/rays/painter.rb +78 -93
- data/lib/rays/point.rb +13 -21
- data/lib/rays/polygon.rb +58 -0
- data/lib/rays/polygon_line.rb +36 -0
- data/lib/rays/polyline.rb +32 -0
- data/lib/rays/shader.rb +20 -1
- data/rays.gemspec +5 -7
- data/src/bitmap.h +36 -0
- data/src/bounds.cpp +74 -11
- data/src/color.cpp +58 -23
- data/src/color_space.cpp +52 -34
- data/src/color_space.h +22 -0
- data/src/coord.cpp +170 -0
- data/src/coord.h +35 -0
- data/src/font.cpp +118 -0
- data/src/font.h +64 -0
- data/src/frame_buffer.cpp +37 -71
- data/src/frame_buffer.h +4 -4
- data/src/image.cpp +172 -98
- data/src/image.h +25 -0
- data/src/ios/bitmap.h +21 -0
- data/src/ios/bitmap.mm +129 -110
- data/src/ios/camera.mm +236 -0
- data/src/ios/font.mm +50 -62
- data/src/ios/helper.h +2 -2
- data/src/ios/opengl.mm +19 -4
- data/src/ios/rays.mm +3 -0
- data/src/matrix.cpp +111 -26
- data/src/matrix.h +30 -0
- data/src/noise.cpp +74 -0
- data/src/opengl.cpp +9 -27
- data/src/opengl.h +37 -0
- data/src/osx/bitmap.h +21 -0
- data/src/osx/bitmap.mm +129 -110
- data/src/osx/camera.mm +236 -0
- data/src/osx/font.mm +49 -62
- data/src/osx/helper.h +2 -2
- data/src/osx/opengl.mm +19 -83
- data/src/osx/rays.mm +3 -0
- data/src/painter.cpp +845 -671
- data/src/painter.h +24 -0
- data/src/point.cpp +140 -119
- data/src/polygon.cpp +1266 -0
- data/src/polygon.h +32 -0
- data/src/polyline.cpp +160 -0
- data/src/polyline.h +69 -0
- data/src/render_buffer.cpp +11 -4
- data/src/render_buffer.h +2 -2
- data/src/shader.cpp +163 -106
- data/src/shader.h +38 -0
- data/src/shader_program.cpp +533 -0
- data/src/{program.h → shader_program.h} +28 -16
- data/src/shader_source.cpp +140 -0
- data/src/shader_source.h +52 -0
- data/src/texture.cpp +136 -160
- data/src/texture.h +65 -0
- data/src/win32/bitmap.cpp +62 -52
- data/src/win32/font.cpp +11 -13
- data/src/win32/font.h +24 -0
- data/src/win32/gdi.h +6 -6
- data/test/helper.rb +0 -3
- data/test/test_bitmap.rb +31 -7
- data/test/test_bounds.rb +36 -0
- data/test/test_color.rb +59 -19
- data/test/test_color_space.rb +95 -0
- data/test/test_font.rb +5 -0
- data/test/test_image.rb +24 -20
- data/test/test_matrix.rb +106 -0
- data/test/test_painter.rb +157 -51
- data/test/test_painter_shape.rb +102 -0
- data/test/test_point.rb +29 -0
- data/test/test_polygon.rb +234 -0
- data/test/test_polygon_line.rb +167 -0
- data/test/test_polyline.rb +171 -0
- data/test/test_shader.rb +9 -9
- metadata +102 -70
- data/.doc/ext/rays/texture.cpp +0 -138
- data/ext/rays/texture.cpp +0 -149
- data/include/rays/ruby/texture.h +0 -41
- data/include/rays/texture.h +0 -71
- data/lib/rays/texture.rb +0 -24
- data/src/program.cpp +0 -648
- data/test/test_texture.rb +0 -27
@@ -0,0 +1,99 @@
|
|
1
|
+
#include "rays/ruby/polygon.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include "rays/ruby/polyline.h"
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon::Line)
|
9
|
+
|
10
|
+
#define THIS to<Rays::Polygon::Line*>(self)
|
11
|
+
|
12
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Polygon::Line, self)
|
13
|
+
|
14
|
+
|
15
|
+
static
|
16
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
17
|
+
{
|
18
|
+
return new_type<Rays::Polygon::Line>(klass);
|
19
|
+
}
|
20
|
+
RUCY_END
|
21
|
+
|
22
|
+
static
|
23
|
+
RUCY_DEF3(setup, points, loop, hole)
|
24
|
+
{
|
25
|
+
CHECK;
|
26
|
+
|
27
|
+
std::vector<Rays::Point> array;
|
28
|
+
get_line_args(&array, points.size(), points.as_array());
|
29
|
+
*THIS = Rays::Polygon::Line(&array[0], array.size(), loop, hole);
|
30
|
+
}
|
31
|
+
RUCY_END
|
32
|
+
|
33
|
+
static
|
34
|
+
RUCY_DEF0(hole)
|
35
|
+
{
|
36
|
+
CHECK;
|
37
|
+
return value(THIS->hole());
|
38
|
+
}
|
39
|
+
RUCY_END
|
40
|
+
|
41
|
+
|
42
|
+
static Class cPolygonLine;
|
43
|
+
|
44
|
+
void
|
45
|
+
Init_polygon_line ()
|
46
|
+
{
|
47
|
+
Module mRays = define_module("Rays");
|
48
|
+
Class cPolygon = mRays.define_class("Polygon");
|
49
|
+
|
50
|
+
cPolygonLine = cPolygon.define_class("Line", Rays::polyline_class());
|
51
|
+
cPolygonLine.define_alloc_func(alloc);
|
52
|
+
cPolygonLine.define_private_method("setup", setup);
|
53
|
+
cPolygonLine.define_method("hole?", hole);
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
namespace Rucy
|
58
|
+
{
|
59
|
+
|
60
|
+
|
61
|
+
template <> Rays::Polygon::Line
|
62
|
+
value_to<Rays::Polygon::Line> (int argc, const Value* argv, bool convert)
|
63
|
+
{
|
64
|
+
assert(argc == 0 || (argc > 0 && argv));
|
65
|
+
|
66
|
+
if (convert)
|
67
|
+
{
|
68
|
+
if (argc <= 0)
|
69
|
+
return Rays::Polygon::Line();
|
70
|
+
else if (argv->is_num() || argv->is_array())
|
71
|
+
{
|
72
|
+
std::vector<Rays::Point> points;
|
73
|
+
get_line_args(&points, argc, argv);
|
74
|
+
return Rays::Polygon::Line(&points[0], points.size());
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
if (argc != 1)
|
79
|
+
argument_error(__FILE__, __LINE__);
|
80
|
+
|
81
|
+
return value_to<Rays::Polygon::Line&>(*argv, convert);
|
82
|
+
}
|
83
|
+
|
84
|
+
|
85
|
+
}// Rucy
|
86
|
+
|
87
|
+
|
88
|
+
namespace Rays
|
89
|
+
{
|
90
|
+
|
91
|
+
|
92
|
+
Class
|
93
|
+
polygon_line_class ()
|
94
|
+
{
|
95
|
+
return cPolygonLine;
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
}// Rays
|
@@ -0,0 +1,176 @@
|
|
1
|
+
#include "rays/ruby/polyline.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <vector>
|
5
|
+
#include "rays/ruby/point.h"
|
6
|
+
#include "rays/ruby/bounds.h"
|
7
|
+
#include "rays/ruby/polygon.h"
|
8
|
+
#include "defs.h"
|
9
|
+
|
10
|
+
|
11
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Polyline)
|
12
|
+
|
13
|
+
#define THIS to<Rays::Polyline*>(self)
|
14
|
+
|
15
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Polyline, self)
|
16
|
+
|
17
|
+
|
18
|
+
static
|
19
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
20
|
+
{
|
21
|
+
return new_type<Rays::Polyline>(klass);
|
22
|
+
}
|
23
|
+
RUCY_END
|
24
|
+
|
25
|
+
static
|
26
|
+
RUCY_DEF2(setup, points, loop)
|
27
|
+
{
|
28
|
+
CHECK;
|
29
|
+
|
30
|
+
std::vector<Rays::Point> array;
|
31
|
+
get_line_args(&array, points.size(), points.as_array());
|
32
|
+
*THIS = Rays::Polyline(&array[0], array.size(), loop);
|
33
|
+
}
|
34
|
+
RUCY_END
|
35
|
+
|
36
|
+
static
|
37
|
+
RUCY_DEFN(expand)
|
38
|
+
{
|
39
|
+
CHECK;
|
40
|
+
check_arg_count(__FILE__, __LINE__, "Polyline#expand", argc, 1, 2, 3, 4);
|
41
|
+
|
42
|
+
coord width = to<coord> (argv[0]);
|
43
|
+
Rays::CapType cap = argc >= 2 ? to<Rays::CapType> (argv[1]) : Rays::CAP_DEFAULT;
|
44
|
+
Rays::JoinType join = argc >= 3 ? to<Rays::JoinType>(argv[2]) : Rays::JOIN_DEFAULT;
|
45
|
+
coord ml = argc >= 4 ? to<coord> (argv[3]) : Rays::JOIN_DEFAULT_MITER_LIMIT;
|
46
|
+
|
47
|
+
Rays::Polygon polygon;
|
48
|
+
THIS->expand(&polygon, width, cap, join, ml);
|
49
|
+
return value(polygon);
|
50
|
+
}
|
51
|
+
RUCY_END
|
52
|
+
|
53
|
+
static
|
54
|
+
RUCY_DEF0(bounds)
|
55
|
+
{
|
56
|
+
CHECK;
|
57
|
+
return value(THIS->bounds());
|
58
|
+
}
|
59
|
+
RUCY_END
|
60
|
+
|
61
|
+
static
|
62
|
+
RUCY_DEF0(loop)
|
63
|
+
{
|
64
|
+
CHECK;
|
65
|
+
return value(THIS->loop());
|
66
|
+
}
|
67
|
+
RUCY_END
|
68
|
+
|
69
|
+
static
|
70
|
+
RUCY_DEF0(size)
|
71
|
+
{
|
72
|
+
CHECK;
|
73
|
+
return value(THIS->size());
|
74
|
+
}
|
75
|
+
RUCY_END
|
76
|
+
|
77
|
+
static
|
78
|
+
RUCY_DEF0(empty)
|
79
|
+
{
|
80
|
+
CHECK;
|
81
|
+
return value(THIS->empty());
|
82
|
+
}
|
83
|
+
RUCY_END
|
84
|
+
|
85
|
+
static
|
86
|
+
RUCY_DEF1(get_at, index)
|
87
|
+
{
|
88
|
+
CHECK;
|
89
|
+
|
90
|
+
int size = (int) THIS->size();
|
91
|
+
int i = to<int>(index);
|
92
|
+
if (i < 0) i += size;
|
93
|
+
|
94
|
+
if (i < 0 || size <= i)
|
95
|
+
index_error(__FILE__, __LINE__);
|
96
|
+
|
97
|
+
return value((*THIS)[i]);
|
98
|
+
}
|
99
|
+
RUCY_END
|
100
|
+
|
101
|
+
static
|
102
|
+
RUCY_DEF0(each)
|
103
|
+
{
|
104
|
+
CHECK;
|
105
|
+
|
106
|
+
Value ret = Qnil;
|
107
|
+
for (const auto& point : *THIS)
|
108
|
+
ret = rb_yield(value(point));
|
109
|
+
return ret;
|
110
|
+
}
|
111
|
+
RUCY_END
|
112
|
+
|
113
|
+
|
114
|
+
static Class cPolyline;
|
115
|
+
|
116
|
+
void
|
117
|
+
Init_polyline ()
|
118
|
+
{
|
119
|
+
Module mRays = define_module("Rays");
|
120
|
+
|
121
|
+
cPolyline = mRays.define_class("Polyline");
|
122
|
+
cPolyline.define_alloc_func(alloc);
|
123
|
+
cPolyline.define_private_method("setup", setup);
|
124
|
+
cPolyline.define_method("expand", expand);
|
125
|
+
cPolyline.define_method("bounds", bounds);
|
126
|
+
cPolyline.define_method("loop?", loop);
|
127
|
+
cPolyline.define_method("size", size);
|
128
|
+
cPolyline.define_method("empty?", empty);
|
129
|
+
cPolyline.define_method("[]", get_at);
|
130
|
+
cPolyline.define_method("each", each);
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
namespace Rucy
|
135
|
+
{
|
136
|
+
|
137
|
+
|
138
|
+
template <> Rays::Polyline
|
139
|
+
value_to<Rays::Polyline> (int argc, const Value* argv, bool convert)
|
140
|
+
{
|
141
|
+
assert(argc == 0 || (argc > 0 && argv));
|
142
|
+
|
143
|
+
if (convert)
|
144
|
+
{
|
145
|
+
if (argc <= 0)
|
146
|
+
return Rays::Polyline();
|
147
|
+
else if (argv->is_num() || argv->is_array())
|
148
|
+
{
|
149
|
+
std::vector<Rays::Point> points;
|
150
|
+
get_line_args(&points, argc, argv);
|
151
|
+
return Rays::Polyline(&points[0], points.size());
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
if (argc != 1)
|
156
|
+
argument_error(__FILE__, __LINE__);
|
157
|
+
|
158
|
+
return value_to<Rays::Polyline&>(*argv, convert);
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
}// Rucy
|
163
|
+
|
164
|
+
|
165
|
+
namespace Rays
|
166
|
+
{
|
167
|
+
|
168
|
+
|
169
|
+
Class
|
170
|
+
polyline_class ()
|
171
|
+
{
|
172
|
+
return cPolyline;
|
173
|
+
}
|
174
|
+
|
175
|
+
|
176
|
+
}// Rays
|
data/ext/rays/rays.cpp
CHANGED
@@ -1,10 +1,33 @@
|
|
1
|
-
#include
|
2
|
-
|
3
|
-
|
1
|
+
#include "rays/ruby/rays.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <vector>
|
4
5
|
#include "defs.h"
|
5
6
|
|
6
7
|
|
7
|
-
|
8
|
+
RUCY_DEFINE_CONVERT_TO(Rays::CapType)
|
9
|
+
RUCY_DEFINE_CONVERT_TO(Rays::JoinType)
|
10
|
+
|
11
|
+
|
12
|
+
template <typename T>
|
13
|
+
struct EnumType
|
14
|
+
{
|
15
|
+
const char* name;
|
16
|
+
const char* short_name;
|
17
|
+
T type;
|
18
|
+
};
|
19
|
+
|
20
|
+
static std::vector<EnumType<Rays::CapType>> CAP_TYPES({
|
21
|
+
{"CAP_BUTT", "BUTT", Rays::CAP_BUTT},
|
22
|
+
{"CAP_ROUND", "ROUND", Rays::CAP_ROUND},
|
23
|
+
{"CAP_SQUARE", "SQUARE", Rays::CAP_SQUARE},
|
24
|
+
});
|
25
|
+
|
26
|
+
static std::vector<EnumType<Rays::JoinType>> JOIN_TYPES({
|
27
|
+
{"JOIN_MITER", "MITER", Rays::JOIN_MITER},
|
28
|
+
{"JOIN_ROUND", "ROUND", Rays::JOIN_ROUND},
|
29
|
+
{"JOIN_SQUARE", "SQUARE", Rays::JOIN_SQUARE},
|
30
|
+
});
|
8
31
|
|
9
32
|
|
10
33
|
static
|
@@ -23,14 +46,6 @@ RUCY_DEF0(fin)
|
|
23
46
|
}
|
24
47
|
RUCY_END
|
25
48
|
|
26
|
-
static
|
27
|
-
RUCY_DEF0(init_offscreen_context)
|
28
|
-
{
|
29
|
-
Rays::init_offscreen_context();
|
30
|
-
return self;
|
31
|
-
}
|
32
|
-
RUCY_END
|
33
|
-
|
34
49
|
|
35
50
|
static Module mRays;
|
36
51
|
|
@@ -38,12 +53,87 @@ void
|
|
38
53
|
Init_rays ()
|
39
54
|
{
|
40
55
|
mRays = define_module("Rays");
|
56
|
+
|
41
57
|
mRays.define_singleton_method("init!", init);
|
42
58
|
mRays.define_singleton_method("fin!", fin);
|
43
|
-
|
59
|
+
|
60
|
+
for (auto it = CAP_TYPES.begin(); it != CAP_TYPES.end(); ++it)
|
61
|
+
mRays.define_const(it->name, it->type);
|
62
|
+
|
63
|
+
for (auto it = JOIN_TYPES.begin(); it != JOIN_TYPES.end(); ++it)
|
64
|
+
mRays.define_const(it->name, it->type);
|
44
65
|
}
|
45
66
|
|
46
67
|
|
68
|
+
namespace Rucy
|
69
|
+
{
|
70
|
+
|
71
|
+
|
72
|
+
template <> Rays::CapType
|
73
|
+
value_to<Rays::CapType> (int argc, const Value* argv, bool convert)
|
74
|
+
{
|
75
|
+
assert(argc > 0 && argv);
|
76
|
+
|
77
|
+
if (convert)
|
78
|
+
{
|
79
|
+
if (argv->is_s() || argv->is_sym())
|
80
|
+
{
|
81
|
+
const char* str = argv->c_str();
|
82
|
+
for (auto it = CAP_TYPES.begin(); it != CAP_TYPES.end(); ++it)
|
83
|
+
{
|
84
|
+
if (
|
85
|
+
strcasecmp(str, it->name) == 0 ||
|
86
|
+
strcasecmp(str, it->short_name) == 0)
|
87
|
+
{
|
88
|
+
return it->type;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
argument_error(__FILE__, __LINE__, "invalid cap type -- %s", str);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
int type = value_to<int>(*argv, convert);
|
96
|
+
if (type < 0 || Rays::CAP_MAX <= type)
|
97
|
+
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
98
|
+
|
99
|
+
return (Rays::CapType) type;
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
template <> Rays::JoinType
|
104
|
+
value_to<Rays::JoinType> (int argc, const Value* argv, bool convert)
|
105
|
+
{
|
106
|
+
assert(argc > 0 && argv);
|
107
|
+
|
108
|
+
if (convert)
|
109
|
+
{
|
110
|
+
if (argv->is_s() || argv->is_sym())
|
111
|
+
{
|
112
|
+
const char* str = argv->c_str();
|
113
|
+
for (auto it = JOIN_TYPES.begin(); it != JOIN_TYPES.end(); ++it)
|
114
|
+
{
|
115
|
+
if (
|
116
|
+
strcasecmp(str, it->name) == 0 ||
|
117
|
+
strcasecmp(str, it->short_name) == 0)
|
118
|
+
{
|
119
|
+
return it->type;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
argument_error(__FILE__, __LINE__, "invalid join type -- %s", str);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
int type = value_to<int>(*argv, convert);
|
127
|
+
if (type < 0 || Rays::JOIN_MAX <= type)
|
128
|
+
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
129
|
+
|
130
|
+
return (Rays::JoinType) type;
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
}// Rucy
|
135
|
+
|
136
|
+
|
47
137
|
namespace Rays
|
48
138
|
{
|
49
139
|
|
data/ext/rays/shader.cpp
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
#include "rays/ruby/shader.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <rucy.h>
|
5
4
|
#include "defs.h"
|
6
5
|
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
RUCY_DEFINE_VALUE_FROM_TO(Rays::Shader)
|
7
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Shader)
|
12
8
|
|
13
9
|
#define THIS to<Rays::Shader*>(self)
|
14
10
|
|
@@ -23,14 +19,61 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
23
19
|
RUCY_END
|
24
20
|
|
25
21
|
static
|
26
|
-
RUCY_DEF1(
|
22
|
+
RUCY_DEF1(setup, source)
|
27
23
|
{
|
28
24
|
RUCY_CHECK_OBJ(Rays::Shader, self);
|
29
25
|
|
30
|
-
|
26
|
+
*THIS = to<Rays::Shader>(source);
|
27
|
+
}
|
28
|
+
RUCY_END
|
29
|
+
|
30
|
+
static
|
31
|
+
RUCY_DEFN(set_uniform)
|
32
|
+
{
|
33
|
+
CHECK;
|
34
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_uniform", argc, 2, 3, 4, 5);
|
35
|
+
|
36
|
+
#define Ai(n) (argv[n].as_i())
|
37
|
+
#define Af(n) ((float) argv[n].as_f())
|
38
|
+
|
39
|
+
const char* name = argv[0].c_str();
|
40
|
+
if (argv[1].is_array())
|
41
|
+
{
|
42
|
+
argc = argv[1].size();
|
43
|
+
argv = argv[1].as_array();
|
44
|
+
}
|
45
|
+
else
|
46
|
+
{
|
47
|
+
argc -= 1;
|
48
|
+
argv += 1;
|
49
|
+
}
|
50
|
+
|
51
|
+
if (argv[0].is_i())
|
52
|
+
{
|
53
|
+
switch (argc)
|
54
|
+
{
|
55
|
+
case 1: THIS->set_uniform(name, Ai(0)); break;
|
56
|
+
case 2: THIS->set_uniform(name, Ai(0), Ai(1)); break;
|
57
|
+
case 3: THIS->set_uniform(name, Ai(0), Ai(1), Ai(2)); break;
|
58
|
+
case 4: THIS->set_uniform(name, Ai(0), Ai(1), Ai(2), Ai(3)); break;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
else if (argv[0].is_f())
|
62
|
+
{
|
63
|
+
switch (argc)
|
64
|
+
{
|
65
|
+
case 1: THIS->set_uniform(name, Af(0)); break;
|
66
|
+
case 2: THIS->set_uniform(name, Af(0), Af(1)); break;
|
67
|
+
case 3: THIS->set_uniform(name, Af(0), Af(1), Af(2)); break;
|
68
|
+
case 4: THIS->set_uniform(name, Af(0), Af(1), Af(2), Af(3)); break;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
else
|
31
72
|
argument_error(__FILE__, __LINE__);
|
32
73
|
|
33
|
-
|
74
|
+
#undef Ai
|
75
|
+
#undef Af
|
76
|
+
|
34
77
|
return self;
|
35
78
|
}
|
36
79
|
RUCY_END
|
@@ -45,10 +88,42 @@ Init_shader ()
|
|
45
88
|
|
46
89
|
cShader = mRays.define_class("Shader");
|
47
90
|
cShader.define_alloc_func(alloc);
|
48
|
-
cShader.define_private_method("
|
91
|
+
cShader.define_private_method("setup", setup);
|
92
|
+
cShader.define_private_method("set_uniform", set_uniform);
|
49
93
|
}
|
50
94
|
|
51
95
|
|
96
|
+
namespace Rucy
|
97
|
+
{
|
98
|
+
|
99
|
+
|
100
|
+
template <> Rays::Shader
|
101
|
+
value_to<Rays::Shader> (int argc, const Value* argv, bool convert)
|
102
|
+
{
|
103
|
+
if (argc == 1 && argv->is_array())
|
104
|
+
{
|
105
|
+
argc = argv->size();
|
106
|
+
argv = argv->as_array();
|
107
|
+
}
|
108
|
+
|
109
|
+
assert(argc > 0 && argv);
|
110
|
+
|
111
|
+
if (convert)
|
112
|
+
{
|
113
|
+
if (argv->is_s())
|
114
|
+
return Rays::Shader(argv[0].c_str());
|
115
|
+
}
|
116
|
+
|
117
|
+
if (argc != 1)
|
118
|
+
argument_error(__FILE__, __LINE__);
|
119
|
+
|
120
|
+
return value_to<Rays::Shader&>(*argv, convert);
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
}// Rucy
|
125
|
+
|
126
|
+
|
52
127
|
namespace Rays
|
53
128
|
{
|
54
129
|
|