mittsu-opengl 0.5.0 → 0.5.2

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: 4e7dcdd16e617a5dba81651c8659900a50658a4afe821fd1c1a61becc1dbd16c
4
- data.tar.gz: 76f40de34ce32ba54723c9dc01bae1c78069699e6382cd4f66201208e55df50e
3
+ metadata.gz: e62e95a332b6331b5f61233675726f151f1e213adf6de2e7b2c644ab9a067e9a
4
+ data.tar.gz: 647bc7862a275d145e9eff671a990bb6198a38564f17733451c6408846a58c58
5
5
  SHA512:
6
- metadata.gz: 066d35853b5318962f280a29cdf4b6b84799372e474ed4adbbaf3f8debaa9212e151cec32c14ad7e63d03a467a5e6674e01504b721eabe71562c46e8cf8f6745
7
- data.tar.gz: b7e4970b8cde00849fd17bfd6d35df48b3e8f60be789d631e60d05b8e85dd939e9b3973fe06b4fe326f9f3e2e261cc3e86f4e26222ac6d120df7803a64df58b1
6
+ metadata.gz: 889ed8f51df14f9a3d237882ce45e70e83e4fec5dd3e7af8a141580ed1c11123cf6e8bd686aa6b5b3ba6d195818aef352339884b0f643e84198076c47162bcf8
7
+ data.tar.gz: dccf5113e0f36c4829500d4884ac408690b72574af6d5c6a0efc9eb2c3b4f9e4c3e07edd42bd68cf3a5209286e16a2e0027c3527a3c4ce114d10b990d489f4ff
@@ -9,11 +9,12 @@ on:
9
9
 
10
10
  jobs:
11
11
  linux:
12
+ continue-on-error: ${{ matrix.ruby == 'head' }}
12
13
  name: Linux
13
14
  runs-on: ubuntu-latest
14
15
  strategy:
15
16
  matrix:
16
- ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
17
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head]
17
18
  steps:
18
19
  - uses: actions/checkout@v4
19
20
  - uses: awalsh128/cache-apt-pkgs-action@v1
@@ -24,8 +25,8 @@ jobs:
24
25
  ruby-version: ${{ matrix.ruby }}
25
26
  bundler-cache: true
26
27
  - name: Test & publish code coverage
27
- uses: paambaati/codeclimate-action@v2.2.1
28
- if: github.event_name == 'push'
28
+ uses: paambaati/codeclimate-action@v9.0.0
29
+ if: github.event_name == 'push' && matrix.ruby == '3.4'
29
30
  env:
30
31
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
31
32
  with:
@@ -35,11 +36,12 @@ jobs:
35
36
  run: bundle exec rake test
36
37
 
37
38
  macos:
39
+ continue-on-error: ${{ matrix.ruby == 'head' || matrix.ruby == 'jruby-head' || matrix.ruby == 'truffleruby-head' }}
38
40
  name: macOS
39
41
  runs-on: macos-latest
40
42
  strategy:
41
43
  matrix:
42
- ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
44
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head, jruby, jruby-head, truffleruby, truffleruby-head]
43
45
  steps:
44
46
  - uses: actions/checkout@v4
45
47
  - run: brew install glfw
@@ -50,13 +52,14 @@ jobs:
50
52
  - run: bundle exec rake test
51
53
 
52
54
  windows:
55
+ continue-on-error: ${{ matrix.ruby == 'head' }}
53
56
  name: Windows
54
57
  runs-on: windows-latest
55
58
  env:
56
59
  MITTSU_LIBGLFW_PATH: c:\projects\mittsu\glfw-3.3.1.bin.WIN32\lib-mingw
57
60
  strategy:
58
61
  matrix:
59
- ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
62
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', head]
60
63
  steps:
61
64
  - uses: actions/checkout@v4
62
65
  - run: .\install-glfw.ps1
data/.gitignore CHANGED
@@ -10,3 +10,7 @@
10
10
  /test/reports
11
11
  *.gem
12
12
  .tool-versions
13
+ **/*screenshot*.png
14
+ *.dylib
15
+ *.dll
16
+ *.so
data/Gemfile CHANGED
@@ -1,9 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem 'mittsu', path: '../mittsu'
6
-
7
- if /darwin/ === RUBY_PLATFORM
8
- gem 'ffi', '~> 1.9', '!= 1.11.1'
9
- end
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Mittsu
1
+ # Mittsu OpenGL Renderer
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/mittsu-opengl.svg)](https://badge.fury.io/rb/mittsu-opengl)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/XXX/test_coverage)](https://codeclimate.com/github/danini-the-panini/mittsu-opengl/test_coverage)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/XXX/maintainability)](https://codeclimate.com/github/danini-the-panini/mittsu-opengl/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/dd4137d5afd04077f4ec/test_coverage)](https://codeclimate.com/github/danini-the-panini/mittsu-opengl/test_coverage)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/dd4137d5afd04077f4ec/maintainability)](https://codeclimate.com/github/danini-the-panini/mittsu-opengl/maintainability)
6
6
  [![Build Status](https://github.com/danini-the-panini/mittsu-opengl/workflows/Build/badge.svg)](https://github.com/danini-the-panini/mittsu-opengl/actions?query=workflow%3A%22Build%22)
7
7
 
8
8
  OpenGL renderer for Mittsu
@@ -184,6 +184,14 @@ end
184
184
 
185
185
  If you just want to see what Mittsu can do and how to do it, take a peek inside the `examples` folder.
186
186
 
187
+ ### JRuby
188
+
189
+ JRuby support is still a work in progress. This is mainly due to subtle behavioural differences in Fiddle.
190
+
191
+ On macOS JRuby must be started with the `-J-XstartOnFirstThread` argument for GLFW to work. This is necessary because most GLFW functions must be called on the main thread and the Cocoa API requires that thread to be the first thread in the process. GLFW windows and the GLFW event loop are incompatible with other window toolkits (such as AWT/Swing or JavaFX).
192
+
193
+ (Otherwise you have to extract and use the custom `libglfw_async.dylib` from [LWJGL3](https://www.lwjgl.org))
194
+
187
195
  ## Contributing
188
196
 
189
197
  1. Fork it ( https://github.com/danini-the-panini/mittsu-opengl/fork )
@@ -4,7 +4,7 @@ require 'open3'
4
4
  module Mittsu
5
5
  module GenericLib
6
6
  def discover
7
- case GL.get_platform
7
+ case ::GL.get_platform
8
8
  when :OPENGL_PLATFORM_WINDOWS
9
9
  self::Windows.new
10
10
  when :OPENGL_PLATFORM_MACOSX
@@ -12,7 +12,7 @@ module Mittsu
12
12
  when :OPENGL_PLATFORM_LINUX
13
13
  self::Linux.new
14
14
  else
15
- warn "WARNING: Unsupported platform: #{GL.get_platform}"
15
+ warn "WARNING: Unsupported platform: #{::GL.get_platform}"
16
16
  Base.new
17
17
  end
18
18
  end
@@ -0,0 +1,28 @@
1
+ require 'glfw'
2
+
3
+ OriginalGLFW = ::GLFW
4
+
5
+ module GLFWDebug
6
+
7
+ OriginalGLFW.constants.each do |c|
8
+ const_set c, OriginalGLFW.const_get(c)
9
+ end
10
+
11
+ class << self
12
+ def load_lib(*args)
13
+ OriginalGLFW.load_lib(*args)
14
+ end
15
+
16
+ def method_missing(m, *args, **kwargs, &block)
17
+ argstr = args.map { |s| s.inspect[0..20] }
18
+ kwargstr = kwargs.map { |k, v| "#{k}: #{v.inspect[0..20]}" }
19
+ print "GLFW.#{m}(#{[*argstr, *kwargstr].join(', ')})"
20
+ r = OriginalGLFW.send(m, *args, **kwargs, &block)
21
+ ret = r ? '' : " => #{r}"
22
+ puts "#{ret} (#{caller[0]})"
23
+ r
24
+ end
25
+ end
26
+ end
27
+
28
+ GLFW = GLFWDebug
@@ -4,19 +4,19 @@ module Mittsu
4
4
  module GLFW
5
5
  module Lib
6
6
  extend GenericLib
7
-
7
+
8
8
  class Linux < GenericLib::Linux
9
9
  def initialize(loader = Linux)
10
10
  @loader = loader
11
11
  end
12
-
12
+
13
13
  class << self
14
14
  def lib_paths
15
15
  Dir.glob('/usr/lib*/**/libglfw*.so*')
16
16
  rescue
17
17
  []
18
18
  end
19
-
19
+
20
20
  def ldconfig
21
21
  out, stderr, _status = Open3.capture3("ldconfig -p | grep 'libglfw3\\?\\.so'")
22
22
  puts stderr if DEBUG
@@ -26,29 +26,28 @@ module Mittsu
26
26
  end
27
27
  end
28
28
  end
29
-
29
+
30
30
  class Windows < GenericLib::Base
31
31
  def path
32
32
  'glfw3.dll'
33
33
  end
34
34
  end
35
-
35
+
36
36
  class MacOS < GenericLib::Base
37
- SEARCH_GLOBS = ['/usr/local/lib/**',
38
- '/usr/lib/**',
39
- '/opt/homebrew/**']
40
-
37
+ SEARCH_GLOBS = ['/usr/local/Cellar/glfw/**',
38
+ '/opt/homebrew/Cellar/glfw/**']
39
+
41
40
  def path
42
41
  @_path ||= find_match&.to_s
43
42
  end
44
-
43
+
45
44
  private
46
-
45
+
47
46
  def find_match
48
47
  SEARCH_GLOBS.each do |glob|
49
48
  matches = Dir.glob("#{glob}/libglfw*.dylib")
50
49
  next if matches.empty?
51
-
50
+
52
51
  return matches.find { |m| m.end_with?('libglfw3.dylib') || m.end_with?('libglfw.3.dylib') } || matches.first
53
52
  end
54
53
  end
@@ -6,6 +6,8 @@ require 'mittsu/glfw/lib'
6
6
  glfw_lib = Mittsu::GLFW::Lib.discover
7
7
  ::GLFW.load_lib(ENV["MITTSU_LIBGLFW_PATH"] || glfw_lib.path, Mittsu.debug?) unless Mittsu.test?
8
8
 
9
+ require 'mittsu/glfw/debug' if Mittsu.debug?
10
+
9
11
  module Mittsu
10
12
  module GLFW
11
13
  class Window
@@ -8,7 +8,7 @@ opengl_lib = Mittsu::OpenGL::Lib.discover
8
8
  GL.load_lib(ENV["MITTSU_LIBGL_PATH"] || opengl_lib.path, Mittsu.debug?)
9
9
 
10
10
  require 'mittsu/glfw/window'
11
- require 'mittsu/opengl/gl_debug' if ENV['DEBUG']
11
+ require 'mittsu/opengl/gl_debug' if Mittsu.debug?
12
12
  require 'mittsu/opengl/implementation'
13
13
  require 'mittsu/opengl/gl_extensions'
14
14
  require 'mittsu/opengl/helper'
@@ -35,7 +35,7 @@ module Mittsu
35
35
  attr_reader :logarithmic_depth_buffer, :programs, :light_renderer, :proj_screen_matrix
36
36
 
37
37
  def initialize(parameters = {})
38
- puts "Mittsu OpenGL Renderer #{VERSION}"
38
+ puts "Mittsu OpenGL Renderer #{OpenGL::VERSION} (Mittsu #{Mittsu::VERSION})"
39
39
 
40
40
  fetch_parameters(parameters)
41
41
 
@@ -318,6 +318,16 @@ module Mittsu
318
318
  @_opengl_objects.delete(object.id)
319
319
  end
320
320
 
321
+ def take_screenshot(filename, x: 0, y: 0, width: self.width, height: self.height)
322
+ type_nb_bytes = 1 # for GL_UNSIGNED_BYTE (0 to 255)
323
+ nb_channels = 3 # for GL_RGB
324
+ pixels = ' ' * width * height * type_nb_bytes * nb_channels
325
+ GL.ReadPixels(x, y, width, height, GL::RGB, GL::UNSIGNED_BYTE, pixels)
326
+ png = ChunkyPNG::Image.from_rgb_stream(width, height, pixels)
327
+ png.flip_horizontally!
328
+ png.save(filename)
329
+ end
330
+
321
331
  private
322
332
 
323
333
  def clear_color(r, g, b, a)
@@ -1,5 +1,5 @@
1
1
  module Mittsu
2
2
  module OpenGL
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.2'
4
4
  end
5
5
  end
@@ -296,7 +296,7 @@ module Mittsu
296
296
  group_hash = "#{hash_map[material_index][:hash]}_#{hash_map[material_index][:counter]}"
297
297
 
298
298
  if !groups.include? group_hash
299
- group = OpenGLGeometryGroup.new(material_index, num_morph_targets, num_morph_normals, @renderer)
299
+ group = OpenGL::GeometryGroup.new(material_index, num_morph_targets, num_morph_normals, @renderer)
300
300
 
301
301
  groups[group_hash] = group
302
302
  groups_list << group
@@ -24,13 +24,13 @@ Gem::Specification.new do |spec|
24
24
  spec.requirements << 'OpenGL 3.3+ capable hardware and drivers'
25
25
 
26
26
  spec.add_runtime_dependency 'opengl-bindings2'
27
- spec.add_runtime_dependency 'fiddle'
28
- spec.add_runtime_dependency 'mittsu'
27
+ spec.add_runtime_dependency 'fiddle', '~> 1.0'
28
+ spec.add_runtime_dependency 'mittsu', '~> 0.5.0'
29
29
 
30
- spec.add_development_dependency "bundler"
31
- spec.add_development_dependency "rake"
32
- spec.add_development_dependency 'minitest'
33
- spec.add_development_dependency 'minitest-reporters'
34
- spec.add_development_dependency 'benchmark-ips'
30
+ spec.add_development_dependency 'bundler', '~> 2.0'
31
+ spec.add_development_dependency 'rake', '~> 13.0'
32
+ spec.add_development_dependency 'minitest', '~> 5.0'
33
+ spec.add_development_dependency 'minitest-reporters', '~> 1.7'
34
+ spec.add_development_dependency 'benchmark-ips', '~> 2.14'
35
35
  spec.add_development_dependency 'simplecov', '0.17.1'
36
36
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mittsu-opengl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danielle Smith
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: opengl-bindings2
@@ -28,100 +27,100 @@ dependencies:
28
27
  name: fiddle
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
30
+ - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '0'
32
+ version: '1.0'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
- - - ">="
37
+ - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '0'
39
+ version: '1.0'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: mittsu
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - ">="
44
+ - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '0'
46
+ version: 0.5.0
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - ">="
51
+ - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '0'
53
+ version: 0.5.0
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: bundler
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - ">="
58
+ - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: '0'
60
+ version: '2.0'
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - ">="
65
+ - - "~>"
67
66
  - !ruby/object:Gem::Version
68
- version: '0'
67
+ version: '2.0'
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: rake
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - ">="
72
+ - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: '0'
74
+ version: '13.0'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - ">="
79
+ - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '0'
81
+ version: '13.0'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: minitest
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
- - - ">="
86
+ - - "~>"
88
87
  - !ruby/object:Gem::Version
89
- version: '0'
88
+ version: '5.0'
90
89
  type: :development
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
- - - ">="
93
+ - - "~>"
95
94
  - !ruby/object:Gem::Version
96
- version: '0'
95
+ version: '5.0'
97
96
  - !ruby/object:Gem::Dependency
98
97
  name: minitest-reporters
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
- - - ">="
100
+ - - "~>"
102
101
  - !ruby/object:Gem::Version
103
- version: '0'
102
+ version: '1.7'
104
103
  type: :development
105
104
  prerelease: false
106
105
  version_requirements: !ruby/object:Gem::Requirement
107
106
  requirements:
108
- - - ">="
107
+ - - "~>"
109
108
  - !ruby/object:Gem::Version
110
- version: '0'
109
+ version: '1.7'
111
110
  - !ruby/object:Gem::Dependency
112
111
  name: benchmark-ips
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
- - - ">="
114
+ - - "~>"
116
115
  - !ruby/object:Gem::Version
117
- version: '0'
116
+ version: '2.14'
118
117
  type: :development
119
118
  prerelease: false
120
119
  version_requirements: !ruby/object:Gem::Requirement
121
120
  requirements:
122
- - - ">="
121
+ - - "~>"
123
122
  - !ruby/object:Gem::Version
124
- version: '0'
123
+ version: '2.14'
125
124
  - !ruby/object:Gem::Dependency
126
125
  name: simplecov
127
126
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +155,7 @@ files:
156
155
  - bin/setup
157
156
  - install-glfw.ps1
158
157
  - lib/mittsu/generic_lib.rb
158
+ - lib/mittsu/glfw/debug.rb
159
159
  - lib/mittsu/glfw/lib.rb
160
160
  - lib/mittsu/glfw/window.rb
161
161
  - lib/mittsu/opengl.rb
@@ -291,7 +291,6 @@ licenses:
291
291
  - MIT
292
292
  metadata:
293
293
  bug_tracker: https://github.com/danini-the-panini/mittsu/issues
294
- post_install_message:
295
294
  rdoc_options: []
296
295
  require_paths:
297
296
  - lib
@@ -307,8 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
307
306
  version: '0'
308
307
  requirements:
309
308
  - OpenGL 3.3+ capable hardware and drivers
310
- rubygems_version: 3.5.23
311
- signing_key:
309
+ rubygems_version: 3.6.7
312
310
  specification_version: 4
313
311
  summary: OpenGL renderer for Mittsu
314
312
  test_files: []