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/.doc/ext/rays/point.cpp
CHANGED
@@ -12,44 +12,11 @@ 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
|
@@ -61,12 +28,8 @@ VALUE alloc(VALUE klass)
|
|
61
28
|
static
|
62
29
|
VALUE initialize(VALUE self)
|
63
30
|
{
|
64
|
-
|
65
|
-
|
66
|
-
if (argc != 0 && argc != 1 && argc != 2 && argc != 3)
|
67
|
-
arg_count_error("Point#initialize", argc, 0, 1, 2, 3);
|
68
|
-
|
69
|
-
if (argc == 0) return self;
|
31
|
+
CHECK;
|
32
|
+
check_arg_count(__FILE__, __LINE__, "Point#initialize", argc, 0, 1, 2, 3);
|
70
33
|
|
71
34
|
switch (argc)
|
72
35
|
{
|
@@ -90,20 +53,54 @@ VALUE initialize(VALUE self)
|
|
90
53
|
static
|
91
54
|
VALUE initialize_copy(VALUE self, VALUE obj)
|
92
55
|
{
|
93
|
-
|
56
|
+
CHECK;
|
57
|
+
*THIS = to<Rays::Point&>(obj);
|
58
|
+
return self;
|
59
|
+
}
|
60
|
+
|
61
|
+
static
|
62
|
+
VALUE move_to(VALUE self)
|
63
|
+
{
|
64
|
+
CHECK;
|
65
|
+
check_arg_count(__FILE__, __LINE__, "Point#move_to", argc, 1, 2, 3);
|
94
66
|
|
95
|
-
|
96
|
-
|
67
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
68
|
+
THIS->move_to(to<Rays::Point&>(argv[0]));
|
69
|
+
else
|
70
|
+
{
|
71
|
+
const Rays::Point& p = *THIS;
|
72
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
|
73
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
74
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
75
|
+
THIS->move_to(x, y, z);
|
76
|
+
}
|
97
77
|
|
98
|
-
*THIS = *point;
|
99
78
|
return self;
|
100
79
|
}
|
101
80
|
|
102
81
|
static
|
103
|
-
VALUE
|
82
|
+
VALUE move_by(VALUE self)
|
104
83
|
{
|
105
84
|
CHECK;
|
85
|
+
check_arg_count(__FILE__, __LINE__, "Point#move_by", argc, 1, 2, 3);
|
86
|
+
|
87
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
88
|
+
THIS->move_by(to<Rays::Point&>(argv[0]));
|
89
|
+
else
|
90
|
+
{
|
91
|
+
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : 0;
|
92
|
+
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
93
|
+
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
94
|
+
THIS->move_by(x, y, z);
|
95
|
+
}
|
96
|
+
|
97
|
+
return self;
|
98
|
+
}
|
106
99
|
|
100
|
+
static
|
101
|
+
VALUE set_x(VALUE self, VALUE x)
|
102
|
+
{
|
103
|
+
CHECK;
|
107
104
|
return value(THIS->x = to<coord>(x));
|
108
105
|
}
|
109
106
|
|
@@ -111,7 +108,6 @@ static
|
|
111
108
|
VALUE get_x(VALUE self)
|
112
109
|
{
|
113
110
|
CHECK;
|
114
|
-
|
115
111
|
return value(THIS->x);
|
116
112
|
}
|
117
113
|
|
@@ -119,7 +115,6 @@ static
|
|
119
115
|
VALUE set_y(VALUE self, VALUE y)
|
120
116
|
{
|
121
117
|
CHECK;
|
122
|
-
|
123
118
|
return value(THIS->y = to<coord>(y));
|
124
119
|
}
|
125
120
|
|
@@ -127,7 +122,6 @@ static
|
|
127
122
|
VALUE get_y(VALUE self)
|
128
123
|
{
|
129
124
|
CHECK;
|
130
|
-
|
131
125
|
return value(THIS->y);
|
132
126
|
}
|
133
127
|
|
@@ -135,7 +129,6 @@ static
|
|
135
129
|
VALUE set_z(VALUE self, VALUE z)
|
136
130
|
{
|
137
131
|
CHECK;
|
138
|
-
|
139
132
|
return value(THIS->z = to<coord>(z));
|
140
133
|
}
|
141
134
|
|
@@ -143,10 +136,80 @@ static
|
|
143
136
|
VALUE get_z(VALUE self)
|
144
137
|
{
|
145
138
|
CHECK;
|
146
|
-
|
147
139
|
return value(THIS->z);
|
148
140
|
}
|
149
141
|
|
142
|
+
static
|
143
|
+
VALUE add(VALUE self, VALUE point)
|
144
|
+
{
|
145
|
+
CHECK;
|
146
|
+
|
147
|
+
Rays::Point p = *THIS;
|
148
|
+
p += to<Rays::Point&>(point);
|
149
|
+
return value(p);
|
150
|
+
}
|
151
|
+
|
152
|
+
static
|
153
|
+
VALUE sub(VALUE self, VALUE point)
|
154
|
+
{
|
155
|
+
CHECK;
|
156
|
+
|
157
|
+
Rays::Point p = *THIS;
|
158
|
+
p -= to<Rays::Point&>(point);
|
159
|
+
return value(p);
|
160
|
+
}
|
161
|
+
|
162
|
+
static
|
163
|
+
VALUE mult(VALUE self, VALUE point)
|
164
|
+
{
|
165
|
+
CHECK;
|
166
|
+
|
167
|
+
Rays::Point p = *THIS;
|
168
|
+
p *= to<Rays::Point&>(point);
|
169
|
+
return value(p);
|
170
|
+
}
|
171
|
+
|
172
|
+
static
|
173
|
+
VALUE div(VALUE self, VALUE point)
|
174
|
+
{
|
175
|
+
CHECK;
|
176
|
+
|
177
|
+
Rays::Point p = *THIS;
|
178
|
+
p /= to<Rays::Point&>(point);
|
179
|
+
return value(p);
|
180
|
+
}
|
181
|
+
|
182
|
+
static
|
183
|
+
VALUE array_get(VALUE self, VALUE index)
|
184
|
+
{
|
185
|
+
CHECK;
|
186
|
+
|
187
|
+
int i = index.as_i();
|
188
|
+
if (i < 0 || 2 < i)
|
189
|
+
index_error(__FILE__, __LINE__);
|
190
|
+
|
191
|
+
return value((*THIS)[i]);
|
192
|
+
}
|
193
|
+
|
194
|
+
static
|
195
|
+
VALUE array_set(VALUE self, VALUE index, VALUE value)
|
196
|
+
{
|
197
|
+
CHECK;
|
198
|
+
|
199
|
+
int i = index.as_i();
|
200
|
+
if (i < 0 || 2 < i)
|
201
|
+
index_error(__FILE__, __LINE__);
|
202
|
+
|
203
|
+
(*THIS)[i] = to<coord>(value);
|
204
|
+
return value;
|
205
|
+
}
|
206
|
+
|
207
|
+
static
|
208
|
+
VALUE inspect(VALUE self)
|
209
|
+
{
|
210
|
+
CHECK;
|
211
|
+
return value(Xot::stringf("#<Rays::Point %s>", THIS->inspect().c_str()));
|
212
|
+
}
|
150
213
|
|
151
214
|
void
|
152
215
|
Init_point ()
|
@@ -157,10 +220,81 @@ Init_point ()
|
|
157
220
|
rb_define_alloc_func(cPoint, alloc);
|
158
221
|
rb_define_private_method(cPoint, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
159
222
|
rb_define_private_method(cPoint, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
223
|
+
cPoint.define_method("move_to!", move_to);
|
224
|
+
cPoint.define_method("move_by!", move_by);
|
160
225
|
rb_define_method(cPoint, "x=", RUBY_METHOD_FUNC(set_x), 1);
|
161
226
|
rb_define_method(cPoint, "x", RUBY_METHOD_FUNC(get_x), 0);
|
162
227
|
rb_define_method(cPoint, "y=", RUBY_METHOD_FUNC(set_y), 1);
|
163
228
|
rb_define_method(cPoint, "y", RUBY_METHOD_FUNC(get_y), 0);
|
164
229
|
rb_define_method(cPoint, "z=", RUBY_METHOD_FUNC(set_z), 1);
|
165
230
|
rb_define_method(cPoint, "z", RUBY_METHOD_FUNC(get_z), 0);
|
231
|
+
rb_define_method(cPoint, "op_add", RUBY_METHOD_FUNC(add), 1);
|
232
|
+
rb_define_method(cPoint, "op_sub", RUBY_METHOD_FUNC(sub), 1);
|
233
|
+
rb_define_method(cPoint, "op_mult", RUBY_METHOD_FUNC(mult), 1);
|
234
|
+
rb_define_method(cPoint, "op_div", RUBY_METHOD_FUNC(div), 1);
|
235
|
+
cPoint.define_method("[]", array_get);
|
236
|
+
cPoint.define_method("[]=", array_set);
|
237
|
+
rb_define_method(cPoint, "inspect", RUBY_METHOD_FUNC(inspect), 0);
|
166
238
|
}
|
239
|
+
|
240
|
+
|
241
|
+
namespace Rucy
|
242
|
+
{
|
243
|
+
|
244
|
+
|
245
|
+
template <> Rays::Point
|
246
|
+
value_to<Rays::Point> (Value value, bool convert)
|
247
|
+
{
|
248
|
+
if (convert)
|
249
|
+
{
|
250
|
+
size_t argc = 0;
|
251
|
+
Value* argv = NULL;
|
252
|
+
if (value.is_array())
|
253
|
+
{
|
254
|
+
argc = value.size();
|
255
|
+
argv = value.as_array();
|
256
|
+
}
|
257
|
+
else
|
258
|
+
{
|
259
|
+
argc = 1;
|
260
|
+
argv = &value;
|
261
|
+
}
|
262
|
+
|
263
|
+
if (argc < 1)
|
264
|
+
Rucy::argument_error(__FILE__, __LINE__);
|
265
|
+
|
266
|
+
if (argv[0].is_kind_of(Rays::point_class()))
|
267
|
+
value = argv[0];
|
268
|
+
else if (argv[0].is_i() || argv[0].is_f())
|
269
|
+
{
|
270
|
+
switch (argc)
|
271
|
+
{
|
272
|
+
#define V(i) argv[i].as_f(true)
|
273
|
+
case 1: return Rays::Point(V(0));
|
274
|
+
case 2: return Rays::Point(V(0), V(1));
|
275
|
+
case 3: return Rays::Point(V(0), V(1), V(2));
|
276
|
+
#undef V
|
277
|
+
default: Rucy::argument_error(__FILE__, __LINE__);
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
return value_to<Rays::Point&>(value, convert);
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
}// Rucy
|
287
|
+
|
288
|
+
|
289
|
+
namespace Rays
|
290
|
+
{
|
291
|
+
|
292
|
+
|
293
|
+
Class
|
294
|
+
point_class ()
|
295
|
+
{
|
296
|
+
return cPoint;
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
}// Rays
|
data/.doc/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,35 +10,24 @@ using namespace Rucy;
|
|
9
10
|
static Module mRays;
|
10
11
|
|
11
12
|
|
12
|
-
namespace Rays
|
13
|
-
{
|
14
|
-
|
15
|
-
|
16
|
-
Module
|
17
|
-
rays_module ()
|
18
|
-
{
|
19
|
-
return mRays;
|
20
|
-
}
|
21
|
-
|
22
|
-
|
23
|
-
}// Rays
|
24
|
-
|
25
|
-
|
26
13
|
static
|
27
14
|
VALUE init(VALUE self)
|
28
15
|
{
|
29
|
-
|
30
|
-
rays_error("Rays::init() failed.");
|
31
|
-
|
16
|
+
Rays::init();
|
32
17
|
return self;
|
33
18
|
}
|
34
19
|
|
35
20
|
static
|
36
21
|
VALUE fin(VALUE self)
|
37
22
|
{
|
38
|
-
|
39
|
-
|
23
|
+
Rays::fin();
|
24
|
+
return self;
|
25
|
+
}
|
40
26
|
|
27
|
+
static
|
28
|
+
VALUE init_offscreen_context(VALUE self)
|
29
|
+
{
|
30
|
+
Rays::init_offscreen_context();
|
41
31
|
return self;
|
42
32
|
}
|
43
33
|
|
@@ -48,4 +38,19 @@ Init_rays ()
|
|
48
38
|
mRays = rb_define_module("Rays");
|
49
39
|
mRays.define_singleton_method("init!", init);
|
50
40
|
mRays.define_singleton_method("fin!", fin);
|
41
|
+
rb_define_singleton_method(mRays, "init_offscreen_context", RUBY_METHOD_FUNC(init_offscreen_context), 0);
|
51
42
|
}
|
43
|
+
|
44
|
+
|
45
|
+
namespace Rays
|
46
|
+
{
|
47
|
+
|
48
|
+
|
49
|
+
Module
|
50
|
+
rays_module ()
|
51
|
+
{
|
52
|
+
return mRays;
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
}// Rays
|
@@ -0,0 +1,61 @@
|
|
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
|
+
VALUE alloc(VALUE klass)
|
22
|
+
{
|
23
|
+
return new_type<Rays::Shader>(klass);
|
24
|
+
}
|
25
|
+
|
26
|
+
static
|
27
|
+
VALUE initialize(VALUE self, VALUE source)
|
28
|
+
{
|
29
|
+
RUCY_CHECK_OBJ(Rays::Shader, cShader, self);
|
30
|
+
|
31
|
+
if (!source.is_s())
|
32
|
+
argument_error(__FILE__, __LINE__);
|
33
|
+
|
34
|
+
*THIS = Rays::Shader(source.c_str());
|
35
|
+
return self;
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
void
|
40
|
+
Init_shader ()
|
41
|
+
{
|
42
|
+
Module mRays = rb_define_module("Rays");
|
43
|
+
|
44
|
+
cShader = rb_define_class_under(mRays, "Shader", rb_cObject);
|
45
|
+
rb_define_alloc_func(cShader, alloc);
|
46
|
+
rb_define_private_method(cShader, "initialize", RUBY_METHOD_FUNC(initialize), 1);
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
namespace Rays
|
51
|
+
{
|
52
|
+
|
53
|
+
|
54
|
+
Class
|
55
|
+
shader_class ()
|
56
|
+
{
|
57
|
+
return cShader;
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
}// Rays
|
data/.doc/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,44 +14,11 @@ 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
|
-
|
20
|
-
|
21
|
-
Class
|
22
|
-
texture_class ()
|
23
|
-
{
|
24
|
-
return cTexture;
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
}// Rays
|
29
|
-
|
30
|
-
|
31
|
-
namespace Rucy
|
32
|
-
{
|
19
|
+
#define THIS to<Rays::Texture*>(self)
|
33
20
|
|
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
|
@@ -60,20 +28,15 @@ VALUE alloc(VALUE klass)
|
|
60
28
|
}
|
61
29
|
|
62
30
|
static
|
63
|
-
VALUE
|
31
|
+
VALUE setup(VALUE self, VALUE width, VALUE height, VALUE color_space, VALUE alpha_only)
|
64
32
|
{
|
65
|
-
RUCY_CHECK_OBJ(
|
66
|
-
|
67
|
-
if (argc != 1 && argc != 2)
|
68
|
-
arg_count_error("Texture#initialize", argc, 1, 2);
|
33
|
+
RUCY_CHECK_OBJ(Rays::Texture, cTexture, self);
|
69
34
|
|
70
|
-
Rays::
|
71
|
-
|
35
|
+
Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
|
36
|
+
if (!cs) argument_error(__FILE__, __LINE__);
|
72
37
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
*THIS = Rays::Texture(*bitmap, alphaonly);
|
38
|
+
*THIS = Rays::Texture(
|
39
|
+
to<int>(width), to<int>(height), *cs, to<bool>(alpha_only));
|
77
40
|
return self;
|
78
41
|
}
|
79
42
|
|
@@ -81,7 +44,6 @@ static
|
|
81
44
|
VALUE width(VALUE self)
|
82
45
|
{
|
83
46
|
CHECK;
|
84
|
-
|
85
47
|
return value(THIS->width());
|
86
48
|
}
|
87
49
|
|
@@ -89,15 +51,27 @@ static
|
|
89
51
|
VALUE height(VALUE self)
|
90
52
|
{
|
91
53
|
CHECK;
|
92
|
-
|
93
54
|
return value(THIS->height());
|
94
55
|
}
|
95
56
|
|
96
57
|
static
|
97
|
-
VALUE
|
58
|
+
VALUE color_space(VALUE self)
|
59
|
+
{
|
60
|
+
CHECK;
|
61
|
+
return value(THIS->color_space());
|
62
|
+
}
|
63
|
+
|
64
|
+
static
|
65
|
+
VALUE alpha_only(VALUE self)
|
98
66
|
{
|
99
67
|
CHECK;
|
68
|
+
return value(THIS->alpha_only());
|
69
|
+
}
|
100
70
|
|
71
|
+
static
|
72
|
+
VALUE s(VALUE self, VALUE x)
|
73
|
+
{
|
74
|
+
CHECK;
|
101
75
|
return value(THIS->s(x.as_f(true)));
|
102
76
|
}
|
103
77
|
|
@@ -105,7 +79,6 @@ static
|
|
105
79
|
VALUE t(VALUE self, VALUE y)
|
106
80
|
{
|
107
81
|
CHECK;
|
108
|
-
|
109
82
|
return value(THIS->t(y.as_f(true)));
|
110
83
|
}
|
111
84
|
|
@@ -113,7 +86,6 @@ static
|
|
113
86
|
VALUE s_max(VALUE self)
|
114
87
|
{
|
115
88
|
CHECK;
|
116
|
-
|
117
89
|
return value(THIS->s_max());
|
118
90
|
}
|
119
91
|
|
@@ -121,16 +93,14 @@ static
|
|
121
93
|
VALUE t_max(VALUE self)
|
122
94
|
{
|
123
95
|
CHECK;
|
124
|
-
|
125
96
|
return value(THIS->t_max());
|
126
97
|
}
|
127
98
|
|
128
99
|
static
|
129
|
-
VALUE
|
100
|
+
VALUE to_bitmap(VALUE self)
|
130
101
|
{
|
131
102
|
CHECK;
|
132
|
-
|
133
|
-
return value(THIS->bitmap());
|
103
|
+
return value(Rays::Bitmap(*THIS));
|
134
104
|
}
|
135
105
|
|
136
106
|
|
@@ -141,10 +111,28 @@ Init_texture ()
|
|
141
111
|
|
142
112
|
cTexture = rb_define_class_under(mRays, "Texture", rb_cObject);
|
143
113
|
rb_define_alloc_func(cTexture, alloc);
|
144
|
-
rb_define_private_method(cTexture, "
|
114
|
+
rb_define_private_method(cTexture, "setup", RUBY_METHOD_FUNC(setup), 4);
|
145
115
|
rb_define_method(cTexture, "width", RUBY_METHOD_FUNC(width), 0);
|
146
116
|
rb_define_method(cTexture, "height", RUBY_METHOD_FUNC(height), 0);
|
117
|
+
rb_define_method(cTexture, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
118
|
+
rb_define_method(cTexture, "alpha_only", RUBY_METHOD_FUNC(alpha_only), 0);
|
119
|
+
rb_define_method(cTexture, "s", RUBY_METHOD_FUNC(s), 1);
|
120
|
+
rb_define_method(cTexture, "t", RUBY_METHOD_FUNC(t), 1);
|
147
121
|
rb_define_method(cTexture, "s_max", RUBY_METHOD_FUNC(s_max), 0);
|
148
122
|
rb_define_method(cTexture, "t_max", RUBY_METHOD_FUNC(t_max), 0);
|
149
|
-
rb_define_method(cTexture, "
|
123
|
+
rb_define_method(cTexture, "to_bitmap", RUBY_METHOD_FUNC(to_bitmap), 0);
|
150
124
|
}
|
125
|
+
|
126
|
+
|
127
|
+
namespace Rays
|
128
|
+
{
|
129
|
+
|
130
|
+
|
131
|
+
Class
|
132
|
+
texture_class ()
|
133
|
+
{
|
134
|
+
return cTexture;
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
}// Rays
|
data/{README → README.md}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
%w[../xot ../rucy .]
|
5
|
+
.map {|s| File.expand_path "../#{s}/lib", __FILE__}
|
6
|
+
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
6
7
|
|
7
8
|
require 'xot/rake'
|
8
9
|
require 'xot/module'
|
@@ -12,8 +13,8 @@ require 'rays/module'
|
|
12
13
|
include Xot::Rake
|
13
14
|
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
MODULES = [Xot, Rucy, Rays].map {|m| m.const_get :Module}
|
17
|
+
MODULE = MODULES.last
|
17
18
|
TESTS_ALONE = ['test/test_rays.rb']
|
18
19
|
|
19
20
|
|
@@ -22,4 +23,4 @@ task :default => :build
|
|
22
23
|
task :build => :ext
|
23
24
|
|
24
25
|
|
25
|
-
|
26
|
+
MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|