rays 0.3.10 → 0.3.12

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/image.cpp +10 -0
  3. data/.doc/ext/rays/painter.cpp +49 -1
  4. data/.doc/ext/rays/polygon.cpp +1 -1
  5. data/.doc/ext/rays/shader.cpp +8 -6
  6. data/.github/workflows/release-gem.yml +4 -1
  7. data/.github/workflows/test.yml +4 -4
  8. data/.github/workflows/utils.rb +88 -17
  9. data/ChangeLog.md +24 -0
  10. data/Gemfile.lock +6 -5
  11. data/Rakefile +3 -3
  12. data/VERSION +1 -1
  13. data/ext/rays/extconf.rb +3 -4
  14. data/ext/rays/image.cpp +11 -0
  15. data/ext/rays/painter.cpp +53 -1
  16. data/ext/rays/polygon.cpp +1 -1
  17. data/ext/rays/shader.cpp +8 -6
  18. data/include/rays/coord.h +6 -6
  19. data/include/rays/defs.h +2 -0
  20. data/include/rays/image.h +11 -1
  21. data/include/rays/painter.h +19 -0
  22. data/include/rays/ruby.h +2 -2
  23. data/include/rays/shader.h +5 -3
  24. data/include/rays.h +2 -2
  25. data/lib/rays/extension.rb +8 -2
  26. data/lib/rays/image.rb +2 -1
  27. data/lib/rays/shader.rb +13 -4
  28. data/rays.gemspec +3 -4
  29. data/src/bitmap.h +4 -0
  30. data/src/color_space.cpp +2 -42
  31. data/src/coord.h +10 -0
  32. data/src/font.cpp +1 -1
  33. data/src/image.cpp +85 -11
  34. data/src/ios/bitmap.mm +5 -32
  35. data/src/ios/rays.mm +3 -3
  36. data/src/opengl/bitmap.cpp +41 -0
  37. data/src/opengl/color_space.cpp +51 -0
  38. data/src/{color_space.h → opengl/color_space.h} +2 -2
  39. data/src/{frame_buffer.cpp → opengl/frame_buffer.cpp} +1 -1
  40. data/src/{frame_buffer.h → opengl/frame_buffer.h} +2 -2
  41. data/src/{ios → opengl/ios}/opengl.mm +3 -3
  42. data/src/{opengl.h → opengl/opengl.h} +2 -6
  43. data/src/{osx → opengl/osx}/opengl.mm +3 -3
  44. data/src/opengl/painter.cpp +1020 -0
  45. data/src/{render_buffer.cpp → opengl/render_buffer.cpp} +1 -1
  46. data/src/{render_buffer.h → opengl/render_buffer.h} +2 -2
  47. data/src/{sdl → opengl/sdl}/opengl.cpp +10 -3
  48. data/src/{shader.cpp → opengl/shader.cpp} +69 -53
  49. data/src/{shader.h → opengl/shader.h} +12 -8
  50. data/src/{shader_program.cpp → opengl/shader_program.cpp} +24 -10
  51. data/src/{shader_program.h → opengl/shader_program.h} +4 -3
  52. data/src/{shader_source.cpp → opengl/shader_source.cpp} +2 -4
  53. data/src/{shader_source.h → opengl/shader_source.h} +2 -2
  54. data/src/{texture.cpp → opengl/texture.cpp} +18 -7
  55. data/src/opengl/texture.h +21 -0
  56. data/src/{win32 → opengl/win32}/opengl.cpp +4 -3
  57. data/src/osx/bitmap.mm +6 -34
  58. data/src/osx/rays.mm +3 -3
  59. data/src/painter.cpp +96 -925
  60. data/src/painter.h +223 -11
  61. data/src/polygon.cpp +38 -13
  62. data/src/renderer.h +22 -0
  63. data/src/sdl/bitmap.cpp +5 -33
  64. data/src/sdl/font.cpp +358 -9
  65. data/src/sdl/rays.cpp +8 -3
  66. data/src/texture.h +6 -3
  67. data/src/win32/bitmap.cpp +6 -34
  68. data/src/win32/rays.cpp +3 -3
  69. data/test/test_painter.rb +36 -25
  70. data/test/test_painter_batch.rb +254 -0
  71. metadata +31 -24
  72. /data/src/{opengl.cpp → opengl/opengl.cpp} +0 -0
data/src/osx/bitmap.mm CHANGED
@@ -5,10 +5,8 @@
5
5
  #import <Cocoa/Cocoa.h>
6
6
  #include <xot/util.h>
7
7
  #include "rays/exception.h"
8
- #include "../color_space.h"
9
8
  #include "../font.h"
10
9
  #include "../texture.h"
11
- #include "../frame_buffer.h"
12
10
 
13
11
 
14
12
  namespace Rays
@@ -130,11 +128,10 @@ namespace Rays
130
128
  };// Bitmap::Data
131
129
 
132
130
 
133
- static void
134
- setup_bitmap (
135
- Bitmap* bitmap,
136
- int w, int h, const ColorSpace& cs,
137
- const void* pixels = NULL, bool clear_pixels = true)
131
+ void
132
+ Bitmap_setup (
133
+ Bitmap* bitmap, int w, int h, const ColorSpace& cs,
134
+ const void* pixels, bool clear_pixels)
138
135
  {
139
136
  if (w <= 0)
140
137
  argument_error(__FILE__, __LINE__);
@@ -161,31 +158,6 @@ namespace Rays
161
158
  memset(self->pixels, 0, size);
162
159
  }
163
160
 
164
- Bitmap
165
- Bitmap_from (const Texture& tex)
166
- {
167
- if (!tex)
168
- argument_error(__FILE__, __LINE__);
169
-
170
- Bitmap bmp;
171
- setup_bitmap(
172
- &bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
173
-
174
- GLenum format, type;
175
- ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
176
-
177
- FrameBuffer fb(tex);
178
- FrameBufferBinder binder(fb.id());
179
-
180
- for (int y = 0; y < bmp.height(); ++y)
181
- {
182
- GLvoid* ptr = (GLvoid*) bmp.at<uchar>(0, y);
183
- glReadPixels(0, y, bmp.width(), 1, format, type, ptr);
184
- }
185
-
186
- return bmp;
187
- }
188
-
189
161
  void
190
162
  Bitmap_draw_image (
191
163
  Bitmap* bitmap, CGImageRef image,
@@ -291,7 +263,7 @@ namespace Rays
291
263
 
292
264
  NSString* path = [NSString stringWithUTF8String: path_];
293
265
  NSBitmapImageRep* imagerep =
294
- [NSBitmapImageRep imageRepWithContentsOfFile: path];
266
+ (NSBitmapImageRep*) [NSBitmapImageRep imageRepWithContentsOfFile: path];
295
267
  if (!imagerep)
296
268
  rays_error(__FILE__, __LINE__, "[NSBitmapImageRep imageRepWithContentsOfFile] failed.");
297
269
 
@@ -318,7 +290,7 @@ namespace Rays
318
290
  Bitmap::Bitmap (
319
291
  int width, int height, const ColorSpace& color_space, const void* pixels)
320
292
  {
321
- setup_bitmap(this, width, height, color_space, pixels);
293
+ Bitmap_setup(this, width, height, color_space, pixels);
322
294
  }
323
295
 
324
296
  Bitmap::~Bitmap ()
data/src/osx/rays.mm CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  #import <Foundation/Foundation.h>
6
6
  #include "rays/exception.h"
7
- #include "../opengl.h"
7
+ #include "../renderer.h"
8
8
 
9
9
 
10
10
  namespace Rays
@@ -29,7 +29,7 @@ namespace Rays
29
29
 
30
30
  global::pool = [[NSAutoreleasePool alloc] init];
31
31
 
32
- OpenGL_init();
32
+ Renderer_init();
33
33
  }
34
34
 
35
35
  void
@@ -38,7 +38,7 @@ namespace Rays
38
38
  if (!global::pool)
39
39
  rays_error(__FILE__, __LINE__, "not initialized.");
40
40
 
41
- OpenGL_fin();
41
+ Renderer_fin();
42
42
 
43
43
  [global::pool release];
44
44
  global::pool = nil;