rays 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.doc/ext/rays/bitmap.cpp +70 -233
- data/.doc/ext/rays/bounds.cpp +339 -57
- data/.doc/ext/rays/color.cpp +58 -48
- data/.doc/ext/rays/color_space.cpp +174 -0
- data/.doc/ext/rays/font.cpp +31 -53
- data/.doc/ext/rays/image.cpp +64 -67
- data/.doc/ext/rays/matrix.cpp +22 -50
- data/.doc/ext/rays/native.cpp +9 -2
- data/.doc/ext/rays/painter.cpp +276 -259
- data/.doc/ext/rays/point.cpp +186 -52
- data/.doc/ext/rays/rays.cpp +25 -20
- data/.doc/ext/rays/shader.cpp +61 -0
- data/.doc/ext/rays/texture.cpp +47 -59
- data/{README → README.md} +0 -0
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +88 -248
- data/ext/rays/bounds.cpp +437 -141
- data/ext/rays/color.cpp +79 -69
- data/ext/rays/color_space.cpp +185 -0
- data/ext/rays/extconf.rb +14 -63
- data/ext/rays/font.cpp +44 -65
- data/ext/rays/image.cpp +82 -81
- data/ext/rays/matrix.cpp +32 -60
- data/ext/rays/native.cpp +9 -2
- data/ext/rays/painter.cpp +345 -321
- data/ext/rays/point.cpp +212 -69
- data/ext/rays/rays.cpp +29 -23
- data/ext/rays/shader.cpp +63 -0
- data/ext/rays/texture.cpp +64 -74
- data/include/rays/bitmap.h +21 -12
- data/include/rays/bounds.h +67 -9
- data/include/rays/color.h +23 -7
- data/include/rays/{colorspace.h → color_space.h} +6 -3
- data/include/rays/exception.h +17 -11
- data/include/rays/font.h +4 -3
- data/include/rays/image.h +11 -6
- data/include/rays/matrix.h +15 -12
- data/include/rays/opengl.h +54 -1
- data/include/rays/painter.h +98 -108
- data/include/rays/point.h +45 -5
- data/include/rays/rays.h +2 -2
- data/include/rays/ruby/bitmap.h +2 -16
- data/include/rays/ruby/bounds.h +4 -16
- data/include/rays/ruby/color.h +3 -16
- data/include/rays/ruby/color_space.h +27 -0
- data/include/rays/ruby/font.h +2 -16
- data/include/rays/ruby/image.h +2 -16
- data/include/rays/ruby/matrix.h +2 -16
- data/include/rays/ruby/painter.h +2 -16
- data/include/rays/ruby/point.h +3 -16
- data/include/rays/ruby/shader.h +27 -0
- data/include/rays/ruby/texture.h +2 -16
- data/include/rays/ruby.h +1 -0
- data/include/rays/shader.h +48 -0
- data/include/rays/texture.h +13 -2
- data/include/rays.h +2 -1
- data/lib/rays/bitmap.rb +20 -11
- data/lib/rays/bounds.rb +29 -68
- data/lib/rays/color.rb +39 -0
- data/lib/rays/color_space.rb +33 -0
- data/lib/rays/font.rb +29 -0
- data/lib/rays/image.rb +22 -0
- data/lib/rays/module.rb +11 -7
- data/lib/rays/painter.rb +103 -40
- data/lib/rays/point.rb +19 -36
- data/lib/rays/shader.rb +13 -0
- data/lib/rays/texture.rb +9 -0
- data/lib/rays.rb +4 -0
- data/rays.gemspec +3 -4
- data/src/bounds.cpp +272 -63
- data/src/color.cpp +168 -21
- data/src/{colorspace.cpp → color_space.cpp} +38 -1
- data/src/exception.cpp +24 -15
- data/src/frame_buffer.cpp +275 -0
- data/src/frame_buffer.h +79 -0
- data/src/image.cpp +80 -36
- data/src/ios/bitmap.mm +340 -0
- data/src/ios/font.mm +206 -0
- data/src/{cocoa → ios}/helper.h +2 -2
- data/src/{cocoa → ios}/helper.mm +0 -0
- data/src/ios/opengl.mm +21 -0
- data/src/ios/program.cpp +122 -0
- data/src/{cocoa → ios}/rays.mm +8 -7
- data/src/matrix.cpp +10 -22
- data/src/opengl.cpp +64 -0
- data/src/{cocoa → osx}/bitmap.mm +121 -70
- data/src/{cocoa → osx}/font.mm +32 -24
- data/src/osx/helper.h +26 -0
- data/src/osx/helper.mm +25 -0
- data/src/osx/opengl.mm +103 -0
- data/src/osx/rays.mm +43 -0
- data/src/painter.cpp +596 -422
- data/src/point.cpp +154 -11
- data/src/program.cpp +513 -0
- data/src/program.h +73 -0
- data/src/render_buffer.cpp +120 -0
- data/src/render_buffer.h +47 -0
- data/src/shader.cpp +117 -0
- data/src/texture.cpp +104 -134
- data/test/helper.rb +10 -3
- data/test/test_bitmap.rb +18 -0
- data/test/test_bounds.rb +81 -35
- data/test/test_color.rb +29 -2
- data/test/test_image.rb +63 -0
- data/test/test_painter.rb +120 -0
- data/test/test_point.rb +30 -9
- data/test/test_shader.rb +37 -0
- data/test/test_texture.rb +18 -0
- metadata +75 -58
- data/.gitignore +0 -14
- data/ChangeLog +0 -8
data/ext/rays/point.cpp
CHANGED
@@ -12,62 +12,25 @@ using Rays::coord;
|
|
12
12
|
|
13
13
|
static Class cPoint;
|
14
14
|
|
15
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Point, cPoint)
|
15
16
|
|
16
|
-
|
17
|
-
{
|
18
|
-
|
19
|
-
|
20
|
-
Class
|
21
|
-
point_class ()
|
22
|
-
{
|
23
|
-
return cPoint;
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
}// Rays
|
17
|
+
#define THIS to<Rays::Point*>(self)
|
28
18
|
|
29
|
-
|
30
|
-
namespace Rucy
|
31
|
-
{
|
32
|
-
|
33
|
-
|
34
|
-
Value
|
35
|
-
value (const Rays::Point& obj)
|
36
|
-
{
|
37
|
-
return new_type(cPoint, new Rays::Point(obj));
|
38
|
-
}
|
39
|
-
|
40
|
-
Value
|
41
|
-
value (const Rays::Point* obj)
|
42
|
-
{
|
43
|
-
return obj ? value(*obj) : nil();
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
}// Rucy
|
48
|
-
|
49
|
-
|
50
|
-
#define THIS to<Rays::Point*>(self)
|
51
|
-
|
52
|
-
#define CHECK RUCY_CHECK_OBJ(self, Rays::Point, cPoint)
|
19
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Point, cPoint, self)
|
53
20
|
|
54
21
|
|
55
22
|
static
|
56
|
-
|
23
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
57
24
|
{
|
58
25
|
return new_type<Rays::Point>(klass);
|
59
26
|
}
|
60
|
-
|
27
|
+
RUCY_END
|
61
28
|
|
62
29
|
static
|
63
|
-
|
30
|
+
RUCY_DEFN(initialize)
|
64
31
|
{
|
65
|
-
|
66
|
-
|
67
|
-
if (argc != 0 && argc != 1 && argc != 2 && argc != 3)
|
68
|
-
arg_count_error("Point#initialize", argc, 0, 1, 2, 3);
|
69
|
-
|
70
|
-
if (argc == 0) return self;
|
32
|
+
CHECK;
|
33
|
+
check_arg_count(__FILE__, __LINE__, "Point#initialize", argc, 0, 1, 2, 3);
|
71
34
|
|
72
35
|
switch (argc)
|
73
36
|
{
|
@@ -87,75 +50,184 @@ RUBY_DEFN(initialize)
|
|
87
50
|
|
88
51
|
return self;
|
89
52
|
}
|
90
|
-
|
53
|
+
RUCY_END
|
91
54
|
|
92
55
|
static
|
93
|
-
|
56
|
+
RUCY_DEF1(initialize_copy, obj)
|
94
57
|
{
|
95
|
-
|
58
|
+
CHECK;
|
59
|
+
*THIS = to<Rays::Point&>(obj);
|
60
|
+
return self;
|
61
|
+
}
|
62
|
+
RUCY_END
|
96
63
|
|
97
|
-
|
98
|
-
|
64
|
+
static
|
65
|
+
RUCY_DEFN(move_to)
|
66
|
+
{
|
67
|
+
CHECK;
|
68
|
+
check_arg_count(__FILE__, __LINE__, "Point#move_to", argc, 1, 2, 3);
|
69
|
+
|
70
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
71
|
+
THIS->move_to(to<Rays::Point&>(argv[0]));
|
72
|
+
else
|
73
|
+
{
|
74
|
+
const Rays::Point& p = *THIS;
|
75
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
|
76
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
77
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
78
|
+
THIS->move_to(x, y, z);
|
79
|
+
}
|
99
80
|
|
100
|
-
*THIS = *point;
|
101
81
|
return self;
|
102
82
|
}
|
103
|
-
|
83
|
+
RUCY_END
|
104
84
|
|
105
85
|
static
|
106
|
-
|
86
|
+
RUCY_DEFN(move_by)
|
107
87
|
{
|
108
88
|
CHECK;
|
89
|
+
check_arg_count(__FILE__, __LINE__, "Point#move_by", argc, 1, 2, 3);
|
109
90
|
|
110
|
-
|
91
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
92
|
+
THIS->move_by(to<Rays::Point&>(argv[0]));
|
93
|
+
else
|
94
|
+
{
|
95
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : 0;
|
96
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
97
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
98
|
+
THIS->move_by(x, y, z);
|
99
|
+
}
|
100
|
+
|
101
|
+
return self;
|
111
102
|
}
|
112
|
-
|
103
|
+
RUCY_END
|
113
104
|
|
114
105
|
static
|
115
|
-
|
106
|
+
RUCY_DEF1(set_x, x)
|
116
107
|
{
|
117
108
|
CHECK;
|
109
|
+
return value(THIS->x = to<coord>(x));
|
110
|
+
}
|
111
|
+
RUCY_END
|
118
112
|
|
113
|
+
static
|
114
|
+
RUCY_DEF0(get_x)
|
115
|
+
{
|
116
|
+
CHECK;
|
119
117
|
return value(THIS->x);
|
120
118
|
}
|
121
|
-
|
119
|
+
RUCY_END
|
122
120
|
|
123
121
|
static
|
124
|
-
|
122
|
+
RUCY_DEF1(set_y, y)
|
125
123
|
{
|
126
124
|
CHECK;
|
127
|
-
|
128
125
|
return value(THIS->y = to<coord>(y));
|
129
126
|
}
|
130
|
-
|
127
|
+
RUCY_END
|
131
128
|
|
132
129
|
static
|
133
|
-
|
130
|
+
RUCY_DEF0(get_y)
|
134
131
|
{
|
135
132
|
CHECK;
|
136
|
-
|
137
133
|
return value(THIS->y);
|
138
134
|
}
|
139
|
-
|
135
|
+
RUCY_END
|
140
136
|
|
141
137
|
static
|
142
|
-
|
138
|
+
RUCY_DEF1(set_z, z)
|
143
139
|
{
|
144
140
|
CHECK;
|
145
|
-
|
146
141
|
return value(THIS->z = to<coord>(z));
|
147
142
|
}
|
148
|
-
|
143
|
+
RUCY_END
|
149
144
|
|
150
145
|
static
|
151
|
-
|
146
|
+
RUCY_DEF0(get_z)
|
152
147
|
{
|
153
148
|
CHECK;
|
154
|
-
|
155
149
|
return value(THIS->z);
|
156
150
|
}
|
157
|
-
|
151
|
+
RUCY_END
|
158
152
|
|
153
|
+
static
|
154
|
+
RUCY_DEF1(add, point)
|
155
|
+
{
|
156
|
+
CHECK;
|
157
|
+
|
158
|
+
Rays::Point p = *THIS;
|
159
|
+
p += to<Rays::Point&>(point);
|
160
|
+
return value(p);
|
161
|
+
}
|
162
|
+
RUCY_END
|
163
|
+
|
164
|
+
static
|
165
|
+
RUCY_DEF1(sub, point)
|
166
|
+
{
|
167
|
+
CHECK;
|
168
|
+
|
169
|
+
Rays::Point p = *THIS;
|
170
|
+
p -= to<Rays::Point&>(point);
|
171
|
+
return value(p);
|
172
|
+
}
|
173
|
+
RUCY_END
|
174
|
+
|
175
|
+
static
|
176
|
+
RUCY_DEF1(mult, point)
|
177
|
+
{
|
178
|
+
CHECK;
|
179
|
+
|
180
|
+
Rays::Point p = *THIS;
|
181
|
+
p *= to<Rays::Point&>(point);
|
182
|
+
return value(p);
|
183
|
+
}
|
184
|
+
RUCY_END
|
185
|
+
|
186
|
+
static
|
187
|
+
RUCY_DEF1(div, point)
|
188
|
+
{
|
189
|
+
CHECK;
|
190
|
+
|
191
|
+
Rays::Point p = *THIS;
|
192
|
+
p /= to<Rays::Point&>(point);
|
193
|
+
return value(p);
|
194
|
+
}
|
195
|
+
RUCY_END
|
196
|
+
|
197
|
+
static
|
198
|
+
RUCY_DEF1(array_get, index)
|
199
|
+
{
|
200
|
+
CHECK;
|
201
|
+
|
202
|
+
int i = index.as_i();
|
203
|
+
if (i < 0 || 2 < i)
|
204
|
+
index_error(__FILE__, __LINE__);
|
205
|
+
|
206
|
+
return value((*THIS)[i]);
|
207
|
+
}
|
208
|
+
RUCY_END
|
209
|
+
|
210
|
+
static
|
211
|
+
RUCY_DEF2(array_set, index, value)
|
212
|
+
{
|
213
|
+
CHECK;
|
214
|
+
|
215
|
+
int i = index.as_i();
|
216
|
+
if (i < 0 || 2 < i)
|
217
|
+
index_error(__FILE__, __LINE__);
|
218
|
+
|
219
|
+
(*THIS)[i] = to<coord>(value);
|
220
|
+
return value;
|
221
|
+
}
|
222
|
+
RUCY_END
|
223
|
+
|
224
|
+
static
|
225
|
+
RUCY_DEF0(inspect)
|
226
|
+
{
|
227
|
+
CHECK;
|
228
|
+
return value(Xot::stringf("#<Rays::Point %s>", THIS->inspect().c_str()));
|
229
|
+
}
|
230
|
+
RUCY_END
|
159
231
|
|
160
232
|
void
|
161
233
|
Init_point ()
|
@@ -166,10 +238,81 @@ Init_point ()
|
|
166
238
|
cPoint.define_alloc_func(alloc);
|
167
239
|
cPoint.define_private_method("initialize", initialize);
|
168
240
|
cPoint.define_private_method("initialize_copy", initialize_copy);
|
241
|
+
cPoint.define_method("move_to!", move_to);
|
242
|
+
cPoint.define_method("move_by!", move_by);
|
169
243
|
cPoint.define_method("x=", set_x);
|
170
244
|
cPoint.define_method("x", get_x);
|
171
245
|
cPoint.define_method("y=", set_y);
|
172
246
|
cPoint.define_method("y", get_y);
|
173
247
|
cPoint.define_method("z=", set_z);
|
174
248
|
cPoint.define_method("z", get_z);
|
249
|
+
cPoint.define_method("op_add", add);
|
250
|
+
cPoint.define_method("op_sub", sub);
|
251
|
+
cPoint.define_method("op_mult", mult);
|
252
|
+
cPoint.define_method("op_div", div);
|
253
|
+
cPoint.define_method("[]", array_get);
|
254
|
+
cPoint.define_method("[]=", array_set);
|
255
|
+
cPoint.define_method("inspect", inspect);
|
175
256
|
}
|
257
|
+
|
258
|
+
|
259
|
+
namespace Rucy
|
260
|
+
{
|
261
|
+
|
262
|
+
|
263
|
+
template <> Rays::Point
|
264
|
+
value_to<Rays::Point> (Value value, bool convert)
|
265
|
+
{
|
266
|
+
if (convert)
|
267
|
+
{
|
268
|
+
size_t argc = 0;
|
269
|
+
Value* argv = NULL;
|
270
|
+
if (value.is_array())
|
271
|
+
{
|
272
|
+
argc = value.size();
|
273
|
+
argv = value.as_array();
|
274
|
+
}
|
275
|
+
else
|
276
|
+
{
|
277
|
+
argc = 1;
|
278
|
+
argv = &value;
|
279
|
+
}
|
280
|
+
|
281
|
+
if (argc < 1)
|
282
|
+
Rucy::argument_error(__FILE__, __LINE__);
|
283
|
+
|
284
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
285
|
+
value = argv[0];
|
286
|
+
else if (argv[0].is_i() || argv[0].is_f())
|
287
|
+
{
|
288
|
+
switch (argc)
|
289
|
+
{
|
290
|
+
#define V(i) argv[i].as_f(true)
|
291
|
+
case 1: return Rays::Point(V(0));
|
292
|
+
case 2: return Rays::Point(V(0), V(1));
|
293
|
+
case 3: return Rays::Point(V(0), V(1), V(2));
|
294
|
+
#undef V
|
295
|
+
default: Rucy::argument_error(__FILE__, __LINE__);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
return value_to<Rays::Point&>(value, convert);
|
301
|
+
}
|
302
|
+
|
303
|
+
|
304
|
+
}// Rucy
|
305
|
+
|
306
|
+
|
307
|
+
namespace Rays
|
308
|
+
{
|
309
|
+
|
310
|
+
|
311
|
+
Class
|
312
|
+
point_class ()
|
313
|
+
{
|
314
|
+
return cPoint;
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
}// Rays
|
data/ext/rays/rays.cpp
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#include <rucy.h>
|
2
|
-
#include
|
2
|
+
#include "rays/rays.h"
|
3
|
+
#include "rays/opengl.h"
|
3
4
|
#include "defs.h"
|
4
5
|
|
5
6
|
|
@@ -9,39 +10,29 @@ using namespace Rucy;
|
|
9
10
|
static Module mRays;
|
10
11
|
|
11
12
|
|
12
|
-
|
13
|
+
static
|
14
|
+
RUCY_DEF0(init)
|
13
15
|
{
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
{
|
19
|
-
return mRays;
|
20
|
-
}
|
21
|
-
|
22
|
-
|
23
|
-
}// Rays
|
24
|
-
|
16
|
+
Rays::init();
|
17
|
+
return self;
|
18
|
+
}
|
19
|
+
RUCY_END
|
25
20
|
|
26
21
|
static
|
27
|
-
|
22
|
+
RUCY_DEF0(fin)
|
28
23
|
{
|
29
|
-
|
30
|
-
rays_error("Rays::init() failed.");
|
31
|
-
|
24
|
+
Rays::fin();
|
32
25
|
return self;
|
33
26
|
}
|
34
|
-
|
27
|
+
RUCY_END
|
35
28
|
|
36
29
|
static
|
37
|
-
|
30
|
+
RUCY_DEF0(init_offscreen_context)
|
38
31
|
{
|
39
|
-
|
40
|
-
rays_error("Rays::fin() failed.");
|
41
|
-
|
32
|
+
Rays::init_offscreen_context();
|
42
33
|
return self;
|
43
34
|
}
|
44
|
-
|
35
|
+
RUCY_END
|
45
36
|
|
46
37
|
|
47
38
|
void
|
@@ -50,4 +41,19 @@ Init_rays ()
|
|
50
41
|
mRays = define_module("Rays");
|
51
42
|
mRays.define_singleton_method("init!", init);
|
52
43
|
mRays.define_singleton_method("fin!", fin);
|
44
|
+
mRays.define_singleton_method("init_offscreen_context", init_offscreen_context);
|
53
45
|
}
|
46
|
+
|
47
|
+
|
48
|
+
namespace Rays
|
49
|
+
{
|
50
|
+
|
51
|
+
|
52
|
+
Module
|
53
|
+
rays_module ()
|
54
|
+
{
|
55
|
+
return mRays;
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
}// Rays
|
data/ext/rays/shader.cpp
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#include "rays/ruby/shader.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <rucy.h>
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
using namespace Rucy;
|
9
|
+
|
10
|
+
|
11
|
+
static Class cShader;
|
12
|
+
|
13
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Shader, cShader)
|
14
|
+
|
15
|
+
#define THIS to<Rays::Shader*>(self)
|
16
|
+
|
17
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Shader, cShader, self)
|
18
|
+
|
19
|
+
|
20
|
+
static
|
21
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
22
|
+
{
|
23
|
+
return new_type<Rays::Shader>(klass);
|
24
|
+
}
|
25
|
+
RUCY_END
|
26
|
+
|
27
|
+
static
|
28
|
+
RUCY_DEF1(initialize, source)
|
29
|
+
{
|
30
|
+
RUCY_CHECK_OBJ(Rays::Shader, cShader, self);
|
31
|
+
|
32
|
+
if (!source.is_s())
|
33
|
+
argument_error(__FILE__, __LINE__);
|
34
|
+
|
35
|
+
*THIS = Rays::Shader(source.c_str());
|
36
|
+
return self;
|
37
|
+
}
|
38
|
+
RUCY_END
|
39
|
+
|
40
|
+
|
41
|
+
void
|
42
|
+
Init_shader ()
|
43
|
+
{
|
44
|
+
Module mRays = define_module("Rays");
|
45
|
+
|
46
|
+
cShader = mRays.define_class("Shader");
|
47
|
+
cShader.define_alloc_func(alloc);
|
48
|
+
cShader.define_private_method("initialize", initialize);
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
namespace Rays
|
53
|
+
{
|
54
|
+
|
55
|
+
|
56
|
+
Class
|
57
|
+
shader_class ()
|
58
|
+
{
|
59
|
+
return cShader;
|
60
|
+
}
|
61
|
+
|
62
|
+
|
63
|
+
}// Rays
|
data/ext/rays/texture.cpp
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
5
|
+
#include "rays/ruby/color_space.h"
|
6
|
+
#include "rays/ruby/bitmap.h"
|
6
7
|
#include "defs.h"
|
7
8
|
|
8
9
|
|
@@ -13,134 +14,105 @@ using Rays::coord;
|
|
13
14
|
|
14
15
|
static Class cTexture;
|
15
16
|
|
17
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Texture, cTexture)
|
16
18
|
|
17
|
-
|
18
|
-
{
|
19
|
+
#define THIS to<Rays::Texture*>(self)
|
19
20
|
|
20
|
-
|
21
|
-
Class
|
22
|
-
texture_class ()
|
23
|
-
{
|
24
|
-
return cTexture;
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
}// Rays
|
29
|
-
|
30
|
-
|
31
|
-
namespace Rucy
|
32
|
-
{
|
33
|
-
|
34
|
-
|
35
|
-
Value
|
36
|
-
value (const Rays::Texture& obj)
|
37
|
-
{
|
38
|
-
return new_type(cTexture, new Rays::Texture(obj));
|
39
|
-
}
|
40
|
-
|
41
|
-
Value
|
42
|
-
value (const Rays::Texture* obj)
|
43
|
-
{
|
44
|
-
return obj ? value(*obj) : nil();
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
}// Rucy
|
49
|
-
|
50
|
-
|
51
|
-
#define THIS to<Rays::Texture*>(self)
|
52
|
-
|
53
|
-
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Texture, cTexture)
|
21
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Texture, cTexture, self)
|
54
22
|
|
55
23
|
|
56
24
|
static
|
57
|
-
|
25
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
58
26
|
{
|
59
27
|
return new_type<Rays::Texture>(klass);
|
60
28
|
}
|
61
|
-
|
29
|
+
RUCY_END
|
62
30
|
|
63
31
|
static
|
64
|
-
|
32
|
+
RUCY_DEF4(setup, width, height, color_space, alpha_only)
|
65
33
|
{
|
66
|
-
RUCY_CHECK_OBJ(
|
34
|
+
RUCY_CHECK_OBJ(Rays::Texture, cTexture, self);
|
67
35
|
|
68
|
-
|
69
|
-
|
36
|
+
Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
|
37
|
+
if (!cs) argument_error(__FILE__, __LINE__);
|
70
38
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if (!bitmap)
|
75
|
-
argument_error("%s is not a Bitmap object.", argv[0].inspect().c_str());
|
76
|
-
|
77
|
-
*THIS = Rays::Texture(*bitmap, alphaonly);
|
39
|
+
*THIS = Rays::Texture(
|
40
|
+
to<int>(width), to<int>(height), *cs, to<bool>(alpha_only));
|
78
41
|
return self;
|
79
42
|
}
|
80
|
-
|
43
|
+
RUCY_END
|
81
44
|
|
82
45
|
static
|
83
|
-
|
46
|
+
RUCY_DEF0(width)
|
84
47
|
{
|
85
48
|
CHECK;
|
86
|
-
|
87
49
|
return value(THIS->width());
|
88
50
|
}
|
89
|
-
|
51
|
+
RUCY_END
|
90
52
|
|
91
53
|
static
|
92
|
-
|
54
|
+
RUCY_DEF0(height)
|
93
55
|
{
|
94
56
|
CHECK;
|
95
|
-
|
96
57
|
return value(THIS->height());
|
97
58
|
}
|
98
|
-
|
59
|
+
RUCY_END
|
99
60
|
|
100
61
|
static
|
101
|
-
|
62
|
+
RUCY_DEF0(color_space)
|
102
63
|
{
|
103
64
|
CHECK;
|
65
|
+
return value(THIS->color_space());
|
66
|
+
}
|
67
|
+
RUCY_END
|
104
68
|
|
105
|
-
|
69
|
+
static
|
70
|
+
RUCY_DEF0(alpha_only)
|
71
|
+
{
|
72
|
+
CHECK;
|
73
|
+
return value(THIS->alpha_only());
|
106
74
|
}
|
107
|
-
|
75
|
+
RUCY_END
|
108
76
|
|
109
77
|
static
|
110
|
-
|
78
|
+
RUCY_DEF1(s, x)
|
111
79
|
{
|
112
80
|
CHECK;
|
81
|
+
return value(THIS->s(x.as_f(true)));
|
82
|
+
}
|
83
|
+
RUCY_END
|
113
84
|
|
85
|
+
static
|
86
|
+
RUCY_DEF1(t, y)
|
87
|
+
{
|
88
|
+
CHECK;
|
114
89
|
return value(THIS->t(y.as_f(true)));
|
115
90
|
}
|
116
|
-
|
91
|
+
RUCY_END
|
117
92
|
|
118
93
|
static
|
119
|
-
|
94
|
+
RUCY_DEF0(s_max)
|
120
95
|
{
|
121
96
|
CHECK;
|
122
|
-
|
123
97
|
return value(THIS->s_max());
|
124
98
|
}
|
125
|
-
|
99
|
+
RUCY_END
|
126
100
|
|
127
101
|
static
|
128
|
-
|
102
|
+
RUCY_DEF0(t_max)
|
129
103
|
{
|
130
104
|
CHECK;
|
131
|
-
|
132
105
|
return value(THIS->t_max());
|
133
106
|
}
|
134
|
-
|
107
|
+
RUCY_END
|
135
108
|
|
136
109
|
static
|
137
|
-
|
110
|
+
RUCY_DEF0(to_bitmap)
|
138
111
|
{
|
139
112
|
CHECK;
|
140
|
-
|
141
|
-
return value(THIS->bitmap());
|
113
|
+
return value(Rays::Bitmap(*THIS));
|
142
114
|
}
|
143
|
-
|
115
|
+
RUCY_END
|
144
116
|
|
145
117
|
|
146
118
|
void
|
@@ -150,10 +122,28 @@ Init_texture ()
|
|
150
122
|
|
151
123
|
cTexture = mRays.define_class("Texture");
|
152
124
|
cTexture.define_alloc_func(alloc);
|
153
|
-
cTexture.define_private_method("
|
125
|
+
cTexture.define_private_method("setup", setup);
|
154
126
|
cTexture.define_method("width", width);
|
155
127
|
cTexture.define_method("height", height);
|
128
|
+
cTexture.define_method("color_space", color_space);
|
129
|
+
cTexture.define_method("alpha_only", alpha_only);
|
130
|
+
cTexture.define_method("s", s);
|
131
|
+
cTexture.define_method("t", t);
|
156
132
|
cTexture.define_method("s_max", s_max);
|
157
133
|
cTexture.define_method("t_max", t_max);
|
158
|
-
cTexture.define_method("
|
134
|
+
cTexture.define_method("to_bitmap", to_bitmap);
|
159
135
|
}
|
136
|
+
|
137
|
+
|
138
|
+
namespace Rays
|
139
|
+
{
|
140
|
+
|
141
|
+
|
142
|
+
Class
|
143
|
+
texture_class ()
|
144
|
+
{
|
145
|
+
return cTexture;
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
}// Rays
|