rays 0.1.49 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a16981d77f0cc82e3020f1a80757dc7620da39d9b309823b47b8dc49883128a
4
- data.tar.gz: 0bffdff4eceb4b60326882341d2fd3f0b2ff583dabfbab05f28127b276a4ab83
3
+ metadata.gz: 9a7045b85aab21570ba6c4f816ea00a7638f39645d0b3393ae9ba93d14110be1
4
+ data.tar.gz: 8492b40089c9a7da4336b72e059b4e189739d4510a0abc2a76ec775a9297bc80
5
5
  SHA512:
6
- metadata.gz: 2e417b9f4f751adeda1108ed76818171896caf4476188a7b3e9116e81f3d1a5d2c9e023e092b202a81c48f6a7a17faed7b388a5cf8211363350efe351f3b3df5
7
- data.tar.gz: 33ff8e0b58b215a1e654fcc9aec4864e35a004a5470f412ce0cec7b0a81865b5d8dad003367ee6630fde11e34fb43b83e0c5f973d0d0f0fbe5cdd00795ef1255
6
+ metadata.gz: 3d48296b01c547a877506077fba4c3b30dae52d74589b947877e8ffc3cf62113619041e7d47d3073222af2ce5dfdc1559004ad08477b5c117c30fbae76a03f68
7
+ data.tar.gz: 73b031ed35d8519e3ebcf4745d18868fe3ac61559d6159f10aa2e0a2a267051ba5d76bd7f61b28b7427cbc4b1b64da2e4e3f8cf5a066c3bb98d578a69adb64a0
@@ -560,7 +560,7 @@ VALUE get_pixels(VALUE self)
560
560
 
561
561
  std::vector<VALUE> pixels;
562
562
  get_pixels(&pixels, *THIS);
563
- return value(pixels.size(), (const Value*) &pixels[0]);
563
+ return array((const Value*) &pixels[0], pixels.size());
564
564
  }
565
565
 
566
566
  static
@@ -127,7 +127,7 @@ VALUE device_names(VALUE self)
127
127
  std::vector<Value> v;
128
128
  for (const auto& name : names)
129
129
  v.emplace_back(name.c_str());
130
- return value(v.size(), &v[0]);
130
+ return array(&v[0], v.size());
131
131
  }
132
132
 
133
133
 
@@ -13,7 +13,7 @@ Init_rays_exception ()
13
13
  {
14
14
  Module mRays = rb_define_module("Rays");
15
15
 
16
- cRaysError = rb_define_class_under(mRays, "RaysError", rb_eRuntimeError);
16
+ cRaysError = rb_define_class_under(mRays, "RaysError", rb_eStandardError);
17
17
  cOpenGLError = rb_define_class_under(mRays, "OpenGLError", cRaysError);
18
18
  cShaderError = rb_define_class_under(mRays, "ShaderError", cOpenGLError);
19
19
  }
@@ -109,7 +109,7 @@ VALUE families(VALUE self)
109
109
  std::vector<Value> members;
110
110
  for (const auto& member : family.second)
111
111
  members.emplace_back(member.c_str());
112
- hash.set(family.first.c_str(), value(members.size(), &members[0]));
112
+ hash.set(family.first.c_str(), array(&members[0], members.size()));
113
113
  }
114
114
  return hash;
115
115
  }
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: 3.2
16
16
 
17
17
  - name: checkout
18
- uses: actions/checkout@v2
18
+ uses: actions/checkout@v4
19
19
 
20
20
  - name: setup gems
21
21
  run: bundle install
@@ -15,7 +15,7 @@ jobs:
15
15
  ruby-version: 3.2
16
16
 
17
17
  - name: checkout
18
- uses: actions/checkout@v2
18
+ uses: actions/checkout@v4
19
19
  with:
20
20
  fetch-depth: 0
21
21
  token: ${{ secrets.PAT }}
@@ -16,7 +16,7 @@ jobs:
16
16
  ruby-version: 3.2
17
17
 
18
18
  - name: checkout
19
- uses: actions/checkout@v2
19
+ uses: actions/checkout@v4
20
20
 
21
21
  - name: setup gems
22
22
  run: bundle install
@@ -24,5 +24,11 @@ jobs:
24
24
  - name: setup dependencies
25
25
  run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
26
26
 
27
+ - name: lib
28
+ run: bundle exec rake lib
29
+
30
+ - name: ext
31
+ run: bundle exec rake ext
32
+
27
33
  - name: test
28
34
  run: bundle exec rake test
data/ChangeLog.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.2.1] - 2024-07-05
5
+
6
+ - Add OpenGL_init() and OpenGL_fin()
7
+ - Add activate_offscreen_context()
8
+ - Do not redefine fin!() methods, they are no longer needed
9
+ - Update workflows for test
10
+ - Update to actions/checkout@v4
11
+
12
+
13
+ ## [v0.2] - 2024-03-14
14
+
15
+ - Change the super class for exception class from RuntimeError to StandardError
16
+ - Fix compile errors on iOS
17
+
18
+
4
19
  ## [v0.1.49] - 2024-02-07
5
20
 
6
21
  - Add point(), line_height(), and line_height!() to Painter
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GEM
9
9
 
10
10
  PLATFORMS
11
11
  arm64-darwin-21
12
- x86_64-darwin-20
12
+ arm64-darwin-22
13
13
 
14
14
  DEPENDENCIES
15
15
  rake
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.49
1
+ 0.2.1
data/ext/rays/bitmap.cpp CHANGED
@@ -567,7 +567,7 @@ RUCY_DEF0(get_pixels)
567
567
 
568
568
  std::vector<VALUE> pixels;
569
569
  get_pixels(&pixels, *THIS);
570
- return value(pixels.size(), (const Value*) &pixels[0]);
570
+ return array((const Value*) &pixels[0], pixels.size());
571
571
  }
572
572
  RUCY_END
573
573
 
data/ext/rays/camera.cpp CHANGED
@@ -141,7 +141,7 @@ RUCY_DEF0(device_names)
141
141
  std::vector<Value> v;
142
142
  for (const auto& name : names)
143
143
  v.emplace_back(name.c_str());
144
- return value(v.size(), &v[0]);
144
+ return array(&v[0], v.size());
145
145
  }
146
146
  RUCY_END
147
147
 
@@ -13,7 +13,7 @@ Init_rays_exception ()
13
13
  {
14
14
  Module mRays = define_module("Rays");
15
15
 
16
- cRaysError = mRays.define_class("RaysError", rb_eRuntimeError);
16
+ cRaysError = mRays.define_class("RaysError", rb_eStandardError);
17
17
  cOpenGLError = mRays.define_class("OpenGLError", cRaysError);
18
18
  cShaderError = mRays.define_class("ShaderError", cOpenGLError);
19
19
  }
data/ext/rays/font.cpp CHANGED
@@ -120,7 +120,7 @@ RUCY_DEF0(families)
120
120
  std::vector<Value> members;
121
121
  for (const auto& member : family.second)
122
122
  members.emplace_back(member.c_str());
123
- hash.set(family.first.c_str(), value(members.size(), &members[0]));
123
+ hash.set(family.first.c_str(), array(&members[0], members.size()));
124
124
  }
125
125
  return hash;
126
126
  }
@@ -56,13 +56,13 @@ namespace Rays
56
56
 
57
57
  ColorSpaceType type () const;
58
58
 
59
- int bpc () const;
59
+ int bpc () const;// bits per channel
60
60
 
61
- int Bpc () const;
61
+ int Bpc () const;// bytes per channel
62
62
 
63
- int bpp () const;
63
+ int bpp () const;// bits per pixel
64
64
 
65
- int Bpp () const;
65
+ int Bpp () const;// bytes per pixel
66
66
 
67
67
  int alpha_pos () const;
68
68
 
data/include/rays/rays.h CHANGED
@@ -11,11 +11,19 @@ namespace Rays
11
11
  {
12
12
 
13
13
 
14
+ typedef void* Context;
15
+
16
+
14
17
  void init ();
15
18
 
16
19
  void fin ();
17
20
 
18
21
 
22
+ Context get_offscreen_context ();
23
+
24
+ void activate_offscreen_context ();
25
+
26
+
19
27
  }// Rays
20
28
 
21
29
 
data/include/rays/ruby.h CHANGED
@@ -4,8 +4,8 @@
4
4
  #define __RAYS_RUBY_H__
5
5
 
6
6
 
7
- #include <rays/ruby/rays.h>
8
7
  #include <rays/ruby/defs.h>
8
+ #include <rays/ruby/rays.h>
9
9
  #include <rays/ruby/exception.h>
10
10
 
11
11
  #include <rays/ruby/point.h>
@@ -23,5 +23,7 @@
23
23
 
24
24
  #include <rays/ruby/painter.h>
25
25
 
26
+ #include <rays/ruby/camera.h>
27
+
26
28
 
27
29
  #endif//EOH
data/include/rays.h CHANGED
@@ -25,5 +25,8 @@
25
25
 
26
26
  #include <rays/painter.h>
27
27
 
28
+ #include <rays/camera.h>
29
+ #include <rays/util.h>
30
+
28
31
 
29
32
  #endif//EOH
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.1.42'
29
- s.add_runtime_dependency 'rucy', '~> 0.1.44'
28
+ s.add_runtime_dependency 'xot', '~> 0.2.1'
29
+ s.add_runtime_dependency 'rucy', '~> 0.2.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/image.cpp CHANGED
@@ -56,33 +56,6 @@ namespace Rays
56
56
  if (self->texture) self->texture.set_modified(false);
57
57
  }
58
58
 
59
- static void
60
- invalidate_texture (Image* image)
61
- {
62
- image->bitmap();// update bitmap
63
- image->self->texture = Texture();
64
- }
65
-
66
- static void
67
- invalidate_texture_for_another_context (Image* image)
68
- {
69
- assert(image);
70
-
71
- const Texture& tex = image->self->texture;
72
- if (!tex) return;
73
-
74
- Context tex_context = tex.context();
75
- if (!tex_context) return;
76
-
77
- Context current_context = OpenGL_get_context();
78
- if (tex_context == current_context)
79
- return;
80
-
81
- OpenGL_set_context(tex_context);
82
- invalidate_texture(image);
83
- OpenGL_set_context(current_context);
84
- }
85
-
86
59
  static Bitmap&
87
60
  get_bitmap (Image* image)
88
61
  {
@@ -139,8 +112,6 @@ namespace Rays
139
112
  return self->texture;
140
113
  }
141
114
 
142
- invalidate_texture_for_another_context(&image);
143
-
144
115
  if (!self->texture)
145
116
  {
146
117
  if (self->bitmap)
data/src/ios/opengl.mm CHANGED
@@ -2,34 +2,47 @@
2
2
  #include "../opengl.h"
3
3
 
4
4
 
5
- #include <vector>
6
5
  #import <OpenGLES/EAGL.h>
6
+ #include "rays/rays.h"
7
+ #include "rays/exception.h"
7
8
 
8
9
 
9
10
  namespace Rays
10
11
  {
11
12
 
12
13
 
14
+ static EAGLContext*
15
+ get_opengl_offscreen_context ()
16
+ {
17
+ static EAGLContext* context = nil;
18
+ if (!context)
19
+ context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES3];
20
+ return context;
21
+ }
22
+
23
+
13
24
  void
14
- OpenGL_set_context (Context context)
25
+ OpenGL_init ()
15
26
  {
16
- [EAGLContext setCurrentContext: (EAGLContext*) context];
27
+ activate_offscreen_context();
17
28
  }
18
29
 
19
- Context
20
- OpenGL_get_context ()
30
+ void
31
+ OpenGL_fin ()
21
32
  {
22
- return [EAGLContext currentContext];
23
33
  }
24
34
 
25
35
 
26
36
  Context
27
37
  get_offscreen_context ()
28
38
  {
29
- static Context context = NULL;
30
- if (!context)
31
- context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES3];
32
- return context;
39
+ return get_opengl_offscreen_context();
40
+ }
41
+
42
+ void
43
+ activate_offscreen_context ()
44
+ {
45
+ [EAGLContext setCurrentContext: get_opengl_offscreen_context()];
33
46
  }
34
47
 
35
48
 
data/src/ios/rays.mm CHANGED
@@ -29,7 +29,7 @@ namespace Rays
29
29
 
30
30
  global::pool = [[NSAutoreleasePool alloc] init];
31
31
 
32
- OpenGL_set_context(get_offscreen_context());
32
+ OpenGL_init();
33
33
  }
34
34
 
35
35
  void
@@ -38,6 +38,8 @@ namespace Rays
38
38
  if (!global::pool)
39
39
  rays_error(__FILE__, __LINE__, "Rays::fin(): not initialized.");
40
40
 
41
+ OpenGL_fin();
42
+
41
43
  [global::pool release];
42
44
  global::pool = nil;
43
45
  }
data/src/opengl.h CHANGED
@@ -15,22 +15,22 @@
15
15
  #include <GL/glext.h>
16
16
  #endif
17
17
 
18
- #include "rays/opengl.h"
18
+ #include "rays/defs.h"
19
19
 
20
20
 
21
21
  namespace Rays
22
22
  {
23
23
 
24
24
 
25
- void OpenGL_set_context (Context context);
25
+ void OpenGL_init ();
26
26
 
27
- Context OpenGL_get_context ();
27
+ void OpenGL_fin ();
28
28
 
29
- bool OpenGL_has_error ();
29
+ bool OpenGL_has_error ();
30
30
 
31
- void OpenGL_check_error (const char* file, int line);
31
+ void OpenGL_check_error (const char* file, int line);
32
32
 
33
- void OpenGL_check_error (const char* file, int line, const char* format, ...);
33
+ void OpenGL_check_error (const char* file, int line, const char* format, ...);
34
34
 
35
35
 
36
36
  }// Rays
data/src/osx/opengl.mm CHANGED
@@ -3,30 +3,18 @@
3
3
 
4
4
 
5
5
  #import <AppKit/AppKit.h>
6
+ #include "rays/rays.h"
7
+ #include "rays/exception.h"
6
8
 
7
9
 
8
10
  namespace Rays
9
11
  {
10
12
 
11
13
 
12
- void
13
- OpenGL_set_context (Context context)
14
- {
15
- NSOpenGLContext* c = (NSOpenGLContext*) context;
16
- [c makeCurrentContext];
17
- }
18
-
19
- Context
20
- OpenGL_get_context ()
14
+ static NSOpenGLContext*
15
+ get_opengl_offscreen_context ()
21
16
  {
22
- return [NSOpenGLContext currentContext];
23
- }
24
-
25
-
26
- Context
27
- get_offscreen_context ()
28
- {
29
- static Context context = NULL;
17
+ static NSOpenGLContext* context = nil;
30
18
  if (!context)
31
19
  {
32
20
  NSOpenGLPixelFormatAttribute attribs[] =
@@ -44,11 +32,35 @@ namespace Rays
44
32
  };
45
33
  NSOpenGLPixelFormat* pf = [[[NSOpenGLPixelFormat alloc]
46
34
  initWithAttributes: attribs] autorelease];
47
- context = [[[NSOpenGLContext alloc]
48
- initWithFormat: pf shareContext: nil] autorelease];
35
+ context = [[NSOpenGLContext alloc] initWithFormat: pf shareContext: nil];
49
36
  }
50
37
  return context;
51
38
  }
52
39
 
53
40
 
41
+ void
42
+ OpenGL_init ()
43
+ {
44
+ activate_offscreen_context();
45
+ }
46
+
47
+ void
48
+ OpenGL_fin ()
49
+ {
50
+ }
51
+
52
+
53
+ Context
54
+ get_offscreen_context ()
55
+ {
56
+ return get_opengl_offscreen_context();
57
+ }
58
+
59
+ void
60
+ activate_offscreen_context ()
61
+ {
62
+ [get_opengl_offscreen_context() makeCurrentContext];
63
+ }
64
+
65
+
54
66
  }// Rays
data/src/osx/rays.mm CHANGED
@@ -29,7 +29,7 @@ namespace Rays
29
29
 
30
30
  global::pool = [[NSAutoreleasePool alloc] init];
31
31
 
32
- OpenGL_set_context(get_offscreen_context());
32
+ OpenGL_init();
33
33
  }
34
34
 
35
35
  void
@@ -38,6 +38,8 @@ namespace Rays
38
38
  if (!global::pool)
39
39
  rays_error(__FILE__, __LINE__, "Rays::fin(): not initialized.");
40
40
 
41
+ OpenGL_fin();
42
+
41
43
  [global::pool release];
42
44
  global::pool = nil;
43
45
  }
data/src/painter.cpp CHANGED
@@ -1236,7 +1236,7 @@ namespace Rays
1236
1236
  Painter* painter, const Font& font,
1237
1237
  const char* line, coord x, coord y, coord width = 0, coord height = 0)
1238
1238
  {
1239
- assert(painter && font && str && *str != '\0');
1239
+ assert(painter && font && line && *line != '\0');
1240
1240
 
1241
1241
  Painter::Data* self = painter->self.get();
1242
1242
 
data/src/texture.cpp CHANGED
@@ -17,8 +17,6 @@ namespace Rays
17
17
  struct Texture::Data
18
18
  {
19
19
 
20
- Context context = NULL;
21
-
22
20
  GLuint id = 0;
23
21
 
24
22
  int width, height, width_pow2, height_pow2;
@@ -53,22 +51,15 @@ namespace Rays
53
51
  {
54
52
  if (!has_id()) return;
55
53
 
56
- Context current_context = OpenGL_get_context();
57
-
58
- assert(context);
59
- OpenGL_set_context(context);
60
-
61
54
  glDeleteTextures(1, &id);
55
+ OpenGL_check_error(__FILE__, __LINE__);
62
56
 
63
- OpenGL_set_context(current_context);
64
-
65
- context = NULL;
66
- id = 0;
57
+ id = 0;
67
58
  }
68
59
 
69
60
  bool has_id () const
70
61
  {
71
- return context && id > 0;
62
+ return id > 0;
72
63
  }
73
64
 
74
65
  };// Texture::Data
@@ -185,13 +176,6 @@ namespace Rays
185
176
  {
186
177
  assert(self && !self->has_id());
187
178
 
188
- if (self->context)
189
- invalid_state_error(__FILE__, __LINE__);
190
-
191
- self->context = OpenGL_get_context();
192
- if (!self->context)
193
- opengl_error(__FILE__, __LINE__);
194
-
195
179
  glGenTextures(1, &self->id);
196
180
  glBindTexture(GL_TEXTURE_2D, self->id);
197
181
  if (glIsTexture(self->id) == GL_FALSE)
@@ -313,12 +297,6 @@ namespace Rays
313
297
  return self->color_space;
314
298
  }
315
299
 
316
- Context
317
- Texture::context () const
318
- {
319
- return self->context;
320
- }
321
-
322
300
  GLuint
323
301
  Texture::id () const
324
302
  {
data/src/texture.h CHANGED
@@ -42,8 +42,6 @@ namespace Rays
42
42
 
43
43
  const ColorSpace& color_space () const;
44
44
 
45
- Context context () const;
46
-
47
45
  GLuint id () const;
48
46
 
49
47
  void set_modified (bool modified = true);
data/src/win32/gdi.cpp CHANGED
@@ -43,10 +43,8 @@ namespace Rays
43
43
 
44
44
  typedef HANDLE Handle;
45
45
 
46
- HandleObject (
47
- Handle handle = NULL, bool owner = true,
48
- DeleteHandleFunc delfun = delete_object)
49
- : handle_(handle), delfun_(delfun)
46
+ HandleObject ()
47
+ : handle_(NULL), delfun_(NULL)
50
48
  {
51
49
  }
52
50
 
data/test/helper.rb CHANGED
@@ -10,11 +10,6 @@ require 'test/unit'
10
10
  include Xot::Test
11
11
 
12
12
 
13
- unless defined?($RAYS_NOAUTOINIT) && $RAYS_NOAUTOINIT
14
- def Rays.fin!() end
15
- end
16
-
17
-
18
13
  def assert_equal_color(c1, c2, delta = 0.000001)
19
14
  assert_in_delta c1.r, c2.r, delta
20
15
  assert_in_delta c1.g, c2.g, delta
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.1.49
4
+ version: 0.2.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-02-06 00:00:00.000000000 Z
11
+ date: 2024-07-05 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.1.42
19
+ version: 0.2.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.1.42
26
+ version: 0.2.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.1.44
33
+ version: 0.2.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.1.44
40
+ version: 0.2.1
41
41
  description: This library helps you to develop graphics application with OpenGL.
42
42
  email: xordog@gmail.com
43
43
  executables: []
@@ -125,7 +125,6 @@ files:
125
125
  - include/rays/font.h
126
126
  - include/rays/image.h
127
127
  - include/rays/matrix.h
128
- - include/rays/opengl.h
129
128
  - include/rays/painter.h
130
129
  - include/rays/point.h
131
130
  - include/rays/polygon.h
@@ -1,20 +0,0 @@
1
- // -*- c++ -*-
2
- #pragma once
3
- #ifndef __RAYS_OPENGL_H__
4
- #define __RAYS_OPENGL_H__
5
-
6
-
7
- namespace Rays
8
- {
9
-
10
-
11
- typedef void* Context;
12
-
13
-
14
- Context get_offscreen_context ();
15
-
16
-
17
- }// Rays
18
-
19
-
20
- #endif//EOH