rays 0.3.10 → 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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/rays/polygon.cpp +1 -1
  3. data/.github/workflows/release-gem.yml +1 -1
  4. data/.github/workflows/test.yml +4 -4
  5. data/ChangeLog.md +7 -0
  6. data/Gemfile.lock +6 -5
  7. data/VERSION +1 -1
  8. data/ext/rays/polygon.cpp +1 -1
  9. data/rays.gemspec +2 -2
  10. data/src/bitmap.h +4 -0
  11. data/src/color_space.cpp +1 -41
  12. data/src/image.cpp +0 -1
  13. data/src/ios/bitmap.mm +5 -32
  14. data/src/ios/rays.mm +3 -3
  15. data/src/opengl/bitmap.cpp +41 -0
  16. data/src/opengl/color_space.cpp +51 -0
  17. data/src/{color_space.h → opengl/color_space.h} +2 -2
  18. data/src/{frame_buffer.cpp → opengl/frame_buffer.cpp} +1 -1
  19. data/src/{frame_buffer.h → opengl/frame_buffer.h} +2 -2
  20. data/src/{ios → opengl/ios}/opengl.mm +3 -3
  21. data/src/{opengl.h → opengl/opengl.h} +2 -6
  22. data/src/{osx → opengl/osx}/opengl.mm +3 -3
  23. data/src/opengl/painter.cpp +756 -0
  24. data/src/{render_buffer.h → opengl/render_buffer.h} +2 -2
  25. data/src/{sdl → opengl/sdl}/opengl.cpp +4 -3
  26. data/src/{shader.cpp → opengl/shader.cpp} +1 -2
  27. data/src/{shader.h → opengl/shader.h} +2 -2
  28. data/src/{shader_program.cpp → opengl/shader_program.cpp} +3 -3
  29. data/src/{shader_program.h → opengl/shader_program.h} +2 -2
  30. data/src/{shader_source.h → opengl/shader_source.h} +2 -2
  31. data/src/{texture.cpp → opengl/texture.cpp} +2 -3
  32. data/src/opengl/texture.h +21 -0
  33. data/src/{win32 → opengl/win32}/opengl.cpp +4 -3
  34. data/src/osx/bitmap.mm +5 -33
  35. data/src/osx/rays.mm +3 -3
  36. data/src/painter.cpp +21 -905
  37. data/src/painter.h +210 -11
  38. data/src/polygon.cpp +38 -13
  39. data/src/renderer.h +22 -0
  40. data/src/sdl/bitmap.cpp +5 -33
  41. data/src/sdl/rays.cpp +3 -3
  42. data/src/texture.h +0 -3
  43. data/src/win32/bitmap.cpp +6 -34
  44. data/src/win32/rays.cpp +3 -3
  45. metadata +29 -24
  46. /data/src/{opengl.cpp → opengl/opengl.cpp} +0 -0
  47. /data/src/{render_buffer.cpp → opengl/render_buffer.cpp} +0 -0
  48. /data/src/{shader_source.cpp → opengl/shader_source.cpp} +0 -0
@@ -1,7 +1,7 @@
1
1
  // -*- c++ -*-
2
2
  #pragma once
3
- #ifndef __RAYS_SRC_RENDER_BUFFER_H__
4
- #define __RAYS_SRC_RENDER_BUFFER_H__
3
+ #ifndef __RAYS_SRC_OPENGL_RENDER_BUFFER_H__
4
+ #define __RAYS_SRC_OPENGL_RENDER_BUFFER_H__
5
5
 
6
6
 
7
7
  #include <xot/pimpl.h>
@@ -1,7 +1,8 @@
1
- #include "../opengl.h"
1
+ #include "../../renderer.h"
2
2
 
3
3
 
4
4
  #include <SDL.h>
5
+ #include "../opengl.h"
5
6
  #include "rays/rays.h"
6
7
  #include "rays/exception.h"
7
8
 
@@ -66,7 +67,7 @@ namespace Rays
66
67
 
67
68
 
68
69
  void
69
- OpenGL_init ()
70
+ Renderer_init ()
70
71
  {
71
72
  activate_offscreen_context();
72
73
 
@@ -80,7 +81,7 @@ namespace Rays
80
81
  }
81
82
 
82
83
  void
83
- OpenGL_fin ()
84
+ Renderer_fin ()
84
85
  {
85
86
  }
86
87
 
@@ -3,8 +3,7 @@
3
3
 
4
4
  #include <assert.h>
5
5
  #include "rays/exception.h"
6
- #include "opengl.h"
7
- #include "image.h"
6
+ #include "../image.h"
8
7
  #include "shader_program.h"
9
8
  #include "shader_source.h"
10
9
 
@@ -1,7 +1,7 @@
1
1
  // -*- c++ -*-
2
2
  #pragma once
3
- #ifndef __RAYS_SRC_SHADER_H__
4
- #define __RAYS_SRC_SHADER_H__
3
+ #ifndef __RAYS_SRC_OPENGL_SHADER_H__
4
+ #define __RAYS_SRC_OPENGL_SHADER_H__
5
5
 
6
6
 
7
7
  #include "rays/shader.h"
@@ -7,9 +7,9 @@
7
7
  #include <algorithm>
8
8
  #include "rays/shader.h"
9
9
  #include "rays/exception.h"
10
- #include "shader_source.h"
10
+ #include "../painter.h"
11
11
  #include "texture.h"
12
- #include "painter.h"
12
+ #include "shader_source.h"
13
13
 
14
14
 
15
15
  namespace Rays
@@ -169,7 +169,7 @@ namespace Rays
169
169
  shader_error(__FILE__, __LINE__, "texture unit must be less than %d", max);
170
170
 
171
171
  glActiveTexture(GL_TEXTURE0 + unit);
172
- glBindTexture(GL_TEXTURE_2D, texture.id());
172
+ glBindTexture(GL_TEXTURE_2D, Texture_get_id(texture));
173
173
  glUniform1i(location, unit);
174
174
  return !OpenGL_has_error();
175
175
  }
@@ -1,7 +1,7 @@
1
1
  // -*- c++ -*-
2
2
  #pragma once
3
- #ifndef __RAYS_SRC_SHADER_PROGRAM_H__
4
- #define __RAYS_SRC_SHADER_PROGRAM_H__
3
+ #ifndef __RAYS_SRC_OPENGL_SHADER_PROGRAM_H__
4
+ #define __RAYS_SRC_OPENGL_SHADER_PROGRAM_H__
5
5
 
6
6
 
7
7
  #include <xot/pimpl.h>
@@ -1,7 +1,7 @@
1
1
  // -*- c++ -*-
2
2
  #pragma once
3
- #ifndef __RAYS_SRC_SHADER_SOURCE_H__
4
- #define __RAYS_SRC_SHADER_SOURCE_H__
3
+ #ifndef __RAYS_SRC_OPENGL_SHADER_SOURCE_H__
4
+ #define __RAYS_SRC_OPENGL_SHADER_SOURCE_H__
5
5
 
6
6
 
7
7
  #include <xot/pimpl.h>
@@ -5,7 +5,6 @@
5
5
  #include "rays/exception.h"
6
6
  #include "rays/bitmap.h"
7
7
  #include "rays/debug.h"
8
- #include "opengl.h"
9
8
  #include "color_space.h"
10
9
  #include "frame_buffer.h"
11
10
 
@@ -320,9 +319,9 @@ namespace Rays
320
319
  }
321
320
 
322
321
  GLuint
323
- Texture::id () const
322
+ Texture_get_id (const Texture& texture)
324
323
  {
325
- return self->id;
324
+ return texture.self->id;
326
325
  }
327
326
 
328
327
  void
@@ -0,0 +1,21 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __RAYS_SRC_OPENGL_TEXTURE_H__
4
+ #define __RAYS_SRC_OPENGL_TEXTURE_H__
5
+
6
+
7
+ #include "../texture.h"
8
+ #include "opengl.h"
9
+
10
+
11
+ namespace Rays
12
+ {
13
+
14
+
15
+ GLuint Texture_get_id (const Texture& texture);
16
+
17
+
18
+ }// Rays
19
+
20
+
21
+ #endif//EOH
@@ -1,7 +1,8 @@
1
- #include "../opengl.h"
1
+ #include "../../renderer.h"
2
2
 
3
3
 
4
4
  #include <xot/windows.h>
5
+ #include "../opengl.h"
5
6
  #include "rays/rays.h"
6
7
  #include "rays/exception.h"
7
8
 
@@ -90,7 +91,7 @@ namespace Rays
90
91
  }
91
92
 
92
93
  void
93
- OpenGL_init ()
94
+ Renderer_init ()
94
95
  {
95
96
  activate_offscreen_context();
96
97
 
@@ -104,7 +105,7 @@ namespace Rays
104
105
  }
105
106
 
106
107
  void
107
- OpenGL_fin ()
108
+ Renderer_fin ()
108
109
  {
109
110
  }
110
111
 
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,
@@ -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;