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
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
- 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
56
- RUBY_DEF_ALLOC(alloc, klass)
23
+ RUCY_DEF_ALLOC(alloc, klass)
57
24
  {
58
25
  return new_type<Rays::Point>(klass);
59
26
  }
60
- RUBY_END
27
+ RUCY_END
61
28
 
62
29
  static
63
- RUBY_DEFN(initialize)
30
+ RUCY_DEFN(initialize)
64
31
  {
65
- RUCY_CHECK_OBJ(self, Rays::Point, cPoint);
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
- RUBY_END
53
+ RUCY_END
91
54
 
92
55
  static
93
- RUBY_DEF1(initialize_copy, obj)
56
+ RUCY_DEF1(initialize_copy, obj)
94
57
  {
95
- RUCY_CHECK_OBJ(self, Rays::Point, cPoint);
58
+ CHECK;
59
+ *THIS = to<Rays::Point&>(obj);
60
+ return self;
61
+ }
62
+ RUCY_END
96
63
 
97
- Rays::Point* point = to<Rays::Point*>(obj);
98
- if (!point) argument_error();
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
- RUBY_END
83
+ RUCY_END
104
84
 
105
85
  static
106
- RUBY_DEF1(set_x, x)
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
- return value(THIS->x = to<coord>(x));
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
- RUBY_END
103
+ RUCY_END
113
104
 
114
105
  static
115
- RUBY_DEF0(get_x)
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
- RUBY_END
119
+ RUCY_END
122
120
 
123
121
  static
124
- RUBY_DEF1(set_y, y)
122
+ RUCY_DEF1(set_y, y)
125
123
  {
126
124
  CHECK;
127
-
128
125
  return value(THIS->y = to<coord>(y));
129
126
  }
130
- RUBY_END
127
+ RUCY_END
131
128
 
132
129
  static
133
- RUBY_DEF0(get_y)
130
+ RUCY_DEF0(get_y)
134
131
  {
135
132
  CHECK;
136
-
137
133
  return value(THIS->y);
138
134
  }
139
- RUBY_END
135
+ RUCY_END
140
136
 
141
137
  static
142
- RUBY_DEF1(set_z, z)
138
+ RUCY_DEF1(set_z, z)
143
139
  {
144
140
  CHECK;
145
-
146
141
  return value(THIS->z = to<coord>(z));
147
142
  }
148
- RUBY_END
143
+ RUCY_END
149
144
 
150
145
  static
151
- RUBY_DEF0(get_z)
146
+ RUCY_DEF0(get_z)
152
147
  {
153
148
  CHECK;
154
-
155
149
  return value(THIS->z);
156
150
  }
157
- RUBY_END
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 <rays/rays.h>
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
- namespace Rays
13
+ static
14
+ RUCY_DEF0(init)
13
15
  {
14
-
15
-
16
- Module
17
- rays_module ()
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
- RUBY_DEF0(init)
22
+ RUCY_DEF0(fin)
28
23
  {
29
- if (!Rays::init())
30
- rays_error("Rays::init() failed.");
31
-
24
+ Rays::fin();
32
25
  return self;
33
26
  }
34
- RUBY_END
27
+ RUCY_END
35
28
 
36
29
  static
37
- RUBY_DEF0(fin)
30
+ RUCY_DEF0(init_offscreen_context)
38
31
  {
39
- if (!Rays::fin())
40
- rays_error("Rays::fin() failed.");
41
-
32
+ Rays::init_offscreen_context();
42
33
  return self;
43
34
  }
44
- RUBY_END
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
@@ -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 <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,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
- namespace Rays
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
- RUBY_DEF_ALLOC(alloc, klass)
25
+ RUCY_DEF_ALLOC(alloc, klass)
58
26
  {
59
27
  return new_type<Rays::Texture>(klass);
60
28
  }
61
- RUBY_END
29
+ RUCY_END
62
30
 
63
31
  static
64
- RUBY_DEFN(initialize)
32
+ RUCY_DEF4(setup, width, height, color_space, alpha_only)
65
33
  {
66
- RUCY_CHECK_OBJ(self, Rays::Texture, cTexture);
34
+ RUCY_CHECK_OBJ(Rays::Texture, cTexture, self);
67
35
 
68
- if (argc != 1 && argc != 2)
69
- arg_count_error("Texture#initialize", argc, 1, 2);
36
+ Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
37
+ if (!cs) argument_error(__FILE__, __LINE__);
70
38
 
71
- Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
72
- bool alphaonly = (argc == 2) ? to<bool>(argv[1]) : false;
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
- RUBY_END
43
+ RUCY_END
81
44
 
82
45
  static
83
- RUBY_DEF0(width)
46
+ RUCY_DEF0(width)
84
47
  {
85
48
  CHECK;
86
-
87
49
  return value(THIS->width());
88
50
  }
89
- RUBY_END
51
+ RUCY_END
90
52
 
91
53
  static
92
- RUBY_DEF0(height)
54
+ RUCY_DEF0(height)
93
55
  {
94
56
  CHECK;
95
-
96
57
  return value(THIS->height());
97
58
  }
98
- RUBY_END
59
+ RUCY_END
99
60
 
100
61
  static
101
- RUBY_DEF1(s, x)
62
+ RUCY_DEF0(color_space)
102
63
  {
103
64
  CHECK;
65
+ return value(THIS->color_space());
66
+ }
67
+ RUCY_END
104
68
 
105
- return value(THIS->s(x.as_f(true)));
69
+ static
70
+ RUCY_DEF0(alpha_only)
71
+ {
72
+ CHECK;
73
+ return value(THIS->alpha_only());
106
74
  }
107
- RUBY_END
75
+ RUCY_END
108
76
 
109
77
  static
110
- RUBY_DEF1(t, y)
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
- RUBY_END
91
+ RUCY_END
117
92
 
118
93
  static
119
- RUBY_DEF0(s_max)
94
+ RUCY_DEF0(s_max)
120
95
  {
121
96
  CHECK;
122
-
123
97
  return value(THIS->s_max());
124
98
  }
125
- RUBY_END
99
+ RUCY_END
126
100
 
127
101
  static
128
- RUBY_DEF0(t_max)
102
+ RUCY_DEF0(t_max)
129
103
  {
130
104
  CHECK;
131
-
132
105
  return value(THIS->t_max());
133
106
  }
134
- RUBY_END
107
+ RUCY_END
135
108
 
136
109
  static
137
- RUBY_DEF0(bitmap)
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
- RUBY_END
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("initialize", initialize);
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("bitmap", bitmap);
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