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/src/texture.cpp CHANGED
@@ -23,7 +23,7 @@ namespace Rays
23
23
 
24
24
  ColorSpace color_space;
25
25
 
26
- bool modified;
26
+ bool smooth, modified;
27
27
 
28
28
  Data ()
29
29
  {
@@ -44,6 +44,7 @@ namespace Rays
44
44
  width_pow2 =
45
45
  height_pow2 = 0;
46
46
  color_space = COLORSPACE_UNKNOWN;
47
+ smooth = false;
47
48
  modified = false;
48
49
  }
49
50
 
@@ -110,7 +111,13 @@ namespace Rays
110
111
  size_t width,
111
112
  uchar* dest, size_t dest_stride, const uchar* src, size_t src_stride)
112
113
  {
113
- if (!dest || !src || dest_stride <= 0 || src_stride <= 0)
114
+ if (!dest)
115
+ argument_error(__FILE__, __LINE__);
116
+ if (!src)
117
+ argument_error(__FILE__, __LINE__);
118
+ if (dest_stride <= 0)
119
+ argument_error(__FILE__, __LINE__);
120
+ if ( src_stride <= 0)
114
121
  argument_error(__FILE__, __LINE__);
115
122
 
116
123
  while (width--)
@@ -171,7 +178,8 @@ namespace Rays
171
178
 
172
179
  static void
173
180
  setup_texture (
174
- Texture::Data* self, int width, int height, const ColorSpace& cs,
181
+ Texture::Data* self,
182
+ int width, int height, const ColorSpace& cs, bool smooth = false,
175
183
  const Bitmap* bitmap = NULL, bool npot = false)
176
184
  {
177
185
  assert(self && !self->has_id());
@@ -184,7 +192,8 @@ namespace Rays
184
192
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
185
193
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
186
194
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
187
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);//GL_LINEAR);
195
+ glTexParameteri(
196
+ GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smooth ? GL_LINEAR : GL_NEAREST);
188
197
 
189
198
  GLenum format, type;
190
199
  ColorSpace_get_gl_format_and_type(&format, &type, cs);
@@ -216,6 +225,7 @@ namespace Rays
216
225
  self->width = width;
217
226
  self->height = height;
218
227
  self->color_space = cs;
228
+ self->smooth = smooth;
219
229
  self->modified = true;
220
230
  }
221
231
 
@@ -224,21 +234,25 @@ namespace Rays
224
234
  {
225
235
  }
226
236
 
227
- Texture::Texture (int width, int height, const ColorSpace& cs)
237
+ Texture::Texture (int width, int height, const ColorSpace& cs, bool smooth)
228
238
  {
229
- if (width <= 0 || height <= 0 || !cs)
239
+ if (width <= 0)
240
+ argument_error(__FILE__, __LINE__);
241
+ if (height <= 0)
242
+ argument_error(__FILE__, __LINE__);
243
+ if (!cs)
230
244
  argument_error(__FILE__, __LINE__);
231
245
 
232
- setup_texture(self.get(), width, height, cs);
246
+ setup_texture(self.get(), width, height, cs, smooth);
233
247
  }
234
248
 
235
- Texture::Texture (const Bitmap& bitmap)
249
+ Texture::Texture (const Bitmap& bitmap, bool smooth)
236
250
  {
237
251
  if (!bitmap)
238
252
  argument_error(__FILE__, __LINE__);
239
253
 
240
254
  setup_texture(
241
- self.get(), bitmap.width(), bitmap.height(), bitmap.color_space(),
255
+ self.get(), bitmap.width(), bitmap.height(), bitmap.color_space(), smooth,
242
256
  &bitmap);
243
257
  }
244
258
 
@@ -249,8 +263,10 @@ namespace Rays
249
263
  argument_error(__FILE__, __LINE__);
250
264
 
251
265
  int w = bitmap.width(), h = bitmap.height();
252
- if (w != width() || h != height())
253
- argument_error(__FILE__, __LINE__, "the size of bitmap does not match");
266
+ if (w != width())
267
+ argument_error(__FILE__, __LINE__, "the width of bitmap does not match");
268
+ if (h != height())
269
+ argument_error(__FILE__, __LINE__, "the height of bitmap does not match");
254
270
 
255
271
  GLenum format, type;
256
272
  ColorSpace_get_gl_format_and_type(&format, &type, bitmap.color_space());
@@ -297,6 +313,12 @@ namespace Rays
297
313
  return self->color_space;
298
314
  }
299
315
 
316
+ bool
317
+ Texture::smooth () const
318
+ {
319
+ return self->smooth;
320
+ }
321
+
300
322
  GLuint
301
323
  Texture::id () const
302
324
  {
data/src/texture.h CHANGED
@@ -24,9 +24,11 @@ namespace Rays
24
24
 
25
25
  Texture ();
26
26
 
27
- Texture (int width, int height, const ColorSpace& cs = RGBA);
27
+ Texture (
28
+ int width, int height, const ColorSpace& cs = RGBA,
29
+ bool smooth = false);
28
30
 
29
- Texture (const Bitmap& bitmap);
31
+ Texture (const Bitmap& bitmap, bool smooth = false);
30
32
 
31
33
  Texture& operator = (const Bitmap& bitmap);
32
34
 
@@ -42,6 +44,8 @@ namespace Rays
42
44
 
43
45
  const ColorSpace& color_space () const;
44
46
 
47
+ bool smooth () const;
48
+
45
49
  GLuint id () const;
46
50
 
47
51
  void set_modified (bool modified = true);
data/src/win32/bitmap.cpp CHANGED
@@ -60,7 +60,11 @@ namespace Rays
60
60
  int w, int h, const ColorSpace& cs,
61
61
  const void* pixels = NULL, bool clear_pixels = true, HDC hdc = NULL)
62
62
  {
63
- if (w <= 0 || h <= 0 || !cs)
63
+ if (w <= 0)
64
+ argument_error(__FILE__, __LINE__);
65
+ if (h <= 0)
66
+ argument_error(__FILE__, __LINE__);
67
+ if (!cs)
64
68
  argument_error(__FILE__, __LINE__);
65
69
 
66
70
  Bitmap::Data* self = bitmap->self.get();
@@ -134,7 +138,13 @@ namespace Rays
134
138
  Bitmap_draw_string (
135
139
  Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y)
136
140
  {
137
- if (!bitmap || !*bitmap || !font || !str)
141
+ if (!bitmap)
142
+ argument_error(__FILE__, __LINE__);
143
+ if (!*bitmap)
144
+ argument_error(__FILE__, __LINE__);
145
+ if (!font)
146
+ argument_error(__FILE__, __LINE__);
147
+ if (!str)
138
148
  argument_error(__FILE__, __LINE__);
139
149
 
140
150
  if (*str == '\0') return;
data/src/win32/font.cpp CHANGED
@@ -132,7 +132,9 @@ namespace Rays
132
132
 
133
133
  HDC hdc = (HDC) context;
134
134
 
135
- if (!hdc || !str)
135
+ if (!hdc)
136
+ argument_error(__FILE__, __LINE__);
137
+ if (!str)
136
138
  argument_error(__FILE__, __LINE__);
137
139
 
138
140
  if (*str == '\0') return;
@@ -8,11 +8,12 @@ class TestPainterShape < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  def image(fill = 1, stroke = 0, pixel_density = 1, &block)
11
- Rays::Image.new(100, 100, Rays::RGBA, pixel_density).paint {|p|
12
- p.fill fill > 0 ? color(fill) : nil
13
- p.stroke stroke > 0 ? color(stroke) : nil
14
- p.instance_eval(&block) if block
15
- }
11
+ Rays::Image.new(100, 100, Rays::RGBA, pixel_density: pixel_density)
12
+ .paint {|p|
13
+ p.fill fill > 0 ? color(fill) : nil
14
+ p.stroke stroke > 0 ? color(stroke) : nil
15
+ p.instance_eval(&block) if block
16
+ }
16
17
  end
17
18
 
18
19
  def test_line()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rays
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-05 00:00:00.000000000 Z
11
+ date: 2025-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: 0.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: 0.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rucy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: 0.3.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.3'
40
+ version: 0.3.1
41
41
  description: This library helps you to develop graphics application with OpenGL.
42
42
  email: xordog@gmail.com
43
43
  executables: []