rays 0.3 → 0.3.1

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.
data/ext/rays/point.cpp CHANGED
@@ -47,7 +47,7 @@ RUCY_DEFN(move_to)
47
47
  CHECK;
48
48
  check_arg_count(__FILE__, __LINE__, "Point#move_to", argc, 1, 2, 3);
49
49
 
50
- if (argv[0].is_kind_of(Rays::point_class()))
50
+ if (argv[0].is_a(Rays::point_class()))
51
51
  THIS->move_to(to<Rays::Point&>(argv[0]));
52
52
  else
53
53
  {
@@ -68,7 +68,7 @@ RUCY_DEFN(move_by)
68
68
  CHECK;
69
69
  check_arg_count(__FILE__, __LINE__, "Point#move_by", argc, 1, 2, 3);
70
70
 
71
- if (argv[0].is_kind_of(Rays::point_class()))
71
+ if (argv[0].is_a(Rays::point_class()))
72
72
  THIS->move_by(to<Rays::Point&>(argv[0]));
73
73
  else
74
74
  {
@@ -224,7 +224,9 @@ RUCY_DEF2(set_at, index, value)
224
224
  CHECK;
225
225
 
226
226
  int i = index.as_i();
227
- if (i < 0 || 2 < i)
227
+ if (i < 0)
228
+ index_error(__FILE__, __LINE__);
229
+ if (i > 2)
228
230
  index_error(__FILE__, __LINE__);
229
231
 
230
232
  (*THIS)[i] = to<coord>(value);
@@ -238,7 +240,9 @@ RUCY_DEF1(get_at, index)
238
240
  CHECK;
239
241
 
240
242
  int i = index.as_i();
241
- if (i < 0 || 2 < i)
243
+ if (i < 0)
244
+ index_error(__FILE__, __LINE__);
245
+ if (i > 2)
242
246
  index_error(__FILE__, __LINE__);
243
247
 
244
248
  return value((*THIS)[i]);
data/ext/rays/polygon.cpp CHANGED
@@ -27,7 +27,7 @@ RUCY_DEF4(setup, args, loop, colors, texcoords)
27
27
  {
28
28
  CHECK;
29
29
 
30
- if (args[0].is_kind_of(Rays::polyline_class()))
30
+ if (args[0].is_a(Rays::polyline_class()))
31
31
  *THIS = to<Rays::Polygon>(args.size(), args.as_array());
32
32
  else
33
33
  {
@@ -89,7 +89,9 @@ RUCY_DEF1(get_at, index)
89
89
  int i = to<int>(index);
90
90
  if (i < 0) i += size;
91
91
 
92
- if (i < 0 || size <= i)
92
+ if (i < 0)
93
+ index_error(__FILE__, __LINE__);
94
+ if (i >= size)
93
95
  index_error(__FILE__, __LINE__);
94
96
 
95
97
  return value((*THIS)[i]);
@@ -124,10 +126,10 @@ RUCY_DEF1(op_add, obj)
124
126
  {
125
127
  CHECK;
126
128
 
127
- if (obj.is_kind_of(Rays::polyline_class()))
129
+ if (obj.is_a(Rays::polyline_class()))
128
130
  return value(*THIS + to<Rays::Polyline&>(obj));
129
131
 
130
- if (obj.is_kind_of(Rays::polygon_class()))
132
+ if (obj.is_a(Rays::polygon_class()))
131
133
  return value(*THIS + to<Rays::Polygon&>(obj));
132
134
 
133
135
  if (!obj.is_array())
@@ -139,7 +141,7 @@ RUCY_DEF1(op_add, obj)
139
141
  for (const auto& polyline : to<Rays::Polygon&>(self))
140
142
  polylines.emplace_back(polyline);
141
143
 
142
- if (obj[0].is_kind_of(Rays::polyline_class()))
144
+ if (obj[0].is_a(Rays::polyline_class()))
143
145
  {
144
146
  each_poly<Rays::Polyline>(obj, [&](const auto& polyline)
145
147
  {
@@ -407,7 +409,7 @@ namespace Rucy
407
409
  {
408
410
  if (argc <= 0)
409
411
  return Rays::Polygon();
410
- else if (argv->is_kind_of(Rays::polyline_class()))
412
+ else if (argv->is_a(Rays::polyline_class()))
411
413
  {
412
414
  if (argc == 1)
413
415
  return Rays::Polygon(to<Rays::Polyline&>(*argv));
@@ -111,7 +111,9 @@ RUCY_DEF1(get_at, index)
111
111
  int i = to<int>(index);
112
112
  if (i < 0) i += size;
113
113
 
114
- if (i < 0 || size <= i)
114
+ if (i < 0)
115
+ index_error(__FILE__, __LINE__);
116
+ if (i >= size)
115
117
  index_error(__FILE__, __LINE__);
116
118
 
117
119
  return value((*THIS)[i]);
data/ext/rays/rays.cpp CHANGED
@@ -128,7 +128,9 @@ namespace Rucy
128
128
  }
129
129
 
130
130
  int type = value_to<int>(*argv, convert);
131
- if (type < 0 || Rays::CAP_MAX <= type)
131
+ if (type < 0)
132
+ argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
133
+ if (type >= Rays::CAP_MAX)
132
134
  argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
133
135
 
134
136
  return (Rays::CapType) type;
@@ -159,7 +161,9 @@ namespace Rucy
159
161
  }
160
162
 
161
163
  int type = value_to<int>(*argv, convert);
162
- if (type < 0 || Rays::JOIN_MAX <= type)
164
+ if (type < 0)
165
+ argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
166
+ if (type >= Rays::JOIN_MAX)
163
167
  argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
164
168
 
165
169
  return (Rays::JoinType) type;
@@ -190,7 +194,9 @@ namespace Rucy
190
194
  }
191
195
 
192
196
  int mode = value_to<int>(*argv, convert);
193
- if (mode < 0 || Rays::BLEND_MAX <= mode)
197
+ if (mode < 0)
198
+ argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
199
+ if (mode >= Rays::BLEND_MAX)
194
200
  argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
195
201
 
196
202
  return (Rays::BlendMode) mode;
@@ -221,7 +227,9 @@ namespace Rucy
221
227
  }
222
228
 
223
229
  int mode = value_to<int>(*argv, convert);
224
- if (mode < 0 || Rays::TEXCOORD_MODE_MAX <= mode)
230
+ if (mode < 0)
231
+ argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
232
+ if (mode >= Rays::TEXCOORD_MODE_MAX)
225
233
  argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
226
234
 
227
235
  return (Rays::TexCoordMode) mode;
@@ -252,7 +260,9 @@ namespace Rucy
252
260
  }
253
261
 
254
262
  int wrap = value_to<int>(*argv, convert);
255
- if (wrap < 0 || Rays::TEXCOORD_WRAP_MAX <= wrap)
263
+ if (wrap < 0)
264
+ argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
265
+ if (wrap >= Rays::TEXCOORD_WRAP_MAX)
256
266
  argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
257
267
 
258
268
  return (Rays::TexCoordWrap) wrap;
data/ext/rays/shader.cpp CHANGED
@@ -141,7 +141,7 @@ RUCY_DEFN(set_uniform)
141
141
  case 4: THIS->set_uniform(name, Af(0), Af(1), Af(2), Af(3)); break;
142
142
  }
143
143
  }
144
- else if (argv[0].is_kind_of(Rays::image_class()))
144
+ else if (argv[0].is_a(Rays::image_class()))
145
145
  THIS->set_uniform(name, to<Rays::Image&>(argv[0]));
146
146
  else
147
147
  argument_error(__FILE__, __LINE__);
data/include/rays/image.h CHANGED
@@ -27,9 +27,11 @@ namespace Rays
27
27
 
28
28
  Image (
29
29
  int width, int height, const ColorSpace& cs = DEFAULT_COLOR_SPACE,
30
- float pixel_density = 1);
30
+ float pixel_density = 1, bool smooth = false);
31
31
 
32
- Image (const Bitmap& bitmap, float pixel_density = 1);
32
+ Image (
33
+ const Bitmap& bitmap,
34
+ float pixel_density = 1, bool smooth = false);
33
35
 
34
36
  ~Image ();
35
37
 
@@ -45,6 +47,10 @@ namespace Rays
45
47
 
46
48
  float pixel_density () const;
47
49
 
50
+ void set_smooth (bool smooth);
51
+
52
+ bool smooth () const;
53
+
48
54
  Painter painter ();
49
55
 
50
56
  Bitmap& bitmap (bool modify = false);
data/lib/rays/image.rb CHANGED
@@ -13,6 +13,10 @@ module Rays
13
13
 
14
14
  def_delegators :bitmap_for_write, :pixels=, :[]=
15
15
 
16
+ def initialize(*args, pixel_density: 1, smooth: false)
17
+ initialize! args, pixel_density, smooth
18
+ end
19
+
16
20
  def paint(&block)
17
21
  painter.paint self, &block
18
22
  self
data/rays.gemspec CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_runtime_dependency 'xot', '~> 0.3'
29
- s.add_runtime_dependency 'rucy', '~> 0.3'
28
+ s.add_runtime_dependency 'xot', '~> 0.3.1'
29
+ s.add_runtime_dependency 'rucy', '~> 0.3.1'
30
30
 
31
31
  s.files = `git ls-files`.split $/
32
32
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
data/src/bounds.cpp CHANGED
@@ -50,7 +50,9 @@ namespace Rays
50
50
  bool
51
51
  Bounds::is_intersect (const Bounds& other, int dimension) const
52
52
  {
53
- if (dimension < 1 || 3 < dimension)
53
+ if (dimension < 1)
54
+ argument_error(__FILE__, __LINE__);
55
+ if (dimension > 3)
54
56
  argument_error(__FILE__, __LINE__);
55
57
 
56
58
  Point size = (*this & other).size();
@@ -69,7 +71,9 @@ namespace Rays
69
71
  bool
70
72
  Bounds::is_include (const Point& point, int dimension) const
71
73
  {
72
- if (dimension < 1 || 3 < dimension)
74
+ if (dimension < 1)
75
+ argument_error(__FILE__, __LINE__);
76
+ if (dimension > 3)
73
77
  argument_error(__FILE__, __LINE__);
74
78
 
75
79
  const Point &pos = position(), &size_ = size();
data/src/color.cpp CHANGED
@@ -117,7 +117,9 @@ namespace Rays
117
117
  Color&
118
118
  Color::reset (const void* pixel, const ColorSpace& cs)
119
119
  {
120
- if (!pixel || !cs)
120
+ if (!pixel)
121
+ argument_error(__FILE__, __LINE__);
122
+ if (!cs)
121
123
  argument_error(__FILE__, __LINE__);
122
124
 
123
125
  if (cs.is_float())
@@ -175,7 +177,9 @@ namespace Rays
175
177
  static void
176
178
  get_rgba (float* red, float* green, float* blue, float* alpha, const float* c)
177
179
  {
178
- if ((!red && !green && !blue && !alpha) || !c)
180
+ if (!red && !green && !blue && !alpha)
181
+ argument_error(__FILE__, __LINE__);
182
+ if (!c)
179
183
  argument_error(__FILE__, __LINE__);
180
184
 
181
185
  if (red) *red = c[0];
@@ -187,7 +191,9 @@ namespace Rays
187
191
  static void
188
192
  get_rgba (uchar* red, uchar* green, uchar* blue, uchar* alpha, const float* c)
189
193
  {
190
- if ((!red && !green && !blue && !alpha) || !c)
194
+ if (!red && !green && !blue && !alpha)
195
+ argument_error(__FILE__, __LINE__);
196
+ if (!c)
191
197
  argument_error(__FILE__, __LINE__);
192
198
 
193
199
  if (red) *red = Color::float2uchar(c[0]);
@@ -199,7 +205,9 @@ namespace Rays
199
205
  void
200
206
  Color::get (void* pixel, const ColorSpace& cs) const
201
207
  {
202
- if (!pixel || !cs)
208
+ if (!pixel)
209
+ argument_error(__FILE__, __LINE__);
210
+ if (!cs)
203
211
  argument_error(__FILE__, __LINE__);
204
212
 
205
213
  const float* c = array;
data/src/image.cpp CHANGED
@@ -30,6 +30,8 @@ namespace Rays
30
30
 
31
31
  float pixel_density = 1;
32
32
 
33
+ bool smooth = false;
34
+
33
35
  mutable Bitmap bitmap;
34
36
 
35
37
  mutable Texture texture;
@@ -56,6 +58,13 @@ namespace Rays
56
58
  if (self->texture) self->texture.set_modified(false);
57
59
  }
58
60
 
61
+ static void
62
+ invalidate_texture (Image* image)
63
+ {
64
+ image->bitmap();// update bitmap
65
+ image->self->texture = Texture();
66
+ }
67
+
59
68
  static Bitmap&
60
69
  get_bitmap (Image* image)
61
70
  {
@@ -117,12 +126,13 @@ namespace Rays
117
126
  if (self->bitmap)
118
127
  {
119
128
  PRINT_MODIFIED_FLAGS("new texture from bitmap");
120
- self->texture = Texture(self->bitmap);
129
+ self->texture = Texture(self->bitmap, self->smooth);
121
130
  }
122
131
  else
123
132
  {
124
133
  PRINT_MODIFIED_FLAGS("new texture");
125
- self->texture = Texture(self->width, self->height, self->color_space);
134
+ self->texture = Texture(
135
+ self->width, self->height, self->color_space, self->smooth);
126
136
 
127
137
  Painter p = image.painter();
128
138
  p.begin();
@@ -167,7 +177,8 @@ namespace Rays
167
177
  }
168
178
 
169
179
  Image::Image (
170
- int width, int height, const ColorSpace& cs, float pixel_density)
180
+ int width, int height, const ColorSpace& cs,
181
+ float pixel_density, bool smooth)
171
182
  {
172
183
  if (pixel_density <= 0)
173
184
  argument_error(__FILE__, __LINE__, "invalid pixel_density.");
@@ -176,9 +187,10 @@ namespace Rays
176
187
  self->height = (int) (height * pixel_density);
177
188
  self->color_space = cs;
178
189
  self->pixel_density = pixel_density;
190
+ self->smooth = smooth;
179
191
  }
180
192
 
181
- Image::Image (const Bitmap& bitmap, float pixel_density)
193
+ Image::Image (const Bitmap& bitmap, float pixel_density, bool smooth)
182
194
  {
183
195
  if (pixel_density <= 0)
184
196
  argument_error(__FILE__, __LINE__, "invalid pixel_density.");
@@ -188,6 +200,7 @@ namespace Rays
188
200
  self->height = bitmap.height();
189
201
  self->color_space = bitmap.color_space();
190
202
  self->pixel_density = pixel_density;
203
+ self->smooth = smooth;
191
204
  }
192
205
 
193
206
  Image::~Image ()
@@ -233,6 +246,21 @@ namespace Rays
233
246
  return self->pixel_density;
234
247
  }
235
248
 
249
+ void
250
+ Image::set_smooth (bool smooth)
251
+ {
252
+ if (smooth == self->smooth) return;
253
+
254
+ self->smooth = smooth;
255
+ invalidate_texture(this);
256
+ }
257
+
258
+ bool
259
+ Image::smooth () const
260
+ {
261
+ return self->smooth;
262
+ }
263
+
236
264
  Painter
237
265
  Image::painter ()
238
266
  {
data/src/ios/bitmap.mm CHANGED
@@ -126,7 +126,11 @@ namespace Rays
126
126
  int w, int h, const ColorSpace& cs,
127
127
  const void* pixels = NULL, bool clear_pixels = true)
128
128
  {
129
- if (w <= 0 || h <= 0 || !cs)
129
+ if (w <= 0)
130
+ argument_error(__FILE__, __LINE__);
131
+ if (h <= 0)
132
+ argument_error(__FILE__, __LINE__);
133
+ if (!cs)
130
134
  argument_error(__FILE__, __LINE__);
131
135
 
132
136
  Bitmap::Data* self = bitmap->self.get();
@@ -179,7 +183,9 @@ namespace Rays
179
183
  {
180
184
  if (width == 0 || height == 0) return;
181
185
 
182
- if (!bitmap || !image)
186
+ if (!bitmap)
187
+ argument_error(__FILE__, __LINE__);
188
+ if (!image)
183
189
  argument_error(__FILE__, __LINE__);
184
190
 
185
191
  CGContextRef context = bitmap->self->get_context();
@@ -197,7 +203,13 @@ namespace Rays
197
203
  Bitmap_draw_string (
198
204
  Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y)
199
205
  {
200
- if (!bitmap || !*bitmap || !font || !str)
206
+ if (!bitmap)
207
+ argument_error(__FILE__, __LINE__);
208
+ if (!*bitmap)
209
+ argument_error(__FILE__, __LINE__);
210
+ if (!font)
211
+ argument_error(__FILE__, __LINE__);
212
+ if (!str)
201
213
  argument_error(__FILE__, __LINE__);
202
214
 
203
215
  if (*str == '\0') return;
@@ -261,7 +273,9 @@ namespace Rays
261
273
  Bitmap
262
274
  Bitmap_load (const char* path_)
263
275
  {
264
- if (!path_ || path_[0] == '\0')
276
+ if (!path_)
277
+ argument_error(__FILE__, __LINE__);
278
+ if (path_[0] == '\0')
265
279
  argument_error(__FILE__, __LINE__);
266
280
 
267
281
  NSString* path = [NSString stringWithUTF8String: path_];
data/src/ios/font.mm CHANGED
@@ -152,7 +152,9 @@ namespace Rays
152
152
  {
153
153
  CGContextRef context = (CGContextRef) context_;
154
154
 
155
- if (!context || !str)
155
+ if (!context)
156
+ argument_error(__FILE__, __LINE__);
157
+ if (!str)
156
158
  argument_error(__FILE__, __LINE__);
157
159
 
158
160
  if (*str == '\0') return;
data/src/osx/bitmap.mm CHANGED
@@ -125,7 +125,11 @@ namespace Rays
125
125
  int w, int h, const ColorSpace& cs,
126
126
  const void* pixels = NULL, bool clear_pixels = true)
127
127
  {
128
- if (w <= 0 || h <= 0 || !cs)
128
+ if (w <= 0)
129
+ argument_error(__FILE__, __LINE__);
130
+ if (h <= 0)
131
+ argument_error(__FILE__, __LINE__);
132
+ if (!cs)
129
133
  argument_error(__FILE__, __LINE__);
130
134
 
131
135
  Bitmap::Data* self = bitmap->self.get();
@@ -178,7 +182,9 @@ namespace Rays
178
182
  {
179
183
  if (width == 0 || height == 0) return;
180
184
 
181
- if (!bitmap || !image)
185
+ if (!bitmap)
186
+ argument_error(__FILE__, __LINE__);
187
+ if (!image)
182
188
  argument_error(__FILE__, __LINE__);
183
189
 
184
190
  CGContextRef context = bitmap->self->get_context();
@@ -196,7 +202,13 @@ namespace Rays
196
202
  Bitmap_draw_string (
197
203
  Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y)
198
204
  {
199
- if (!bitmap || !*bitmap || !font || !str)
205
+ if (!bitmap)
206
+ argument_error(__FILE__, __LINE__);
207
+ if (!*bitmap)
208
+ argument_error(__FILE__, __LINE__);
209
+ if (!font)
210
+ argument_error(__FILE__, __LINE__);
211
+ if (!str)
200
212
  argument_error(__FILE__, __LINE__);
201
213
 
202
214
  if (*str == '\0') return;
@@ -260,7 +272,9 @@ namespace Rays
260
272
  Bitmap
261
273
  Bitmap_load (const char* path_)
262
274
  {
263
- if (!path_ || path_[0] == '\0')
275
+ if (!path_)
276
+ argument_error(__FILE__, __LINE__);
277
+ if (path_[0] == '\0')
264
278
  argument_error(__FILE__, __LINE__);
265
279
 
266
280
  NSString* path = [NSString stringWithUTF8String: path_];
data/src/osx/font.mm CHANGED
@@ -154,7 +154,9 @@ namespace Rays
154
154
  {
155
155
  CGContextRef context = (CGContextRef) context_;
156
156
 
157
- if (!context || !str)
157
+ if (!context)
158
+ argument_error(__FILE__, __LINE__);
159
+ if (!str)
158
160
  argument_error(__FILE__, __LINE__);
159
161
 
160
162
  if (*str == '\0') return;
data/src/painter.cpp CHANGED
@@ -332,7 +332,9 @@ namespace Rays
332
332
  const TextureInfo* texinfo = NULL,
333
333
  const Shader* shader = NULL)
334
334
  {
335
- if (!points || npoints <= 0)
335
+ if (!points)
336
+ argument_error(__FILE__, __LINE__);
337
+ if (npoints <= 0)
336
338
  argument_error(__FILE__, __LINE__);
337
339
 
338
340
  if (!painting)
data/src/point.cpp CHANGED
@@ -159,7 +159,11 @@ namespace Rays
159
159
  Point&
160
160
  Point::operator /= (const This& rhs)
161
161
  {
162
- if (rhs.x == 0 || rhs.y == 0 || rhs.z == 0)
162
+ if (rhs.x == 0)
163
+ argument_error(__FILE__, __LINE__);
164
+ if (rhs.y == 0)
165
+ argument_error(__FILE__, __LINE__);
166
+ if (rhs.z == 0)
163
167
  argument_error(__FILE__, __LINE__);
164
168
 
165
169
  to_glm(*this) /= to_glm(rhs);
@@ -235,7 +239,11 @@ namespace Rays
235
239
  Point
236
240
  operator / (coord lhs, const Point& rhs)
237
241
  {
238
- if (rhs.x == 0 || rhs.y == 0 || rhs.z == 0)
242
+ if (rhs.x == 0)
243
+ argument_error(__FILE__, __LINE__);
244
+ if (rhs.y == 0)
245
+ argument_error(__FILE__, __LINE__);
246
+ if (rhs.z == 0)
239
247
  argument_error(__FILE__, __LINE__);
240
248
 
241
249
  return to_rays<Point>(lhs / to_glm(rhs));
@@ -253,7 +261,11 @@ namespace Rays
253
261
  Point
254
262
  operator / (const Point& lhs, const Point& rhs)
255
263
  {
256
- if (rhs.x == 0 || rhs.y == 0 || rhs.z == 0)
264
+ if (rhs.x == 0)
265
+ argument_error(__FILE__, __LINE__);
266
+ if (rhs.y == 0)
267
+ argument_error(__FILE__, __LINE__);
268
+ if (rhs.z == 0)
257
269
  argument_error(__FILE__, __LINE__);
258
270
 
259
271
  return to_rays<Point>(to_glm(lhs) / to_glm(rhs));
data/src/polygon.cpp CHANGED
@@ -70,12 +70,10 @@ namespace Rays
70
70
  if (!points_)
71
71
  argument_error(__FILE__, __LINE__);
72
72
 
73
- if (
74
- !points.empty() &&
75
- (!colors_ != !pcolors || !texcoords_ != !ptexcoords))
76
- {
73
+ if (!points.empty() && !colors_ != !pcolors)
74
+ argument_error(__FILE__, __LINE__);
75
+ if (!points.empty() && !texcoords_ != !ptexcoords)
77
76
  argument_error(__FILE__, __LINE__);
78
- }
79
77
 
80
78
  segments.emplace_back(points.size(), 0, polyline.hole());
81
79
  points.insert(points.end(), points_, points_ + polyline.size());
@@ -25,16 +25,24 @@ namespace Rays
25
25
 
26
26
  void create (int width_, int height_)
27
27
  {
28
- if (width_ <= 0 || height_ <= 0)
28
+ if (width_ <= 0)
29
+ argument_error(__FILE__, __LINE__);
30
+ if (height_ <= 0)
29
31
  argument_error(__FILE__, __LINE__);
30
32
 
31
33
  if (is_valid())
32
34
  {
33
- if (width != width_ || height == height_)
35
+ if (width != width_)
36
+ {
37
+ argument_error(__FILE__, __LINE__,
38
+ "RenderBuffer is already created and "
39
+ "width parameters is not same as current width.");
40
+ }
41
+ if (height != height_)
34
42
  {
35
43
  argument_error(__FILE__, __LINE__,
36
44
  "RenderBuffer is already created and "
37
- "width/height parameters is not same as current width/height.");
45
+ "height parameters is not same as current height.");
38
46
  }
39
47
  return;
40
48
  }
@@ -99,42 +99,50 @@ namespace Rays
99
99
  };// UniformValueT
100
100
 
101
101
 
102
- template <> void UniformValueT<int, 1>::apply_value (GLint location) const
102
+ template <> void
103
+ UniformValueT<int, 1>::apply_value (GLint location) const
103
104
  {
104
105
  glUniform1iv(location, 1, array);
105
106
  }
106
107
 
107
- template <> void UniformValueT<int, 2>::apply_value (GLint location) const
108
+ template <> void
109
+ UniformValueT<int, 2>::apply_value (GLint location) const
108
110
  {
109
111
  glUniform2iv(location, 1, array);
110
112
  }
111
113
 
112
- template <> void UniformValueT<int, 3>::apply_value (GLint location) const
114
+ template <> void
115
+ UniformValueT<int, 3>::apply_value (GLint location) const
113
116
  {
114
117
  glUniform3iv(location, 1, array);
115
118
  }
116
119
 
117
- template <> void UniformValueT<int, 4>::apply_value (GLint location) const
120
+ template <> void
121
+ UniformValueT<int, 4>::apply_value (GLint location) const
118
122
  {
119
123
  glUniform4iv(location, 1, array);
120
124
  }
121
125
 
122
- template <> void UniformValueT<float, 1>::apply_value (GLint location) const
126
+ template <> void
127
+ UniformValueT<float, 1>::apply_value (GLint location) const
123
128
  {
124
129
  glUniform1fv(location, 1, array);
125
130
  }
126
131
 
127
- template <> void UniformValueT<float, 2>::apply_value (GLint location) const
132
+ template <> void
133
+ UniformValueT<float, 2>::apply_value (GLint location) const
128
134
  {
129
135
  glUniform2fv(location, 1, array);
130
136
  }
131
137
 
132
- template <> void UniformValueT<float, 3>::apply_value (GLint location) const
138
+ template <> void
139
+ UniformValueT<float, 3>::apply_value (GLint location) const
133
140
  {
134
141
  glUniform3fv(location, 1, array);
135
142
  }
136
143
 
137
- template <> void UniformValueT<float, 4>::apply_value (GLint location) const
144
+ template <> void
145
+ UniformValueT<float, 4>::apply_value (GLint location) const
138
146
  {
139
147
  glUniform4fv(location, 1, array);
140
148
  }
@@ -191,7 +199,9 @@ namespace Rays
191
199
 
192
200
  Uniform (const char* name, const UniformValue* value)
193
201
  {
194
- if (!name || name[0] == '\0')
202
+ if (!name)
203
+ argument_error(__FILE__, __LINE__);
204
+ if (name[0] == '\0')
195
205
  argument_error(__FILE__, __LINE__);
196
206
 
197
207
  reset(value);
@@ -29,7 +29,11 @@ namespace Rays
29
29
 
30
30
  void compile (GLenum type_, const char* source_)
31
31
  {
32
- if (!is_valid_type(type_) || !source_ || !*source_)
32
+ if (!is_valid_type(type_))
33
+ argument_error(__FILE__, __LINE__);
34
+ if (!source_)
35
+ argument_error(__FILE__, __LINE__);
36
+ if (!*source_)
33
37
  argument_error(__FILE__, __LINE__);
34
38
 
35
39
  if (is_valid())