rays 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.doc/ext/rays/bitmap.cpp +70 -233
  3. data/.doc/ext/rays/bounds.cpp +339 -57
  4. data/.doc/ext/rays/color.cpp +58 -48
  5. data/.doc/ext/rays/color_space.cpp +174 -0
  6. data/.doc/ext/rays/font.cpp +31 -53
  7. data/.doc/ext/rays/image.cpp +64 -67
  8. data/.doc/ext/rays/matrix.cpp +22 -50
  9. data/.doc/ext/rays/native.cpp +9 -2
  10. data/.doc/ext/rays/painter.cpp +276 -259
  11. data/.doc/ext/rays/point.cpp +186 -52
  12. data/.doc/ext/rays/rays.cpp +25 -20
  13. data/.doc/ext/rays/shader.cpp +61 -0
  14. data/.doc/ext/rays/texture.cpp +47 -59
  15. data/{README → README.md} +0 -0
  16. data/Rakefile +6 -5
  17. data/VERSION +1 -1
  18. data/ext/rays/bitmap.cpp +88 -248
  19. data/ext/rays/bounds.cpp +437 -141
  20. data/ext/rays/color.cpp +79 -69
  21. data/ext/rays/color_space.cpp +185 -0
  22. data/ext/rays/extconf.rb +14 -63
  23. data/ext/rays/font.cpp +44 -65
  24. data/ext/rays/image.cpp +82 -81
  25. data/ext/rays/matrix.cpp +32 -60
  26. data/ext/rays/native.cpp +9 -2
  27. data/ext/rays/painter.cpp +345 -321
  28. data/ext/rays/point.cpp +212 -69
  29. data/ext/rays/rays.cpp +29 -23
  30. data/ext/rays/shader.cpp +63 -0
  31. data/ext/rays/texture.cpp +64 -74
  32. data/include/rays/bitmap.h +21 -12
  33. data/include/rays/bounds.h +67 -9
  34. data/include/rays/color.h +23 -7
  35. data/include/rays/{colorspace.h → color_space.h} +6 -3
  36. data/include/rays/exception.h +17 -11
  37. data/include/rays/font.h +4 -3
  38. data/include/rays/image.h +11 -6
  39. data/include/rays/matrix.h +15 -12
  40. data/include/rays/opengl.h +54 -1
  41. data/include/rays/painter.h +98 -108
  42. data/include/rays/point.h +45 -5
  43. data/include/rays/rays.h +2 -2
  44. data/include/rays/ruby/bitmap.h +2 -16
  45. data/include/rays/ruby/bounds.h +4 -16
  46. data/include/rays/ruby/color.h +3 -16
  47. data/include/rays/ruby/color_space.h +27 -0
  48. data/include/rays/ruby/font.h +2 -16
  49. data/include/rays/ruby/image.h +2 -16
  50. data/include/rays/ruby/matrix.h +2 -16
  51. data/include/rays/ruby/painter.h +2 -16
  52. data/include/rays/ruby/point.h +3 -16
  53. data/include/rays/ruby/shader.h +27 -0
  54. data/include/rays/ruby/texture.h +2 -16
  55. data/include/rays/ruby.h +1 -0
  56. data/include/rays/shader.h +48 -0
  57. data/include/rays/texture.h +13 -2
  58. data/include/rays.h +2 -1
  59. data/lib/rays/bitmap.rb +20 -11
  60. data/lib/rays/bounds.rb +29 -68
  61. data/lib/rays/color.rb +39 -0
  62. data/lib/rays/color_space.rb +33 -0
  63. data/lib/rays/font.rb +29 -0
  64. data/lib/rays/image.rb +22 -0
  65. data/lib/rays/module.rb +11 -7
  66. data/lib/rays/painter.rb +103 -40
  67. data/lib/rays/point.rb +19 -36
  68. data/lib/rays/shader.rb +13 -0
  69. data/lib/rays/texture.rb +9 -0
  70. data/lib/rays.rb +4 -0
  71. data/rays.gemspec +3 -4
  72. data/src/bounds.cpp +272 -63
  73. data/src/color.cpp +168 -21
  74. data/src/{colorspace.cpp → color_space.cpp} +38 -1
  75. data/src/exception.cpp +24 -15
  76. data/src/frame_buffer.cpp +275 -0
  77. data/src/frame_buffer.h +79 -0
  78. data/src/image.cpp +80 -36
  79. data/src/ios/bitmap.mm +340 -0
  80. data/src/ios/font.mm +206 -0
  81. data/src/{cocoa → ios}/helper.h +2 -2
  82. data/src/{cocoa → ios}/helper.mm +0 -0
  83. data/src/ios/opengl.mm +21 -0
  84. data/src/ios/program.cpp +122 -0
  85. data/src/{cocoa → ios}/rays.mm +8 -7
  86. data/src/matrix.cpp +10 -22
  87. data/src/opengl.cpp +64 -0
  88. data/src/{cocoa → osx}/bitmap.mm +121 -70
  89. data/src/{cocoa → osx}/font.mm +32 -24
  90. data/src/osx/helper.h +26 -0
  91. data/src/osx/helper.mm +25 -0
  92. data/src/osx/opengl.mm +103 -0
  93. data/src/osx/rays.mm +43 -0
  94. data/src/painter.cpp +596 -422
  95. data/src/point.cpp +154 -11
  96. data/src/program.cpp +513 -0
  97. data/src/program.h +73 -0
  98. data/src/render_buffer.cpp +120 -0
  99. data/src/render_buffer.h +47 -0
  100. data/src/shader.cpp +117 -0
  101. data/src/texture.cpp +104 -134
  102. data/test/helper.rb +10 -3
  103. data/test/test_bitmap.rb +18 -0
  104. data/test/test_bounds.rb +81 -35
  105. data/test/test_color.rb +29 -2
  106. data/test/test_image.rb +63 -0
  107. data/test/test_painter.rb +120 -0
  108. data/test/test_point.rb +30 -9
  109. data/test/test_shader.rb +37 -0
  110. data/test/test_texture.rb +18 -0
  111. metadata +75 -58
  112. data/.gitignore +0 -14
  113. data/ChangeLog +0 -8
@@ -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
- namespace Rays
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
- RUCY_CHECK_OBJ(self, Rays::Point, cPoint);
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
- RUCY_CHECK_OBJ(self, Rays::Point, cPoint);
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
- Rays::Point* point = to<Rays::Point*>(obj);
96
- if (!point) argument_error();
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 set_x(VALUE self, VALUE x)
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
@@ -1,5 +1,6 @@
1
1
  #include <rucy.h>
2
- #include <rays/rays.h>
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
- if (!Rays::init())
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
- if (!Rays::fin())
39
- rays_error("Rays::fin() failed.");
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
@@ -2,7 +2,8 @@
2
2
 
3
3
 
4
4
  #include <rucy.h>
5
- #include <rays/ruby/bitmap.h>
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
- namespace Rays
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 initialize(VALUE self)
31
+ VALUE setup(VALUE self, VALUE width, VALUE height, VALUE color_space, VALUE alpha_only)
64
32
  {
65
- RUCY_CHECK_OBJ(self, Rays::Texture, cTexture);
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::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
71
- bool alphaonly = (argc == 2) ? to<bool>(argv[1]) : false;
35
+ Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
36
+ if (!cs) argument_error(__FILE__, __LINE__);
72
37
 
73
- if (!bitmap)
74
- argument_error("%s is not a Bitmap object.", argv[0].inspect().c_str());
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 s(VALUE self, VALUE x)
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 bitmap(VALUE self)
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, "initialize", RUBY_METHOD_FUNC(initialize), -1);
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, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
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
File without changes
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
 
4
- require 'xot/load_path'
5
- Xot::LoadPath.unshift File.expand_path('../lib', __FILE__)
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
- MODULE = Rays
16
- INCDIRS = [Rays, Rucy, Xot].map {|m| m.include_dirs}.flatten
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
- [Xot, Rucy, Rays].each {|m| m.load_tasks}
26
+ MODULES.each {|m| m.load_tasks :lib, :ext, :test, :doc, :gem}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7