rays 0.1.11 → 0.1.16

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