metaco-ext 0.1.0
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 +7 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +83 -0
- data/Rakefile +9 -0
- data/lib/metaco/ext/version.rb +7 -0
- data/lib/metaco/ext.rb +46 -0
- data/sig/metaco/ext.rbs +6 -0
- metadata +49 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 679fd4c4e31f510d21e5f91cef3646bdcf41341ca31358c8c5f012bbf05c0e4f
|
|
4
|
+
data.tar.gz: a4029522783974d02d9b46b05ae33dea97a84bfce1bd5dc1abbc7b33cbc3506d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c5b588f4859b3a44543ee2c60f961efffe9829e6065f37d78cd0be09dd53587a707c32a6686876b684700348ff73246377ad9fbc91f07a5623ba6782f4e15696
|
|
7
|
+
data.tar.gz: 1e66134660ea5509ef3278e0c9a5edbcb7759db66fb602c4f30c78addc4dfc18f96a0284f3a604808ee3123ef91c1a213d8fa331d092dc8798ee7a5cfbbf28f7
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ydah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# metaco-ext
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/metaco-ext)
|
|
4
|
+
[](https://rubygems.org/gems/metaco-ext)
|
|
5
|
+
[](https://github.com/rbgfx/metaco-ext/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.ruby-lang.org/)
|
|
7
|
+
[](LICENSE.txt)
|
|
8
|
+
|
|
9
|
+
> Small Ruby adapters for metaco textures, pixels, events, and resize data.
|
|
10
|
+
|
|
11
|
+
metaco-ext adds the Ruby-side helpers that sit next to the native
|
|
12
|
+
[metaco](https://github.com/rbgfx/metaco) API. Resource methods delegate to
|
|
13
|
+
metaco, while event helpers provide a stable, normalized shape for graphics
|
|
14
|
+
applications.
|
|
15
|
+
|
|
16
|
+
**[Features](#features) · [Installation](#installation) · [Quick start](#quick-start) · [Requirements](#requirements) · [Development](#development)**
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- Texture create, update, bind, and destroy helpers.
|
|
21
|
+
- Compute and framebuffer pixel readback delegation.
|
|
22
|
+
- Frozen, symbol-keyed event normalization.
|
|
23
|
+
- Logical and framebuffer dimensions in resize events.
|
|
24
|
+
- No in-memory substitute for native texture resources.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
Add both gems to your Gemfile:
|
|
29
|
+
|
|
30
|
+
~~~ruby
|
|
31
|
+
gem "metaco"
|
|
32
|
+
gem "metaco-ext"
|
|
33
|
+
~~~
|
|
34
|
+
|
|
35
|
+
Then run:
|
|
36
|
+
|
|
37
|
+
~~~sh
|
|
38
|
+
bundle install
|
|
39
|
+
~~~
|
|
40
|
+
|
|
41
|
+
Or install the released extension:
|
|
42
|
+
|
|
43
|
+
~~~sh
|
|
44
|
+
gem install metaco-ext
|
|
45
|
+
~~~
|
|
46
|
+
|
|
47
|
+
## Quick start
|
|
48
|
+
|
|
49
|
+
~~~ruby
|
|
50
|
+
require "metaco/ext"
|
|
51
|
+
|
|
52
|
+
resize = Metaco::Ext.resize_event(
|
|
53
|
+
width: 800,
|
|
54
|
+
height: 450,
|
|
55
|
+
framebuffer_width: 1600,
|
|
56
|
+
framebuffer_height: 900
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
puts resize[:framebuffer_width]
|
|
60
|
+
~~~
|
|
61
|
+
|
|
62
|
+
Native texture operations require a metaco build with texture support:
|
|
63
|
+
|
|
64
|
+
~~~ruby
|
|
65
|
+
texture = Metaco::Ext.texture_create(handle, 2, 2, rgba_bytes)
|
|
66
|
+
Metaco::Ext.bind_compute_texture(handle, 0, texture)
|
|
67
|
+
~~~
|
|
68
|
+
|
|
69
|
+
## Requirements
|
|
70
|
+
|
|
71
|
+
Native Metal calls are available on macOS only. Calling a resource method
|
|
72
|
+
without a compatible metaco installation raises <code>LoadError</code>.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
~~~sh
|
|
77
|
+
bundle install
|
|
78
|
+
bundle exec rake verify
|
|
79
|
+
~~~
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
[MIT](LICENSE.txt)
|
data/Rakefile
ADDED
data/lib/metaco/ext.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "ext/version"
|
|
4
|
+
|
|
5
|
+
module Metaco
|
|
6
|
+
module Ext
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
def texture_create(handle, width, height, bytes, **options)
|
|
10
|
+
native.texture_create(handle, width, height, bytes, **options)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def texture_update(texture, bytes)
|
|
14
|
+
native.texture_update(texture, bytes)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def texture_destroy(texture)
|
|
18
|
+
native.texture_destroy(texture)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def bind_compute_texture(handle, index, texture)
|
|
22
|
+
native.bind_compute_texture(handle, index, texture)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def read_pixels(handle, source: :compute)
|
|
26
|
+
native.read_pixels(handle, source: source)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def normalize_event(event)
|
|
30
|
+
event = event.transform_keys(&:to_sym)
|
|
31
|
+
event[:modifiers] = Array(event[:modifiers]).map(&:to_sym).freeze if event.key?(:modifiers)
|
|
32
|
+
event.freeze
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def resize_event(width:, height:, framebuffer_width: width, framebuffer_height: height)
|
|
36
|
+
normalize_event(type: :resize, width: width, height: height, framebuffer_width: framebuffer_width, framebuffer_height: framebuffer_height)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def native
|
|
40
|
+
require "metaco" unless Metaco.respond_to?(:texture_create)
|
|
41
|
+
raise LoadError, "metaco with texture support is required" unless Metaco.respond_to?(:texture_create)
|
|
42
|
+
Metaco
|
|
43
|
+
end
|
|
44
|
+
private_class_method :native
|
|
45
|
+
end
|
|
46
|
+
end
|
data/sig/metaco/ext.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: metaco-ext
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ydah
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Validated texture, pixel, event, and resize adapters for metaco.
|
|
13
|
+
email:
|
|
14
|
+
- t.yudai92@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- CHANGELOG.md
|
|
20
|
+
- LICENSE.txt
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- lib/metaco/ext.rb
|
|
24
|
+
- lib/metaco/ext/version.rb
|
|
25
|
+
- sig/metaco/ext.rbs
|
|
26
|
+
homepage: https://github.com/rbgfx/metaco-ext
|
|
27
|
+
licenses:
|
|
28
|
+
- MIT
|
|
29
|
+
metadata:
|
|
30
|
+
homepage_uri: https://github.com/rbgfx/metaco-ext
|
|
31
|
+
source_code_uri: https://github.com/rbgfx/metaco-ext/tree/main
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 3.1.0
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
requirements: []
|
|
46
|
+
rubygems_version: 4.0.16
|
|
47
|
+
specification_version: 4
|
|
48
|
+
summary: Ruby helpers for metaco resources and events
|
|
49
|
+
test_files: []
|