rays 0.1.28 → 0.1.30

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bitmap.cpp +1 -1
  3. data/.doc/ext/rays/bounds.cpp +1 -1
  4. data/.doc/ext/rays/camera.cpp +1 -1
  5. data/.doc/ext/rays/color.cpp +1 -1
  6. data/.doc/ext/rays/color_space.cpp +1 -1
  7. data/.doc/ext/rays/exception.cpp +45 -0
  8. data/.doc/ext/rays/font.cpp +1 -1
  9. data/.doc/ext/rays/image.cpp +1 -1
  10. data/.doc/ext/rays/matrix.cpp +1 -1
  11. data/.doc/ext/rays/native.cpp +35 -33
  12. data/.doc/ext/rays/noise.cpp +1 -1
  13. data/.doc/ext/rays/painter.cpp +1 -1
  14. data/.doc/ext/rays/point.cpp +1 -1
  15. data/.doc/ext/rays/polygon.cpp +1 -1
  16. data/.doc/ext/rays/polygon_line.cpp +1 -1
  17. data/.doc/ext/rays/polyline.cpp +1 -1
  18. data/.doc/ext/rays/shader.cpp +101 -7
  19. data/VERSION +1 -1
  20. data/ext/rays/bitmap.cpp +1 -1
  21. data/ext/rays/bounds.cpp +1 -1
  22. data/ext/rays/camera.cpp +1 -1
  23. data/ext/rays/color.cpp +1 -1
  24. data/ext/rays/color_space.cpp +1 -1
  25. data/ext/rays/defs.h +1 -0
  26. data/ext/rays/exception.cpp +45 -0
  27. data/ext/rays/extconf.rb +1 -1
  28. data/ext/rays/font.cpp +1 -1
  29. data/ext/rays/image.cpp +1 -1
  30. data/ext/rays/matrix.cpp +1 -1
  31. data/ext/rays/native.cpp +35 -33
  32. data/ext/rays/noise.cpp +1 -1
  33. data/ext/rays/painter.cpp +1 -1
  34. data/ext/rays/point.cpp +1 -1
  35. data/ext/rays/polygon.cpp +1 -1
  36. data/ext/rays/polygon_line.cpp +1 -1
  37. data/ext/rays/polyline.cpp +1 -1
  38. data/ext/rays/shader.cpp +102 -6
  39. data/include/rays/exception.h +11 -0
  40. data/include/rays/ruby/bitmap.h +0 -1
  41. data/include/rays/ruby/bounds.h +0 -2
  42. data/include/rays/ruby/camera.h +0 -1
  43. data/include/rays/ruby/color.h +0 -2
  44. data/include/rays/ruby/color_space.h +0 -1
  45. data/include/rays/ruby/defs.h +30 -0
  46. data/include/rays/ruby/exception.h +28 -0
  47. data/include/rays/ruby/font.h +0 -1
  48. data/include/rays/ruby/image.h +0 -1
  49. data/include/rays/ruby/matrix.h +0 -1
  50. data/include/rays/ruby/painter.h +0 -1
  51. data/include/rays/ruby/point.h +0 -2
  52. data/include/rays/ruby/polygon.h +0 -1
  53. data/include/rays/ruby/polyline.h +0 -1
  54. data/include/rays/ruby/rays.h +0 -1
  55. data/include/rays/ruby/shader.h +0 -1
  56. data/include/rays/ruby.h +2 -0
  57. data/include/rays/shader.h +48 -1
  58. data/lib/rays/painter.rb +6 -5
  59. data/lib/rays/point.rb +1 -0
  60. data/lib/rays/shader.rb +18 -5
  61. data/rays.gemspec +3 -3
  62. data/src/exception.cpp +13 -0
  63. data/src/image.cpp +6 -4
  64. data/src/opengl.cpp +20 -7
  65. data/src/opengl.h +5 -3
  66. data/src/osx/font.mm +0 -2
  67. data/src/osx/opengl.mm +17 -2
  68. data/src/painter.cpp +181 -148
  69. data/src/shader.cpp +333 -53
  70. data/src/shader.h +53 -14
  71. data/src/shader_program.cpp +53 -27
  72. data/src/shader_program.h +8 -1
  73. data/src/shader_source.cpp +2 -2
  74. data/src/texture.cpp +80 -63
  75. data/test/helper.rb +1 -1
  76. data/test/test_point.rb +6 -5
  77. data/test/test_rays.rb +2 -2
  78. data/test/test_shader.rb +151 -14
  79. metadata +12 -7
data/ext/rays/noise.cpp CHANGED
@@ -47,7 +47,7 @@ RUCY_END
47
47
 
48
48
 
49
49
  void
50
- Init_noise ()
50
+ Init_rays_noise ()
51
51
  {
52
52
  Module mRays = define_module("Rays");
53
53
  mRays.define_singleton_method("perlin", perlin);
data/ext/rays/painter.cpp CHANGED
@@ -656,7 +656,7 @@ RUCY_END
656
656
  static Class cPainter;
657
657
 
658
658
  void
659
- Init_painter ()
659
+ Init_rays_painter ()
660
660
  {
661
661
  Module mRays = define_module("Rays");
662
662
 
data/ext/rays/point.cpp CHANGED
@@ -272,7 +272,7 @@ RUCY_END
272
272
  static Class cPoint;
273
273
 
274
274
  void
275
- Init_point ()
275
+ Init_rays_point ()
276
276
  {
277
277
  Module mRays = define_module("Rays");
278
278
 
data/ext/rays/polygon.cpp CHANGED
@@ -249,7 +249,7 @@ RUCY_END
249
249
  static Class cPolygon;
250
250
 
251
251
  void
252
- Init_polygon ()
252
+ Init_rays_polygon ()
253
253
  {
254
254
  Module mRays = define_module("Rays");
255
255
 
@@ -42,7 +42,7 @@ RUCY_END
42
42
  static Class cPolygonLine;
43
43
 
44
44
  void
45
- Init_polygon_line ()
45
+ Init_rays_polygon_line ()
46
46
  {
47
47
  Module mRays = define_module("Rays");
48
48
  Class cPolygon = mRays.define_class("Polygon");
@@ -114,7 +114,7 @@ RUCY_END
114
114
  static Class cPolyline;
115
115
 
116
116
  void
117
- Init_polyline ()
117
+ Init_rays_polyline ()
118
118
  {
119
119
  Module mRays = define_module("Rays");
120
120
 
data/ext/rays/shader.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "rays/ruby/shader.h"
2
2
 
3
3
 
4
+ #include "rays/ruby/image.h"
4
5
  #include "defs.h"
5
6
 
6
7
 
@@ -18,12 +19,83 @@ RUCY_DEF_ALLOC(alloc, klass)
18
19
  }
19
20
  RUCY_END
20
21
 
22
+ static const char*
23
+ to_name (const Value& names, size_t index)
24
+ {
25
+ if (!names || !names.is_array() || index >= names.size())
26
+ return NULL;
27
+
28
+ const auto& name = names[index];
29
+ if (!name) return NULL;
30
+
31
+ return name.c_str();
32
+ }
33
+
34
+ static Rays::ShaderEnv::NameList
35
+ to_name_list (const Value& names, size_t index)
36
+ {
37
+ if (!names || !names.is_array() || index >= names.size())
38
+ return {};
39
+
40
+ const auto& name_or_array = names[index];
41
+ if (name_or_array.is_array())
42
+ {
43
+ Rays::ShaderEnv::NameList list;
44
+ for (size_t i = 0; i < name_or_array.size(); ++i)
45
+ list.emplace_back(name_or_array[i].c_str());
46
+ return list;
47
+ }
48
+ else if (name_or_array.is_s() || name_or_array.is_sym())
49
+ return {Xot::String(name_or_array.c_str())};
50
+ else
51
+ return {};
52
+ }
53
+
54
+ static std::shared_ptr<Rays::ShaderEnv>
55
+ make_env (const Value& names, const Value& ignore_no_uniform_location_error)
56
+ {
57
+ bool has_names = names && names.is_array() && !names.empty();
58
+ if (!has_names && !ignore_no_uniform_location_error)
59
+ return NULL;
60
+
61
+ uint flags = 0;
62
+ if (ignore_no_uniform_location_error)
63
+ flags |= Rays::ShaderEnv::IGNORE_NO_UNIFORM_LOCATION_ERROR;
64
+
65
+ return std::make_shared<Rays::ShaderEnv>(
66
+ to_name_list(names, 0),
67
+ to_name_list(names, 1),
68
+ to_name_list(names, 2),
69
+ to_name( names, 3),
70
+ to_name( names, 4),
71
+ to_name( names, 5),
72
+ to_name_list(names, 6),
73
+ to_name_list(names, 7),
74
+ to_name_list(names, 8),
75
+ to_name_list(names, 9),
76
+ to_name_list(names, 10),
77
+ to_name_list(names, 11),
78
+ flags);
79
+ }
80
+
21
81
  static
22
- RUCY_DEF1(setup, source)
82
+ RUCY_DEF4(setup,
83
+ fragment_shader_source, vertex_shader_source,
84
+ builtin_variable_names, ignore_no_uniform_location_error)
23
85
  {
24
86
  RUCY_CHECK_OBJ(Rays::Shader, self);
25
87
 
26
- *THIS = to<Rays::Shader>(source);
88
+ if (fragment_shader_source.is_nil())
89
+ argument_error(__FILE__, __LINE__);
90
+
91
+ const char* fs = fragment_shader_source.c_str();
92
+ const char* vs = vertex_shader_source ? vertex_shader_source.c_str() : NULL;
93
+
94
+ auto env = make_env(builtin_variable_names, ignore_no_uniform_location_error);
95
+ if (env)
96
+ *THIS = Rays::Shader(fs, vs, *env);
97
+ else
98
+ *THIS = Rays::Shader(fs, vs);
27
99
  }
28
100
  RUCY_END
29
101
 
@@ -33,9 +105,6 @@ RUCY_DEFN(set_uniform)
33
105
  CHECK;
34
106
  check_arg_count(__FILE__, __LINE__, "Painter#set_uniform", argc, 2, 3, 4, 5);
35
107
 
36
- #define Ai(n) (argv[n].as_i())
37
- #define Af(n) ((float) argv[n].as_f())
38
-
39
108
  const char* name = argv[0].c_str();
40
109
  if (argv[1].is_array())
41
110
  {
@@ -48,6 +117,9 @@ RUCY_DEFN(set_uniform)
48
117
  argv += 1;
49
118
  }
50
119
 
120
+ #define Ai(n) (argv[n].as_i())
121
+ #define Af(n) ((float) argv[n].as_f())
122
+
51
123
  if (argv[0].is_i())
52
124
  {
53
125
  switch (argc)
@@ -68,6 +140,8 @@ RUCY_DEFN(set_uniform)
68
140
  case 4: THIS->set_uniform(name, Af(0), Af(1), Af(2), Af(3)); break;
69
141
  }
70
142
  }
143
+ else if (argv[0].is_kind_of(Rays::image_class()))
144
+ THIS->set_uniform(name, to<Rays::Image&>(argv[0]));
71
145
  else
72
146
  argument_error(__FILE__, __LINE__);
73
147
 
@@ -78,11 +152,31 @@ RUCY_DEFN(set_uniform)
78
152
  }
79
153
  RUCY_END
80
154
 
155
+ static
156
+ RUCY_DEF0(get_vertex_shader_source)
157
+ {
158
+ CHECK;
159
+
160
+ const char* source = THIS->vertex_shader_source();
161
+ return source ? value(source) : nil();
162
+ }
163
+ RUCY_END
164
+
165
+ static
166
+ RUCY_DEF0(get_fragment_shader_source)
167
+ {
168
+ CHECK;
169
+
170
+ const char* source = THIS->fragment_shader_source();
171
+ return source ? value(source) : nil();
172
+ }
173
+ RUCY_END
174
+
81
175
 
82
176
  static Class cShader;
83
177
 
84
178
  void
85
- Init_shader ()
179
+ Init_rays_shader ()
86
180
  {
87
181
  Module mRays = define_module("Rays");
88
182
 
@@ -90,6 +184,8 @@ Init_shader ()
90
184
  cShader.define_alloc_func(alloc);
91
185
  cShader.define_private_method("setup", setup);
92
186
  cShader.define_private_method("set_uniform", set_uniform);
187
+ cShader.define_method( "vertex_shader_source", get_vertex_shader_source);
188
+ cShader.define_method("fragment_shader_source", get_fragment_shader_source);
93
189
  }
94
190
 
95
191
 
@@ -26,6 +26,13 @@ namespace Rays
26
26
  };
27
27
 
28
28
 
29
+ class ShaderError : public OpenGLError
30
+ {
31
+ typedef OpenGLError Super;
32
+ public: ShaderError (const char* str = NULL);
33
+ };
34
+
35
+
29
36
  namespace ErrorFunctions
30
37
  {
31
38
 
@@ -39,6 +46,10 @@ namespace Rays
39
46
  void opengl_error (
40
47
  const char* file, int line, const char* format = NULL, ...);
41
48
 
49
+ [[noreturn]]
50
+ void shader_error (
51
+ const char* file, int line, const char* format = NULL, ...);
52
+
42
53
  }// ErrorFunctions
43
54
 
44
55
 
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_BITMAP_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/bitmap.h>
@@ -4,10 +4,8 @@
4
4
  #define __RAYS_RUBY_BOUNDS_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
- #include <rucy/exception.h>
11
9
  #include <rays/bounds.h>
12
10
  #include <rays/ruby/point.h>
13
11
 
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_CAMERA_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/camera.h>
@@ -4,10 +4,8 @@
4
4
  #define __RAYS_RUBY_COLOR_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
- #include <rucy/exception.h>
11
9
  #include <rays/color.h>
12
10
 
13
11
 
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_COLOR_SPACE_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/color_space.h>
@@ -0,0 +1,30 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_DEFS_H__
4
+ #define __RAYS_RUBY_DEFS_H__
5
+
6
+
7
+ #include <rucy/extension.h>
8
+ #include <rays/ruby/exception.h>
9
+
10
+
11
+ #define RAYS_CATCH \
12
+ } \
13
+ catch (const Rays::ShaderError& e) \
14
+ { \
15
+ RUCY_RAISE(Rays::shader_error_class(), e.what()); \
16
+ } \
17
+ catch (const Rays::OpenGLError& e) \
18
+ { \
19
+ RUCY_RAISE(Rays::opengl_error_class(), e.what()); \
20
+ } \
21
+ catch (const Rays::RaysError& e) \
22
+ { \
23
+ RUCY_RAISE(Rays::rays_error_class(), e.what());
24
+
25
+ #define RUCY_END \
26
+ RAYS_CATCH \
27
+ RUCY_DEF_END
28
+
29
+
30
+ #endif//EOH
@@ -0,0 +1,28 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_RUBY_EXCEPTION_H__
4
+ #define __RAYS_RUBY_EXCEPTION_H__
5
+
6
+
7
+ #include <rucy/class.h>
8
+ #include <rays/exception.h>
9
+
10
+
11
+ namespace Rays
12
+ {
13
+
14
+
15
+ Rucy::Class rays_error_class ();
16
+ // class Rays::RaysError
17
+
18
+ Rucy::Class opengl_error_class ();
19
+ // class Rays::OpenGLError
20
+
21
+ Rucy::Class shader_error_class ();
22
+ // class Rays::ShaderError
23
+
24
+
25
+ }// Rays
26
+
27
+
28
+ #endif//EOH
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_FONT_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/font.h>
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_IMAGE_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/image.h>
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_MATRIX_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/matrix.h>
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_PAINTER_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/painter.h>
@@ -4,10 +4,8 @@
4
4
  #define __RAYS_RUBY_POINT_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
- #include <rucy/exception.h>
11
9
  #include <rays/point.h>
12
10
 
13
11
 
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_POLYGON_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/polygon.h>
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_POLYLINE_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/polyline.h>
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_RAYS_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/module.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/rays.h>
@@ -4,7 +4,6 @@
4
4
  #define __RAYS_RUBY_SHADER_H__
5
5
 
6
6
 
7
- #include <rucy/rucy.h>
8
7
  #include <rucy/class.h>
9
8
  #include <rucy/extension.h>
10
9
  #include <rays/shader.h>
data/include/rays/ruby.h CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
 
7
7
  #include <rays/ruby/rays.h>
8
+ #include <rays/ruby/defs.h>
9
+ #include <rays/ruby/exception.h>
8
10
 
9
11
  #include <rays/ruby/point.h>
10
12
  #include <rays/ruby/bounds.h>
@@ -4,6 +4,7 @@
4
4
  #define __RAYS_SHADER_H__
5
5
 
6
6
 
7
+ #include <vector>
7
8
  #include <xot/pimpl.h>
8
9
  #include <rays/defs.h>
9
10
  #include <rays/coord.h>
@@ -14,6 +15,7 @@ namespace Rays
14
15
 
15
16
 
16
17
  class Image;
18
+ class ShaderEnv;
17
19
 
18
20
 
19
21
  class Shader
@@ -23,7 +25,14 @@ namespace Rays
23
25
 
24
26
  public:
25
27
 
26
- Shader (const char* source = NULL);
28
+ Shader (
29
+ const char* fragment_shader_source = NULL,
30
+ const char* vertex_shader_source = NULL);
31
+
32
+ Shader (
33
+ const char* fragment_shader_source,
34
+ const char* vertex_shader_source,
35
+ ShaderEnv env);
27
36
 
28
37
  ~Shader ();
29
38
 
@@ -55,6 +64,10 @@ namespace Rays
55
64
 
56
65
  void set_uniform (const char* name, const Image& texture);
57
66
 
67
+ const char* vertex_shader_source () const;
68
+
69
+ const char* fragment_shader_source () const;
70
+
58
71
  operator bool () const;
59
72
 
60
73
  bool operator ! () const;
@@ -70,6 +83,40 @@ namespace Rays
70
83
  };// Shader
71
84
 
72
85
 
86
+ class ShaderEnv
87
+ {
88
+
89
+ public:
90
+
91
+ typedef std::vector<String> NameList;
92
+
93
+ enum Flags
94
+ {
95
+ IGNORE_NO_UNIFORM_LOCATION_ERROR = 0x1 << 0,
96
+ };
97
+
98
+ ShaderEnv (
99
+ const NameList& attribute_position_names = {},
100
+ const NameList& attribute_texcoord_names = {},
101
+ const NameList& attribute_color_names = {},
102
+ const char* varying_position_name = NULL,
103
+ const char* varying_texcoord_name = NULL,
104
+ const char* varying_color_name = NULL,
105
+ const NameList& uniform_position_matrix_names = {},
106
+ const NameList& uniform_texcoord_matrix_names = {},
107
+ const NameList& uniform_texcoord_min_names = {},
108
+ const NameList& uniform_texcoord_max_names = {},
109
+ const NameList& uniform_texcoord_offset_names = {},
110
+ const NameList& uniform_texture_names = {},
111
+ uint flags = 0);
112
+
113
+ struct Data;
114
+
115
+ Xot::PSharedImpl<Data> self;
116
+
117
+ };// ShaderEnv
118
+
119
+
73
120
  }// Rays
74
121
 
75
122
 
data/lib/rays/painter.rb CHANGED
@@ -27,15 +27,15 @@ module Rays
27
27
  if block
28
28
  attributes.each do |key, value|
29
29
  attributes[key] = __send__ key
30
- __send__ key, *value
30
+ __send__ key, *(value.nil? ? [nil] : value)
31
31
  end
32
-
33
32
  Xot::BlockUtil.instance_eval_or_block_call self, &block
34
-
33
+ end
34
+ ensure
35
+ if block
35
36
  attributes.each do |key, value|
36
- __send__ key, *value
37
+ __send__ key, *(value.nil? ? [nil] : value)
37
38
  end
38
-
39
39
  pop(*types)
40
40
  end
41
41
  end
@@ -92,6 +92,7 @@ module Rays
92
92
  end
93
93
 
94
94
  def shader=(shader, **uniforms)
95
+ shader = Shader.new shader if shader.is_a?(String)
95
96
  shader.uniform(**uniforms) if shader && !uniforms.empty?
96
97
  set_shader shader
97
98
  end
data/lib/rays/point.rb CHANGED
@@ -33,6 +33,7 @@ module Rays
33
33
  when 1 then [x]
34
34
  when 2 then [x, y]
35
35
  when 3 then [x, y, z]
36
+ when 4 then [x, y, z, 1.0]
36
37
  else raise ArgumentError
37
38
  end
38
39
  end
data/lib/rays/shader.rb CHANGED
@@ -10,11 +10,24 @@ module Rays
10
10
 
11
11
  class Shader
12
12
 
13
- def initialize(source = nil, **uniforms, &block)
14
- if source
15
- setup source
16
- uniform(**uniforms) unless uniforms.empty?
17
- end
13
+ def initialize(
14
+ fragment_shader_source,
15
+ vertex_shader_source = nil,
16
+ builtin_variable_names = nil,
17
+ ignore_no_uniform_location_error: false,
18
+ **uniforms, &block)
19
+
20
+ setup(
21
+ fragment_shader_source, vertex_shader_source,
22
+ builtin_variable_names&.values_at(
23
+ :attribute_position, :attribute_texcoord, :attribute_color,
24
+ :varying_position, :varying_texcoord, :varying_color,
25
+ :uniform_position_matrix, :uniform_texcoord_matrix,
26
+ :uniform_texcoord_min, :uniform_texcoord_max, :uniform_texcoord_offset,
27
+ :uniform_texture),
28
+ ignore_no_uniform_location_error)
29
+
30
+ uniform(**uniforms) unless uniforms.empty?
18
31
 
19
32
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
20
33
  end
data/rays.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
 
3
3
 
4
- File.expand_path('../lib', __FILE__)
4
+ File.expand_path('lib', __dir__)
5
5
  .tap {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
6
 
7
7
  require 'rays/module'
@@ -28,8 +28,8 @@ Gem::Specification.new do |s|
28
28
  s.platform = Gem::Platform::RUBY
29
29
  s.required_ruby_version = '>= 2.6.0'
30
30
 
31
- s.add_runtime_dependency 'xot', '~> 0.1.28'
32
- s.add_runtime_dependency 'rucy', '~> 0.1.28'
31
+ s.add_runtime_dependency 'xot', '~> 0.1.30'
32
+ s.add_runtime_dependency 'rucy', '~> 0.1.30'
33
33
 
34
34
  s.files = `git ls-files`.split $/
35
35
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/src/exception.cpp CHANGED
@@ -20,6 +20,12 @@ namespace Rays
20
20
  }
21
21
 
22
22
 
23
+ ShaderError::ShaderError (const char* str)
24
+ : Super(str)
25
+ {
26
+ }
27
+
28
+
23
29
  namespace ErrorFunctions
24
30
  {
25
31
 
@@ -37,6 +43,13 @@ namespace Rays
37
43
  throw OpenGLError(Xot::error_text(file, line, s));
38
44
  }
39
45
 
46
+ void
47
+ shader_error (const char* file, int line, const char* format, ...)
48
+ {
49
+ XOT_STRINGF(format, s);
50
+ throw ShaderError(Xot::error_text(file, line, s));
51
+ }
52
+
40
53
  }// ErrorFunctions
41
54
 
42
55
 
data/src/image.cpp CHANGED
@@ -58,9 +58,11 @@ namespace Rays
58
58
  }
59
59
 
60
60
  static Bitmap&
61
- get_bitmap (Image& image)
61
+ get_bitmap (Image* image)
62
62
  {
63
- Image::Data* self = image.self.get();
63
+ assert(image);
64
+
65
+ Image::Data* self = image->self.get();
64
66
 
65
67
  if (!image)
66
68
  {
@@ -230,13 +232,13 @@ namespace Rays
230
232
  Bitmap&
231
233
  Image::bitmap ()
232
234
  {
233
- return get_bitmap(*this);
235
+ return get_bitmap(this);
234
236
  }
235
237
 
236
238
  const Bitmap&
237
239
  Image::bitmap () const
238
240
  {
239
- return get_bitmap(const_cast<Image&>(*this));
241
+ return get_bitmap(const_cast<Image*>(this));
240
242
  }
241
243
 
242
244
  Image::operator bool () const