rays 0.3.9 → 0.3.11

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/bounds.cpp +1 -1
  3. data/.doc/ext/rays/font.cpp +23 -5
  4. data/.doc/ext/rays/image.cpp +1 -1
  5. data/.doc/ext/rays/native.cpp +1 -5
  6. data/.doc/ext/rays/painter.cpp +1 -1
  7. data/.doc/ext/rays/polygon.cpp +1 -1
  8. data/.github/workflows/release-gem.yml +1 -1
  9. data/.github/workflows/test.yml +4 -4
  10. data/CLAUDE.md +25 -0
  11. data/ChangeLog.md +17 -0
  12. data/Gemfile.lock +6 -5
  13. data/Rakefile +4 -2
  14. data/VERSION +1 -1
  15. data/ext/rays/bounds.cpp +1 -1
  16. data/ext/rays/extconf.rb +4 -3
  17. data/ext/rays/font.cpp +27 -7
  18. data/ext/rays/image.cpp +1 -1
  19. data/ext/rays/native.cpp +1 -5
  20. data/ext/rays/painter.cpp +1 -1
  21. data/ext/rays/polygon.cpp +1 -1
  22. data/include/rays/font.h +5 -1
  23. data/include/rays/painter.h +1 -1
  24. data/lib/rays/ext.rb +1 -1
  25. data/lib/rays/image.rb +5 -0
  26. data/rays.gemspec +2 -2
  27. data/src/bitmap.h +6 -1
  28. data/src/color_space.cpp +1 -41
  29. data/src/font.cpp +17 -1
  30. data/src/image.cpp +0 -1
  31. data/src/ios/bitmap.mm +20 -35
  32. data/src/ios/rays.mm +3 -3
  33. data/src/opengl/bitmap.cpp +41 -0
  34. data/src/opengl/color_space.cpp +51 -0
  35. data/src/{color_space.h → opengl/color_space.h} +2 -2
  36. data/src/{frame_buffer.cpp → opengl/frame_buffer.cpp} +1 -1
  37. data/src/{frame_buffer.h → opengl/frame_buffer.h} +2 -2
  38. data/src/{ios → opengl/ios}/opengl.mm +3 -3
  39. data/src/{opengl.h → opengl/opengl.h} +3 -7
  40. data/src/{osx → opengl/osx}/opengl.mm +3 -3
  41. data/src/opengl/painter.cpp +756 -0
  42. data/src/{render_buffer.h → opengl/render_buffer.h} +2 -2
  43. data/src/opengl/sdl/opengl.cpp +103 -0
  44. data/src/{shader.cpp → opengl/shader.cpp} +1 -2
  45. data/src/{shader.h → opengl/shader.h} +2 -2
  46. data/src/{shader_program.cpp → opengl/shader_program.cpp} +3 -3
  47. data/src/{shader_program.h → opengl/shader_program.h} +2 -2
  48. data/src/{shader_source.h → opengl/shader_source.h} +2 -2
  49. data/src/{texture.cpp → opengl/texture.cpp} +2 -3
  50. data/src/opengl/texture.h +21 -0
  51. data/src/{win32 → opengl/win32}/opengl.cpp +4 -4
  52. data/src/osx/bitmap.mm +20 -36
  53. data/src/osx/rays.mm +3 -3
  54. data/src/painter.cpp +28 -910
  55. data/src/painter.h +210 -11
  56. data/src/polygon.cpp +38 -13
  57. data/src/renderer.h +22 -0
  58. data/src/sdl/bitmap.cpp +304 -0
  59. data/src/sdl/camera.cpp +119 -0
  60. data/src/sdl/font.cpp +93 -0
  61. data/src/sdl/rays.cpp +50 -0
  62. data/src/texture.h +0 -3
  63. data/src/win32/bitmap.cpp +8 -35
  64. data/src/win32/rays.cpp +3 -3
  65. data/test/test_image.rb +1 -0
  66. metadata +34 -35
  67. /data/src/{opengl.cpp → opengl/opengl.cpp} +0 -0
  68. /data/src/{render_buffer.cpp → opengl/render_buffer.cpp} +0 -0
  69. /data/src/{shader_source.cpp → opengl/shader_source.cpp} +0 -0
@@ -0,0 +1,119 @@
1
+ #include "rays/camera.h"
2
+
3
+
4
+ #include "rays/exception.h"
5
+
6
+
7
+ namespace Rays
8
+ {
9
+
10
+
11
+ struct Camera::Data
12
+ {
13
+ };// Camera::Data
14
+
15
+
16
+ std::vector<String>
17
+ get_camera_device_names ()
18
+ {
19
+ not_implemented_error(__FILE__, __LINE__);
20
+ }
21
+
22
+
23
+ Camera::Camera (
24
+ const char* device_name,
25
+ int min_width, int min_height, bool resize, bool crop)
26
+ {
27
+ not_implemented_error(__FILE__, __LINE__);
28
+ }
29
+
30
+ Camera::~Camera ()
31
+ {
32
+ not_implemented_error(__FILE__, __LINE__);
33
+ }
34
+
35
+ bool
36
+ Camera::start ()
37
+ {
38
+ not_implemented_error(__FILE__, __LINE__);
39
+ }
40
+
41
+ void
42
+ Camera::stop ()
43
+ {
44
+ not_implemented_error(__FILE__, __LINE__);
45
+ }
46
+
47
+ bool
48
+ Camera::is_active () const
49
+ {
50
+ not_implemented_error(__FILE__, __LINE__);
51
+ }
52
+
53
+ void
54
+ Camera::set_min_width (int width)
55
+ {
56
+ not_implemented_error(__FILE__, __LINE__);
57
+ }
58
+
59
+ int
60
+ Camera::min_width () const
61
+ {
62
+ not_implemented_error(__FILE__, __LINE__);
63
+ }
64
+
65
+ void
66
+ Camera::set_min_height (int height)
67
+ {
68
+ not_implemented_error(__FILE__, __LINE__);
69
+ }
70
+
71
+ int
72
+ Camera::min_height () const
73
+ {
74
+ not_implemented_error(__FILE__, __LINE__);
75
+ }
76
+
77
+ void
78
+ Camera::set_resize (bool resize)
79
+ {
80
+ not_implemented_error(__FILE__, __LINE__);
81
+ }
82
+
83
+ bool
84
+ Camera::is_resize () const
85
+ {
86
+ not_implemented_error(__FILE__, __LINE__);
87
+ }
88
+
89
+ void
90
+ Camera::set_crop (bool crop)
91
+ {
92
+ not_implemented_error(__FILE__, __LINE__);
93
+ }
94
+
95
+ bool
96
+ Camera::is_crop () const
97
+ {
98
+ not_implemented_error(__FILE__, __LINE__);
99
+ }
100
+
101
+ const Image*
102
+ Camera::image () const
103
+ {
104
+ not_implemented_error(__FILE__, __LINE__);
105
+ }
106
+
107
+ Camera::operator bool () const
108
+ {
109
+ return false;
110
+ }
111
+
112
+ bool
113
+ Camera::operator ! () const
114
+ {
115
+ return !operator bool();
116
+ }
117
+
118
+
119
+ }// Rays
data/src/sdl/font.cpp ADDED
@@ -0,0 +1,93 @@
1
+ #include "../font.h"
2
+
3
+
4
+ #include "rays/exception.h"
5
+
6
+
7
+ namespace Rays
8
+ {
9
+
10
+
11
+ struct RawFont::Data
12
+ {
13
+
14
+ String path;
15
+
16
+ };// RawFont::Data
17
+
18
+
19
+ const FontFamilyMap&
20
+ get_font_families ()
21
+ {
22
+ static const FontFamilyMap MAP;
23
+ return MAP;
24
+ }
25
+
26
+ RawFont
27
+ RawFont_load (const char* path, coord size)
28
+ {
29
+ return RawFont();
30
+ }
31
+
32
+
33
+ RawFont::RawFont ()
34
+ {
35
+ }
36
+
37
+ RawFont::RawFont (const char* name, coord size)
38
+ {
39
+ }
40
+
41
+ RawFont::RawFont (const This& obj, coord size)
42
+ {
43
+ }
44
+
45
+ RawFont::~RawFont ()
46
+ {
47
+ }
48
+
49
+ void
50
+ RawFont::draw_string (
51
+ void* context_, coord context_height,
52
+ const char* str, coord x, coord y) const
53
+ {
54
+ }
55
+
56
+ String
57
+ RawFont::name () const
58
+ {
59
+ return "";
60
+ }
61
+
62
+ coord
63
+ RawFont::size () const
64
+ {
65
+ return 0;
66
+ }
67
+
68
+ coord
69
+ RawFont::get_width (const char* str) const
70
+ {
71
+ if (!str || *str == '\0') return 0;
72
+ return 0;
73
+ }
74
+
75
+ coord
76
+ RawFont::get_height (coord* ascent, coord* descent, coord* leading) const
77
+ {
78
+ return 0;
79
+ }
80
+
81
+ RawFont::operator bool () const
82
+ {
83
+ return true;
84
+ }
85
+
86
+ bool
87
+ RawFont::operator ! () const
88
+ {
89
+ return !operator bool();
90
+ }
91
+
92
+
93
+ }// Rays
data/src/sdl/rays.cpp ADDED
@@ -0,0 +1,50 @@
1
+ #include "rays/rays.h"
2
+
3
+
4
+ #include <SDL.h>
5
+ #include "rays/exception.h"
6
+ #include "rays/debug.h"
7
+ #include "../renderer.h"
8
+
9
+
10
+ namespace Rays
11
+ {
12
+
13
+
14
+ namespace global
15
+ {
16
+
17
+ static bool initialized = false;
18
+
19
+ }
20
+
21
+
22
+ void
23
+ init ()
24
+ {
25
+ if (global::initialized)
26
+ rays_error(__FILE__, __LINE__, "already initialized");
27
+
28
+ if (SDL_Init(SDL_INIT_VIDEO) < 0)
29
+ rays_error(__FILE__, __LINE__, SDL_GetError());
30
+
31
+ Renderer_init();
32
+
33
+ global::initialized = true;
34
+ }
35
+
36
+ void
37
+ fin ()
38
+ {
39
+ if (!global::initialized)
40
+ rays_error(__FILE__, __LINE__, "not initialized");
41
+
42
+ Renderer_fin();
43
+
44
+ SDL_Quit();
45
+
46
+ global::initialized = false;
47
+ }
48
+
49
+
50
+ }// Rays
data/src/texture.h CHANGED
@@ -7,7 +7,6 @@
7
7
  #include <xot/pimpl.h>
8
8
  #include "rays/defs.h"
9
9
  #include "rays/color_space.h"
10
- #include "opengl.h"
11
10
 
12
11
 
13
12
  namespace Rays
@@ -46,8 +45,6 @@ namespace Rays
46
45
 
47
46
  bool smooth () const;
48
47
 
49
- GLuint id () const;
50
-
51
48
  void set_modified (bool modified = true);
52
49
 
53
50
  bool modified () const;
data/src/win32/bitmap.cpp CHANGED
@@ -7,10 +7,8 @@
7
7
  #include <stb_image_write.h>
8
8
 
9
9
  #include "rays/exception.h"
10
- #include "../color_space.h"
11
10
  #include "../font.h"
12
11
  #include "../texture.h"
13
- #include "../frame_buffer.h"
14
12
  #include "gdi.h"
15
13
 
16
14
 
@@ -54,11 +52,10 @@ namespace Rays
54
52
  };// Bitmap::Data
55
53
 
56
54
 
57
- static void
58
- setup_bitmap (
59
- Bitmap* bitmap,
60
- int w, int h, const ColorSpace& cs,
61
- const void* pixels = NULL, bool clear_pixels = true, HDC hdc = NULL)
55
+ void
56
+ Bitmap_setup (
57
+ Bitmap* bitmap, int w, int h, const ColorSpace& cs,
58
+ const void* pixels, bool clear_pixels)
62
59
  {
63
60
  if (w <= 0)
64
61
  argument_error(__FILE__, __LINE__);
@@ -91,7 +88,7 @@ namespace Rays
91
88
  header.biBitCount = self->color_space.bpp();
92
89
  header.biCompression = BI_RGB;
93
90
 
94
- Win32::DC dc = hdc ? Win32::DC(hdc) : Win32::screen_dc();
91
+ Win32::DC dc = Win32::screen_dc();
95
92
 
96
93
  HBITMAP hbmp = CreateDIBSection(
97
94
  dc.handle(), &bmpinfo, DIB_RGB_COLORS, (void**) &self->pixels, NULL, 0);
@@ -109,34 +106,10 @@ namespace Rays
109
106
  memset(self->pixels, 0, size);
110
107
  }
111
108
 
112
- Bitmap
113
- Bitmap_from (const Texture& tex)
114
- {
115
- if (!tex)
116
- argument_error(__FILE__, __LINE__);
117
-
118
- Bitmap bmp;
119
- setup_bitmap(
120
- &bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
121
-
122
- GLenum format, type;
123
- ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
124
-
125
- FrameBuffer fb(tex);
126
- FrameBufferBinder binder(fb.id());
127
-
128
- for (int y = 0; y < bmp.height(); ++y)
129
- {
130
- GLvoid* ptr = (GLvoid*) bmp.at<uchar>(0, y);
131
- glReadPixels(0, y, bmp.width(), 1, format, type, ptr);
132
- }
133
-
134
- return bmp;
135
- }
136
-
137
109
  void
138
110
  Bitmap_draw_string (
139
- Bitmap* bitmap, const RawFont& font, const char* str, coord x, coord y)
111
+ Bitmap* bitmap, const RawFont& font,
112
+ const char* str, coord x, coord y, bool smooth)
140
113
  {
141
114
  if (!bitmap)
142
115
  argument_error(__FILE__, __LINE__);
@@ -252,7 +225,7 @@ namespace Rays
252
225
  Bitmap::Bitmap (
253
226
  int width, int height, const ColorSpace& color_space, const void* pixels)
254
227
  {
255
- setup_bitmap(this, width, height, color_space, pixels);
228
+ Bitmap_setup(this, width, height, color_space, pixels);
256
229
  }
257
230
 
258
231
  Bitmap::~Bitmap ()
data/src/win32/rays.cpp CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  #include "rays/exception.h"
5
- #include "../opengl.h"
5
+ #include "../renderer.h"
6
6
 
7
7
 
8
8
  namespace Rays
@@ -25,7 +25,7 @@ namespace Rays
25
25
 
26
26
  global::initialized = true;
27
27
 
28
- OpenGL_init();
28
+ Renderer_init();
29
29
  }
30
30
 
31
31
  void
@@ -34,7 +34,7 @@ namespace Rays
34
34
  if (!global::initialized)
35
35
  rays_error(__FILE__, __LINE__, "not initialized.");
36
36
 
37
- OpenGL_fin();
37
+ Renderer_fin();
38
38
 
39
39
  global::initialized = false;
40
40
  }
data/test/test_image.rb CHANGED
@@ -124,6 +124,7 @@ class TestImage < Test::Unit::TestCase
124
124
  paths.each {|path| File.delete path}
125
125
 
126
126
  assert_raise(ArgumentError) {img.save 'testimage.unknown'}
127
+ assert_raise(Errno::ENOENT) {load '/nofile.png'}
127
128
  end
128
129
 
129
130
  end# TestImage
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.9
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-05 00:00:00.000000000 Z
11
+ date: 2026-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -16,40 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.9
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.3.9
19
+ version: 0.3.11
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 0.3.9
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.3.9
26
+ version: 0.3.11
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rucy
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: 0.3.9
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.3.9
33
+ version: 0.3.11
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
38
  - - "~>"
48
39
  - !ruby/object:Gem::Version
49
- version: 0.3.9
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.3.9
40
+ version: 0.3.11
53
41
  description: This library helps you to develop graphics application with OpenGL.
54
42
  email: xordog@gmail.com
55
43
  executables: []
@@ -98,6 +86,7 @@ files:
98
86
  - ".github/workflows/tag.yml"
99
87
  - ".github/workflows/test.yml"
100
88
  - ".github/workflows/utils.rb"
89
+ - CLAUDE.md
101
90
  - CONTRIBUTING.md
102
91
  - ChangeLog.md
103
92
  - Gemfile
@@ -185,14 +174,11 @@ files:
185
174
  - src/bounds.cpp
186
175
  - src/color.cpp
187
176
  - src/color_space.cpp
188
- - src/color_space.h
189
177
  - src/coord.cpp
190
178
  - src/coord.h
191
179
  - src/exception.cpp
192
180
  - src/font.cpp
193
181
  - src/font.h
194
- - src/frame_buffer.cpp
195
- - src/frame_buffer.h
196
182
  - src/glm.h
197
183
  - src/image.cpp
198
184
  - src/image.h
@@ -200,17 +186,35 @@ files:
200
186
  - src/ios/bitmap.mm
201
187
  - src/ios/camera.mm
202
188
  - src/ios/font.mm
203
- - src/ios/opengl.mm
204
189
  - src/ios/rays.mm
205
190
  - src/matrix.cpp
206
191
  - src/matrix.h
207
- - src/opengl.cpp
208
- - src/opengl.h
192
+ - src/opengl/bitmap.cpp
193
+ - src/opengl/color_space.cpp
194
+ - src/opengl/color_space.h
195
+ - src/opengl/frame_buffer.cpp
196
+ - src/opengl/frame_buffer.h
197
+ - src/opengl/ios/opengl.mm
198
+ - src/opengl/opengl.cpp
199
+ - src/opengl/opengl.h
200
+ - src/opengl/osx/opengl.mm
201
+ - src/opengl/painter.cpp
202
+ - src/opengl/render_buffer.cpp
203
+ - src/opengl/render_buffer.h
204
+ - src/opengl/sdl/opengl.cpp
205
+ - src/opengl/shader.cpp
206
+ - src/opengl/shader.h
207
+ - src/opengl/shader_program.cpp
208
+ - src/opengl/shader_program.h
209
+ - src/opengl/shader_source.cpp
210
+ - src/opengl/shader_source.h
211
+ - src/opengl/texture.cpp
212
+ - src/opengl/texture.h
213
+ - src/opengl/win32/opengl.cpp
209
214
  - src/osx/bitmap.h
210
215
  - src/osx/bitmap.mm
211
216
  - src/osx/camera.mm
212
217
  - src/osx/font.mm
213
- - src/osx/opengl.mm
214
218
  - src/osx/rays.mm
215
219
  - src/painter.cpp
216
220
  - src/painter.h
@@ -219,15 +223,11 @@ files:
219
223
  - src/polygon.h
220
224
  - src/polyline.cpp
221
225
  - src/polyline.h
222
- - src/render_buffer.cpp
223
- - src/render_buffer.h
224
- - src/shader.cpp
225
- - src/shader.h
226
- - src/shader_program.cpp
227
- - src/shader_program.h
228
- - src/shader_source.cpp
229
- - src/shader_source.h
230
- - src/texture.cpp
226
+ - src/renderer.h
227
+ - src/sdl/bitmap.cpp
228
+ - src/sdl/camera.cpp
229
+ - src/sdl/font.cpp
230
+ - src/sdl/rays.cpp
231
231
  - src/texture.h
232
232
  - src/util.cpp
233
233
  - src/win32/bitmap.cpp
@@ -235,7 +235,6 @@ files:
235
235
  - src/win32/font.cpp
236
236
  - src/win32/gdi.cpp
237
237
  - src/win32/gdi.h
238
- - src/win32/opengl.cpp
239
238
  - src/win32/rays.cpp
240
239
  - test/helper.rb
241
240
  - test/test_bitmap.rb
File without changes