sfml3-rb 0.3.0-arm-linux-musl
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/.yardopts +9 -0
- data/CHANGELOG.md +368 -0
- data/LICENSE.md +14 -0
- data/README.md +215 -0
- data/TODO.md +199 -0
- data/lib/sfml/3.1/sfml_ext.so +0 -0
- data/lib/sfml/3.2/sfml_ext.so +0 -0
- data/lib/sfml/3.3/sfml_ext.so +0 -0
- data/lib/sfml/3.4/sfml_ext.so +0 -0
- data/lib/sfml/4.0/sfml_ext.so +0 -0
- data/lib/sfml/version.rb +5 -0
- data/lib/sfml.rb +11 -0
- data/sig/audio/audio_enums.rbs +30 -0
- data/sig/audio/listener.rbs +16 -0
- data/sig/audio/music.rbs +56 -0
- data/sig/audio/sound.rbs +51 -0
- data/sig/audio/sound_buffer.rbs +17 -0
- data/sig/audio/sound_buffer_recorder.rbs +14 -0
- data/sig/audio/sound_recorder.rbs +17 -0
- data/sig/audio/sound_source_cone.rbs +14 -0
- data/sig/audio/sound_stream.rbs +51 -0
- data/sig/graphics/blend_mode.rbs +29 -0
- data/sig/graphics/circle.rbs +44 -0
- data/sig/graphics/color.rbs +39 -0
- data/sig/graphics/drawable.rbs +5 -0
- data/sig/graphics/font.rbs +20 -0
- data/sig/graphics/glyph.rbs +7 -0
- data/sig/graphics/image.rbs +22 -0
- data/sig/graphics/polygon.rbs +42 -0
- data/sig/graphics/rect.rbs +33 -0
- data/sig/graphics/rectangle.rbs +42 -0
- data/sig/graphics/render_state.rbs +21 -0
- data/sig/graphics/render_texture.rbs +37 -0
- data/sig/graphics/shader.rbs +39 -0
- data/sig/graphics/shape.rbs +38 -0
- data/sig/graphics/sprite.rbs +34 -0
- data/sig/graphics/stencil_mode.rbs +18 -0
- data/sig/graphics/target.rbs +10 -0
- data/sig/graphics/text.rbs +48 -0
- data/sig/graphics/texture.rbs +34 -0
- data/sig/graphics/transform.rbs +37 -0
- data/sig/graphics/transformable.rbs +25 -0
- data/sig/graphics/vertex.rbs +17 -0
- data/sig/graphics/vertex_array.rbs +17 -0
- data/sig/graphics/vertex_buffer.rbs +22 -0
- data/sig/graphics/view.rbs +24 -0
- data/sig/network/ftp.rbs +46 -0
- data/sig/network/http.rbs +27 -0
- data/sig/network/ip_address.rbs +22 -0
- data/sig/network/network_enums.rbs +95 -0
- data/sig/network/packet.rbs +40 -0
- data/sig/network/socket_selector.rbs +14 -0
- data/sig/network/tcp_listener.rbs +13 -0
- data/sig/network/tcp_socket.rbs +18 -0
- data/sig/network/udp_socket.rbs +17 -0
- data/sig/system/buffer.rbs +11 -0
- data/sig/system/clock.rbs +13 -0
- data/sig/system/input_stream.rbs +7 -0
- data/sig/system/sleep.rbs +3 -0
- data/sig/system/time.rbs +28 -0
- data/sig/system/vec2.rbs +26 -0
- data/sig/system/vec3.rbs +27 -0
- data/sig/window/clipboard.rbs +8 -0
- data/sig/window/context.rbs +11 -0
- data/sig/window/context_settings.rbs +20 -0
- data/sig/window/cursor.rbs +6 -0
- data/sig/window/event.rbs +20 -0
- data/sig/window/joystick.rbs +15 -0
- data/sig/window/keyboard.rbs +10 -0
- data/sig/window/mouse.rbs +9 -0
- data/sig/window/sensor.rbs +8 -0
- data/sig/window/touch.rbs +6 -0
- data/sig/window/video_mode.rbs +16 -0
- data/sig/window/vulkan.rbs +7 -0
- data/sig/window/window.rbs +57 -0
- metadata +131 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 25e694daba3cad1f2e3b142cd12ec7afde46d64b5acc953a99469dbdcf447ce3
|
|
4
|
+
data.tar.gz: 13bc22af2a0435b2bc3f551118f42a381bd2bbc1b902bf15b0963f44b86c67d6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: da5519ffc358c31db56f0382148e7eb6b008c1d22ce0c1793418bfeea93529b0263a6037daa9f747d4f3e52d149e4a2387c98082f9ed217179d270bd571ef48d
|
|
7
|
+
data.tar.gz: 8249421866aea6c645926c2d0bde1ac5cc9004c2385ff526a53c49b0233ca803f3d34ffdd046d79bc21cda87f3dbef4cc1d56b2f34cda7cb40932613ebb8789a
|
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.3.0] - 2026-09-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
* **Four more experimental binary-gem targets**: `aarch64-linux-musl`, `arm-linux-gnu`
|
|
13
|
+
(ARMv7 hard-float), `arm-linux-musl`, and `aarch64-mingw-ucrt` (64-bit Windows on ARM).
|
|
14
|
+
All four ride the same rake-compiler-dock cross-compilation this project already uses for
|
|
15
|
+
its other targets; none has been run on its target hardware yet, so all are
|
|
16
|
+
`experimental` in `publish.yaml` like `aarch64-linux-gnu`, `x86_64-darwin` and
|
|
17
|
+
`arm64-darwin` already were. `script/provision.sh` gained matching cases for the two new
|
|
18
|
+
glibc/musl Linux targets.
|
|
19
|
+
* `rakelib/package.rake`'s `EXPECTED_ABIS` gained an entry for `aarch64-mingw-ucrt`: its
|
|
20
|
+
rake-compiler-dock image carries no cross Ruby older than 3.4, so that gem has no floor
|
|
21
|
+
below it — the same kind of upstream gap `x86-mingw32` already has at the top end.
|
|
22
|
+
* `aarch64-linux-gnu` is now additionally run — not just cross-compiled — by a new
|
|
23
|
+
`test-arm64.yaml` workflow, on GitHub's hosted `ubuntu-24.04-arm` runner. It stays
|
|
24
|
+
`experimental` in `publish.yaml` for now; this is the evidence that will eventually
|
|
25
|
+
justify dropping that flag.
|
|
26
|
+
* ARMv6 (32-bit), RISC-V (rv64gc), PowerPC (ppc64le), and any BSD are deliberately not
|
|
27
|
+
covered by a binary gem: rake-compiler-dock ships no cross-compilation image for any of
|
|
28
|
+
them, and building custom cross-toolchain infrastructure for them is a much larger,
|
|
29
|
+
separate undertaking. The source-gem fallback remains the only path there, unchanged.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
* **A GC race in the audio bindings aborted the process on arm64.** `Sound`, `Music` and
|
|
33
|
+
`SoundStream` released the GVL inside their `dfree`, but their data types were marked
|
|
34
|
+
`RUBY_TYPED_FREE_IMMEDIATELY`, so the free could run *during* garbage collection: another
|
|
35
|
+
thread (Ruby's `Timeout` thread, in the test suite) could then allocate while GC was mid-cycle
|
|
36
|
+
and Ruby aborted with "object allocation during garbage collection phase". Dropping the flag
|
|
37
|
+
defers the free to a safe point; releasing the GVL is still what keeps `sf*_destroy` from
|
|
38
|
+
deadlocking against the audio thread.
|
|
39
|
+
|
|
40
|
+
### Documentation
|
|
41
|
+
* **Every public class, module, method and constant is documented**, with the
|
|
42
|
+
result rendered on [rubydoc.info](https://rubydoc.info/gems/sfml3-rb). The
|
|
43
|
+
comments live beside each binding in `ext/**/*.c`; `rake yard` builds them
|
|
44
|
+
into `doc/`. Previously the comments carried `call-seq` and `@return` tags
|
|
45
|
+
but little prose, so rubydoc.info showed a signature with a blank
|
|
46
|
+
description; every such method now has a sentence of its own.
|
|
47
|
+
* RBS type signatures for the same surface ship in `sig/**/*.rbs`, for IDE
|
|
48
|
+
completion (Solargraph, RubyMine) and static checking (Sorbet, Steep);
|
|
49
|
+
`rake rbs` validates them.
|
|
50
|
+
* `.yardopts` ships in the gem, so rubydoc.info generates with the same title,
|
|
51
|
+
README and extra files as `rake yard`.
|
|
52
|
+
* `rake doc:undoc` fails when a method is left without a description, so the
|
|
53
|
+
coverage cannot regress silently (`yard stats` uses `blank?` and passes for
|
|
54
|
+
tag-only comments, which is how the blanks went unnoticed).
|
|
55
|
+
|
|
56
|
+
## [0.2.1]
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
* **`SFML::Transform` is now a class**, wrapping `sfTransform` by value. It previously exposed
|
|
60
|
+
only `combine` and `inverse` as module functions over plain 9-element Arrays, leaving 11 of
|
|
61
|
+
CSFML's 13 transform functions unbound: you could read a matrix out of a `Sprite` but not build
|
|
62
|
+
one, apply one to a point, or compose one. It now has `Transform.identity` / `IDENTITY`,
|
|
63
|
+
`Transform.from_a`, `#to_a`/`#matrix`, `#gl_matrix`, `#==`, `#translate!`, `#rotate!`,
|
|
64
|
+
`#scale!` (the last two taking an optional centre), non-mutating `#translate`/`#rotate`/
|
|
65
|
+
`#scale`, `#transform_point`, `#transform_rect`, `#combine!`, `#*`, `#inverse` and `#copy`.
|
|
66
|
+
* **`map_pixel_to_coords` and `map_coords_to_pixel` on both render targets.** The screen-to-world
|
|
67
|
+
conversion behind every click-to-select interaction; without it a zoomed, rotated or
|
|
68
|
+
viewport-shifted `View` could not be hit-tested from Ruby at all.
|
|
69
|
+
* **`SFML::Window` gained the render-target methods only `RenderTexture` had**: `clear_stencil`,
|
|
70
|
+
`clear_color_and_stencil`, `viewport`, `scissor` and `srgb?`. Both classes also gained
|
|
71
|
+
`push_gl_states`, `pop_gl_states`, `reset_gl_states`, `draw_primitives` and
|
|
72
|
+
`draw_vertex_buffer_range`. The shared surface is generated once from
|
|
73
|
+
`ext/graphics/render_target.inc`, the same way `ext/audio/sound_source.inc` already serves the
|
|
74
|
+
three sound sources.
|
|
75
|
+
* `SFML::View.from_rect`, `View#scissor` and `View#scissor=`.
|
|
76
|
+
* `SFML::Transformable#inverse_transform` and `#copy` — every subclass (`Sprite`, `Text`,
|
|
77
|
+
`Circle`, `RectangleShape`, `ConvexShape`, `Shape`) already had both.
|
|
78
|
+
* `SFML::Texture.srgb`, `.srgb_from_stream`, `.srgb_from_image`, `Texture#resize_srgb` and
|
|
79
|
+
`Texture#swap`.
|
|
80
|
+
* `SFML::Shader#set_vec4_array`, `#set_mat3_array` and `#set_mat4_array`, completing the array
|
|
81
|
+
uniforms alongside the existing float/vec2/vec3 forms.
|
|
82
|
+
* `SFML::Circle#point_count=`, `SFML::VertexBuffer#swap`, `SFML::Window.from_handle` and
|
|
83
|
+
`SFML::Window#create_vulkan_surface`.
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
* **Non-ASCII text and window titles were mangled.** `Text#string=`, `Window#title=`, window
|
|
87
|
+
creation and `FtpDirectoryResponse#directory` passed UTF-8 bytes to CSFML's `const char*`
|
|
88
|
+
entry points, which hand them to `sf::String`'s narrow-character constructor and decode them
|
|
89
|
+
with the C locale: `"héllo"` came back as `U+0068 U+FFFFFFFF U+FFFFFFFF U+006C U+006C U+006F`.
|
|
90
|
+
All four now go through the UTF-32 entry points and round-trip exactly, including astral-plane
|
|
91
|
+
characters. The converters live in `ext/core/unicode.c`.
|
|
92
|
+
* **`Mouse.position`, `Mouse.position=` and `Touch.position` reinterpret-cast `sfRenderWindow*`
|
|
93
|
+
to `sfWindowBase*`**, relying on the base being at offset 0 — true of CSFML 3.0.0's layout but
|
|
94
|
+
not guaranteed by it. They now call `sfMouse_getPositionRenderWindow`,
|
|
95
|
+
`sfMouse_setPositionRenderWindow` and `sfTouch_getPositionRenderWindow`, which CSFML ships for
|
|
96
|
+
exactly this reason. Ruby-visible behaviour is unchanged.
|
|
97
|
+
* `Shader#set_float_array`, `#set_vec2_array` and `#set_vec3_array` leaked their conversion
|
|
98
|
+
buffer if an element raised part-way through. All six array setters are now generated from one
|
|
99
|
+
macro built on `ALLOCV_N`, whose buffer Ruby frees while unwinding.
|
|
100
|
+
* `VertexBuffer#update` had the same leak; it now shares `vertices_from_rb`, which validates
|
|
101
|
+
every element before allocating anything.
|
|
102
|
+
* **Audio-thread callbacks re-entered the VM from a foreign native thread.** The
|
|
103
|
+
`SoundStream#on_get_data` / `#on_seek` callbacks and the effect processor run on SFML's audio
|
|
104
|
+
thread, which Ruby never created; calling back into Ruby from it (`rb_thread_call_with_gvl`) is
|
|
105
|
+
a fatal VM error. Each now hands off to one shared Ruby-owned worker
|
|
106
|
+
(`ext/core/foreign_thread.c`). `SoundSource#stop`, `Sound#buffer=` and the `Sound` / `Music` /
|
|
107
|
+
`SoundStream` destructors release the GVL while they wait on the audio thread, and a processor
|
|
108
|
+
that times out degrades to a full buffer of silence rather than stalling playback.
|
|
109
|
+
|
|
110
|
+
### Changed
|
|
111
|
+
* `Window` is created through `sfRenderWindow_createUnicode` rather than `sfRenderWindow_create`,
|
|
112
|
+
so a title given at construction is subject to the same UTF-8 fix as `#title=`.
|
|
113
|
+
* `RenderTexture#viewport` and `#scissor` now take the view as an *optional* argument; omitting
|
|
114
|
+
it means the target's current view, matching CSFML's `NULL`.
|
|
115
|
+
|
|
116
|
+
## [0.2.0]
|
|
117
|
+
|
|
118
|
+
### Added
|
|
119
|
+
* **Full Audio binding.** `SFML::Listener`, `SFML::SoundSourceCone`, `SFML::SoundBuffer`,
|
|
120
|
+
`SFML::Sound`, `SFML::Music`, `SFML::SoundStream`, `SFML::SoundRecorder` and
|
|
121
|
+
`SFML::SoundBufferRecorder`, plus the `SFML::SoundStatus` and `SFML::SoundChannel` enums. The
|
|
122
|
+
shared sound-source surface (play/pause/stop/status, pitch, pan, volume, spatialization,
|
|
123
|
+
position/direction/velocity, cone, doppler and attenuation factors, distance/gain bounds and
|
|
124
|
+
playing offset) is generated once from `ext/audio/sound_source.inc` for all three source classes.
|
|
125
|
+
`SoundStream` and `SoundRecorder` are subclassable through `#on_get_data`/`#on_seek` and
|
|
126
|
+
`#on_process`/`#on_start`/`#on_stop`; their callbacks re-enter Ruby under the GVL and treat an
|
|
127
|
+
exception as "stop", since they run on SFML's audio thread.
|
|
128
|
+
* **Full Network binding.** `SFML::IpAddress` (string/bytes/integer constructors, `NONE`, `ANY`,
|
|
129
|
+
`LOCAL_HOST`, `BROADCAST`, local/public lookup), `SFML::Packet` (raw data plus every typed
|
|
130
|
+
reader/writer), `SFML::SocketSelector`, `SFML::TcpSocket`, `SFML::TcpListener`,
|
|
131
|
+
`SFML::UdpSocket`, `SFML::Http`/`HttpRequest`/`HttpResponse`, `SFML::Ftp` with its response,
|
|
132
|
+
directory-response and listing-response classes, and the `SocketStatus`, `HttpMethod`,
|
|
133
|
+
`HttpStatus`, `FtpStatus` and `FtpTransferMode` enums.
|
|
134
|
+
* `SFML::SoundSource#effect_processor=` accepts a Ruby proc. Because `sfEffectProcessor` carries
|
|
135
|
+
no `userData` (so one C callback cannot tell which source invoked it), the binding dispatches
|
|
136
|
+
through a bounded pool of C thunks, one per active source; exceeding the pool raises.
|
|
137
|
+
|
|
138
|
+
### Changed
|
|
139
|
+
* The vendored CSFML/SFML archives are now linked by **full path** instead of `-l`. mkmf puts the
|
|
140
|
+
host's `-L/usr/lib64` ahead of the ports prefix, which made `-lfreetype` (and the new codec
|
|
141
|
+
libraries) resolve to the host's shared objects and silently add runtime dependencies. The
|
|
142
|
+
built extension again has no `libsfml`/`libcsfml`/`libfreetype`/`libvorbis`/`libFLAC`/`libogg`
|
|
143
|
+
shared dependency.
|
|
144
|
+
|
|
145
|
+
### Build
|
|
146
|
+
* `ext/ports.rb` now builds **Ogg 1.3.5, Vorbis 1.3.7 and FLAC 1.4.3** as pinned,
|
|
147
|
+
checksum-verified, static and position-independent ports, alongside FreeType. SFML 3's audio
|
|
148
|
+
backend is miniaudio, so OpenAL is not needed.
|
|
149
|
+
* `SFML_BUILD_AUDIO`, `SFML_BUILD_NETWORK`, `CSFML_BUILD_AUDIO` and `CSFML_BUILD_NETWORK` are
|
|
150
|
+
enabled; `ws2_32` was added to the Windows system libraries and the CoreAudio/CoreFoundation
|
|
151
|
+
frameworks to the macOS ones. `CMakeLists.txt` finds and links the `Audio`/`Network` components.
|
|
152
|
+
* Archive extraction accepts `.tar.xz` as well as `.tar.gz`, since the FLAC release ships only as
|
|
153
|
+
xz.
|
|
154
|
+
|
|
155
|
+
### Known issues
|
|
156
|
+
* Audio playback and capture need an audio device; the CI suite stays headless, so
|
|
157
|
+
`SoundStream#on_get_data` and `SoundRecorder` are exercised by construction and mapping only,
|
|
158
|
+
never by actually playing or capturing.
|
|
159
|
+
* `Http` and `Ftp` perform real network I/O and are not exercised in CI beyond construction and
|
|
160
|
+
enum mapping.
|
|
161
|
+
|
|
162
|
+
## [0.1.1]
|
|
163
|
+
|
|
164
|
+
### Added
|
|
165
|
+
* **Full Graphics binding.** `RectangleShape`, `ConvexShape`, a callback-based custom `Shape`, `Sprite`,
|
|
166
|
+
`Texture`, `Image`, `Font`, `Text`, `RenderTexture`, `Shader`, `Vertex`, `VertexArray`,
|
|
167
|
+
`VertexBuffer`, `Glyph`, and the value types `BlendMode`, `StencilMode`. `Circle` gained the
|
|
168
|
+
outline/texture/bounds surface it was missing.
|
|
169
|
+
* **Full Window/input binding.** `Keyboard` real-time queries (`pressed?`, `scancode_pressed?`,
|
|
170
|
+
`localize`, `delocalize`, `description`), and the `Mouse`, `Joystick`, `Touch`, `Sensor`,
|
|
171
|
+
`Clipboard`, `Cursor`, `Context`, `ContextSettings` and `Vulkan` modules/classes. `Event` now
|
|
172
|
+
exposes every payload (text, mouse move/raw/button/wheel, joystick move/button/connect, touch,
|
|
173
|
+
sensor).
|
|
174
|
+
* **System completeness.** `SFML::Time` (arithmetic, comparison, unit conversions), `SFML.sleep`,
|
|
175
|
+
`SFML::Buffer`, and `SFML::InputStream` (wraps any `#read`-able object so `Font`/`Texture`/`Image`/
|
|
176
|
+
`Shader` can load from streams).
|
|
177
|
+
* **Value classes.** `Vector2`, `Vector3`, `Color`, `Rect` are now real Ruby classes; every setter
|
|
178
|
+
still accepts a plain array, and getters return the class (which behaves like an array via
|
|
179
|
+
`to_ary`/`Enumerable`).
|
|
180
|
+
* `RenderTexture` is a draw target alongside `Window`: both route through the shared `Target`
|
|
181
|
+
dispatcher, so every drawable renders to either.
|
|
182
|
+
* Predefined `Color` constants, `BlendMode`/`StencilMode` predefined values, `ContextSettings`,
|
|
183
|
+
and `VideoMode.desktop_mode` / `.fullscreen_modes`.
|
|
184
|
+
* Initial project scaffolding: C extension wrapping CSFML (SFML 2 bindings).
|
|
185
|
+
* Windows, video modes, events, keyboard input, transforms, drawables (circle, rectangle, sprite, image), textures, views, clocks, and render targets.
|
|
186
|
+
* Unit tests (minitest) for Clock, Transformable, Circle, RenderState, VideoMode — headless, deterministic.
|
|
187
|
+
* RuboCop configuration and CI integration (test, check, publish workflows).
|
|
188
|
+
* Publish GitHub Action to build and upload the gem on release.
|
|
189
|
+
* `ext/ports.rb`: downloads, checksum-verifies, and builds SFML 3.0.2 and CSFML 3.0.0 from source into a static, position-independent prefix. Ships inside the gem, so `gem install sfml3-rb` builds its own dependencies with no CSFML pre-installed. Shared by `rake ports` (development) and `ext/extconf.rb` (install time).
|
|
190
|
+
* `ext/extconf.rb` three-way dependency resolution: `--enable-system-libraries` (or `SFML_USE_SYSTEM_LIBRARIES`) links a system CSFML 3; otherwise an existing `ports/<host>` prefix is reused, or built automatically.
|
|
191
|
+
* A compile-time `CSFML_VERSION_MAJOR < 3` guard (`ext/ext/sfml.h`) and an `extconf.rb` header check, so a CSFML 2.x install fails with one actionable message instead of a wall of compiler errors.
|
|
192
|
+
* `CMakeLists.txt` rewritten into a real, buildable configuration (CLion/IDE use only — `rake compile` remains the build of record): resolves the vendored `ports/<host>` prefix, links `find_package(SFML 3 ...)` and the CSFML static archives, and links through the C++ driver, since SFML is C++.
|
|
193
|
+
|
|
194
|
+
### Changed
|
|
195
|
+
* **Rebuilt the drawing path around `Target`.** `Target` now carries a `{type, handle}` union and
|
|
196
|
+
dispatches each draw call to the window or render-texture variant; `Window#draw` and every
|
|
197
|
+
drawable's `#draw` go through it. `RenderState` is initialized from `sfRenderStates_default`
|
|
198
|
+
instead of field-by-field, fixing the `stencilMode`/`coordinateType` fields that were left
|
|
199
|
+
uninitialized under CSFML 3, and it now exposes `blend_mode`, `stencil_mode`, `coordinate_type`,
|
|
200
|
+
`texture` and `shader`.
|
|
201
|
+
* **Naming aligned with SFML 3, typos fixed.** `angle`/`angle=` → `rotation`/`rotation=`;
|
|
202
|
+
`escalate` → `scale!` (the mutating operation; `scale` remains the getter); `matrix` → `transform`
|
|
203
|
+
(`matrix` kept as an alias). `View#position`/`position=` were removed: the old setter wrote the
|
|
204
|
+
viewport rather than the center — use `center`/`viewport`.
|
|
205
|
+
* `Clock#elapsed_time`/`#restart!` now return `SFML::Time` rather than bare `Float` seconds.
|
|
206
|
+
* `Window.new` accepts `(video_mode, title, style = :default, state = :windowed, settings = nil)`
|
|
207
|
+
instead of hardcoding `sfDefaultStyle`/`sfWindowed`/no settings.
|
|
208
|
+
* **The C extension is now organised by SFML subsystem.** The 24 sources no longer sit flat in `ext/`
|
|
209
|
+
with their headers in a doubled `ext/ext/` tree; each binding's `.c` and `.h` live together under
|
|
210
|
+
`ext/core/`, `ext/system/`, `ext/window/` or `ext/graphics/`, matching how SFML and CSFML split
|
|
211
|
+
themselves, so a binding's home follows from the CSFML header it wraps. Includes became
|
|
212
|
+
subsystem-relative (`#include "graphics/circle.h"`) and header guards path-derived
|
|
213
|
+
(`SFML_RB_GRAPHICS_CIRCLE_H`), retiring three `CANDY2D_EXT_*` guards left over from a previous
|
|
214
|
+
project name. `ext/extconf.rb` sets `$srcs` from a recursive glob and extends `$VPATH`, because mkmf
|
|
215
|
+
globs only the top level; objects stay flat, which is why every `.c` basename must remain unique.
|
|
216
|
+
`Rakefile` gained `source_pattern = '**/*.{c,h}'` — recursive so the new tree is seen at all, and
|
|
217
|
+
including headers because editing one previously triggered no rebuild. `CMakeLists.txt` globs
|
|
218
|
+
recursively to match.
|
|
219
|
+
* `ext/ext/klass/transform.h` deleted: a stale duplicate of the live `module/transform.h` that nothing
|
|
220
|
+
included, and which would have collided with it in the new tree. The five unbound placeholders
|
|
221
|
+
(Image, Polygon, Rectangle, Sprite, Texture) were kept, so the layout still shows where they will
|
|
222
|
+
land.
|
|
223
|
+
* `CrossBuild#build` now clears **every** staging directory under `pkg/`, not just the current
|
|
224
|
+
platform's. `rake native:<platform> gem` also runs the shared source-gem task, so a stale
|
|
225
|
+
`pkg/<name>-<version>/` fails the cross build with `... are not files` about files that plainly
|
|
226
|
+
exist — which is exactly what the restructuring triggered.
|
|
227
|
+
* **The C extension moved from the untyped `Data_Wrap_Struct` family to `TypedData`.** All wrapped
|
|
228
|
+
types now carry an `rb_data_type_t`. `Data_*` has been deprecated since Ruby 2.3 and warns on every
|
|
229
|
+
use under Ruby 4.0, which was the extension's only compile-time portability problem — the build is
|
|
230
|
+
now warning-clean under `-Wall -Wextra` from Ruby 3.1 to 4.0. `TypedData_Get_Struct` also
|
|
231
|
+
type-checks, where `Data_Get_Struct` silently reinterpreted whatever pointer it was handed.
|
|
232
|
+
* `ext/extconf.rb` now always compiles with `-Wall -Wextra`, and with `-Werror=deprecated-declarations`
|
|
233
|
+
when `SFML_STRICT=1`. CI sets it, so a regression to the deprecated API fails the build rather than
|
|
234
|
+
adding noise. It is opt-in because an unfamiliar compiler at `gem install` time must never fail on a
|
|
235
|
+
warning.
|
|
236
|
+
* **Minimum Ruby raised from 2.5.0 to 3.1**, matched by `TargetRubyVersion` in `.rubocop.yml` and by
|
|
237
|
+
the binary gems, which is the point: there is now **one** floor rather than a source/binary split.
|
|
238
|
+
`>= 2.5.0` had never been exercised — every workflow ran only Ruby 3.3. 3.1 is the oldest
|
|
239
|
+
cross-ruby the `x64-mingw-ucrt` rake-compiler-dock image carries, so it is what lets a single
|
|
240
|
+
`RUBY_CC_VERSION` serve every platform.
|
|
241
|
+
* `test.yaml` now runs the suite across 3.1, 3.2, 3.3, 3.4 and 4.0 — exactly the ABI set the binary
|
|
242
|
+
gems ship — so every Ruby that can receive a precompiled gem is also proven to build from source,
|
|
243
|
+
with `SFML_STRICT=1`.
|
|
244
|
+
* `publish.yaml` gained a `verify-source` gate that installs the freshly built source gem on the floor
|
|
245
|
+
and requires `sfml`, so a release cannot ship a source gem that fails to build. Every supported
|
|
246
|
+
Ruby now has a binary gem, but most *platforms* (macOS, ARM, the BSDs) still do not, and that path
|
|
247
|
+
stays load-bearing.
|
|
248
|
+
* `Gemfile` gained a `:test` group pinning `minitest` to `~> 5.0`; minitest 6 requires Ruby >= 3.2,
|
|
249
|
+
still above the floor. The cross-compile containers now install with `BUNDLE_WITHOUT="development
|
|
250
|
+
test"`.
|
|
251
|
+
* `.rubocop.yml` excludes `pkg/`, `tmp/` and `ports/`. Those hold staged copies of `lib/` and `ext/`,
|
|
252
|
+
so every offence in a real source file was being counted twice or more.
|
|
253
|
+
* **Packaging now produces precompiled binary gems** alongside the source gem. `rake gem:native`
|
|
254
|
+
cross-compiles inside [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock);
|
|
255
|
+
`rake platforms` lists the targets. On a covered platform `gem install sfml3-rb` no longer needs a
|
|
256
|
+
toolchain, CMake, or a source build at all. The source gem remains the fallback everywhere else,
|
|
257
|
+
unchanged in behaviour.
|
|
258
|
+
* **Binary gems now cover i686 as well as x86_64, on both glibc and musl Linux and on 32- and 64-bit
|
|
259
|
+
Windows**: `x86-linux-gnu`, `x86-linux-musl` and `x86-mingw32` join `x86_64-linux-gnu`,
|
|
260
|
+
`x86_64-linux-musl` and `x64-mingw-ucrt`, with `aarch64-linux-gnu`, `x86_64-darwin` and
|
|
261
|
+
`arm64-darwin` still experimental. Two gaps are upstream, not ours: RubyInstaller publishes no
|
|
262
|
+
32-bit Ruby 4.0, so `x86-mingw32` stops at 3.4; and 64-bit Windows before Ruby 3.1 is a different
|
|
263
|
+
platform (`x64-mingw32`), which is not built.
|
|
264
|
+
* `rakelib/package.rake` asserts the ABIs of each gem it builds against `EXPECTED_ABIS`.
|
|
265
|
+
rake-compiler only *warns* when an image lacks a cross-ruby it was asked for, so without this a gem
|
|
266
|
+
could quietly ship fewer ABIs than intended.
|
|
267
|
+
* `ext/ports.rb` targets gained a `multiarch` key. i686 compiles with `i686-linux-gnu-gcc` but its
|
|
268
|
+
libraries live in `/usr/lib/i386-linux-gnu`, and feeding the compiler triple to
|
|
269
|
+
`CMAKE_LIBRARY_ARCHITECTURE` would have pointed CMake at a directory that does not exist.
|
|
270
|
+
* The extension build moved from a hand-rolled `rake compile` (`ruby extconf.rb && make` inside
|
|
271
|
+
`ext/`, then a manual copy) to `rake-compiler`'s `Rake::ExtensionTask`. Builds are now out of tree
|
|
272
|
+
in `tmp/`, so `ext/` no longer accumulates `.o` files, a `Makefile` and `mkmf.log` beside its
|
|
273
|
+
sources.
|
|
274
|
+
* `lib/sfml.rb` prefers `sfml/<major.minor>/sfml_ext` — the per-ABI layout binary gems use — and falls
|
|
275
|
+
back to `sfml/sfml_ext` for a source build.
|
|
276
|
+
* `ext/ports.rb` is now cross-aware: prefixes and build trees are keyed by target (`ports/<target>`)
|
|
277
|
+
rather than by host, and a CMake toolchain file is generated per target. `SFML_TARGET` selects one;
|
|
278
|
+
a native build is unaffected.
|
|
279
|
+
* Project renamed to sfml3.rb; **migrated from SFML 2 to SFML 3** (via CSFML 3) — no longer just
|
|
280
|
+
planned. Distro CSFML packages are frequently still 2.x and are no longer supported.
|
|
281
|
+
* Native extension renamed from the bare `ext` to `sfml/sfml_ext`, matching the `sfml` gem namespace
|
|
282
|
+
and what `rake-compiler` cross-compilation expects.
|
|
283
|
+
* `event_name.c` and `keyboard.c` name tables are now indexed by named enum constant (C99 designated
|
|
284
|
+
initializers) instead of raw ordinal position, so a future upstream reorder is a compile error
|
|
285
|
+
rather than a silently wrong event or key name.
|
|
286
|
+
* `Window#clear` now takes a single `[r, g, b, a]` color array, matching every other color-setting
|
|
287
|
+
method in the API, instead of three positional numbers.
|
|
288
|
+
* Removed the dead `install-package` extconf hook and its accompanying `ext/linux.sh` (empty) and
|
|
289
|
+
`ext/msys2.sh` stubs, and the unused `run_script`/`Arguments`/`library_nofound` helpers in
|
|
290
|
+
`ext/auxlib.rb`.
|
|
291
|
+
* Removed the vendored `include/ruby/*.h` stubs and the empty `include/SFML/CSFML headers` placeholder;
|
|
292
|
+
nothing referenced them once `CMakeLists.txt` was fixed to query the real Ruby headers.
|
|
293
|
+
* `sfml3-rb.gemspec` carries more information: a `documentation_uri` alongside the existing
|
|
294
|
+
source/bug-tracker/changelog links, a summary that actually names SFML 3 and the precompiled
|
|
295
|
+
binaries (it is the line `gem search` shows), and `extra_rdoc_files`/`rdoc_options`. It also ships
|
|
296
|
+
`CHANGELOG.md` and `TODO.md` — the latter being the module-by-module record of what is bound, which
|
|
297
|
+
is what tells someone whether the gem covers their case. Comments now record what a reader cannot
|
|
298
|
+
infer: that rake-compiler rewrites `platform`, `required_ruby_version` and `extensions` for binary
|
|
299
|
+
gems, and that `required_rubygems_version` is deliberately unset because pinning `>= 3.3.22` here
|
|
300
|
+
would lock Ruby 3.1.0 (RubyGems 3.3.3) out of the source gem. Reformatted to 2-space indentation.
|
|
301
|
+
No `homepage_uri`: it would duplicate `source_code_uri`, and RubyGems warns that only the first of a
|
|
302
|
+
duplicated link is shown.
|
|
303
|
+
* `sfml.gemspec` → `sfml3-rb.gemspec`: description now describes the self-building install rather
|
|
304
|
+
than a still-planned migration; license changed to `0BSD`, matching `LICENSE.md`.
|
|
305
|
+
* **Gem package renamed from `sfml` to `sfml3-rb`** (`gem install sfml3-rb`). `require 'sfml'` and the
|
|
306
|
+
`SFML` Ruby module are unchanged — only the RubyGems package name moved.
|
|
307
|
+
|
|
308
|
+
### Fixed
|
|
309
|
+
* `Circle#scale` returned the position, not the scale.
|
|
310
|
+
* `RenderState` was missing a `dmark` slot; the wrapped struct now holds its texture/shader Ruby
|
|
311
|
+
references so a GC cannot collect them while the states are in use.
|
|
312
|
+
* `View#position`/`position=` wrote the viewport under a misleading name (removed).
|
|
313
|
+
* `raise_method_no_implemented` crashed on `NULL` and never reached its message branch.
|
|
314
|
+
* `Window#joystick_threshold=` treated the threshold as a boolean.
|
|
315
|
+
* `Circle#draw` raised unconditionally: its second argument check tested `rb_target` against
|
|
316
|
+
`RenderState` instead of `rb_state` (`ext/circle.c`), and a valid `Target` is never a `RenderState`,
|
|
317
|
+
so no call could get past it.
|
|
318
|
+
* `Target#draw` unwrapped its `state` argument with no class check — the one remaining place a
|
|
319
|
+
caller-supplied object reached a struct accessor unguarded. Combined with the untyped
|
|
320
|
+
`Data_Get_Struct` it used to call, passing the wrong object there reinterpreted an arbitrary
|
|
321
|
+
pointer; it now raises before that can happen.
|
|
322
|
+
* `ext/ext/module.h` and `ext/ext/klass/transform.h` each declared a `static VALUE` at file scope in a
|
|
323
|
+
**header**, giving every one of the ~10 including translation units its own zero-initialized copy.
|
|
324
|
+
`rb_mExt` moved into `ext.c`, its only user; `rb_cTransform` was dead and is gone.
|
|
325
|
+
* An unused `hash` local in `Event_key` (`ext/event.c`).
|
|
326
|
+
* Gem metadata: summary typo, empty description, incorrect homepage.
|
|
327
|
+
* Double-free crash (`free(): double free detected in tcache`) in `Circle`, `Clock`, `Transformable`,
|
|
328
|
+
and `Window`: their `_free` functions called both CSFML's own `sfX_destroy` *and* `free()` on the
|
|
329
|
+
same pointer, though `sfX_destroy` already releases it.
|
|
330
|
+
* `Event#size` read `event->size.height` for both components, so a resize event always reported a
|
|
331
|
+
square. Also fixes the CSFML 3 struct layout (`sfSizeEvent.size` is now a vector, not flat
|
|
332
|
+
`width`/`height`).
|
|
333
|
+
* `View#get_rotation` and `RenderTarget#draw` were missing `return` statements, so both handed an
|
|
334
|
+
uninitialized `VALUE` back to Ruby — the same crash class as the double-free above, just not yet
|
|
335
|
+
triggered by the test suite.
|
|
336
|
+
* `Transform.inverse` was bound to `Transform_combine` instead of `Transform_inverse` — a copy-paste
|
|
337
|
+
bug that made `.inverse` silently wrong (and unusable at 1 argument).
|
|
338
|
+
* `Window#view=`, `#view`, and `#default_view` were fully implemented but never registered — calling
|
|
339
|
+
them raised `NoMethodError`.
|
|
340
|
+
* CSFML 3 API port: video mode fields, `sfRenderWindow_create`'s new window-state parameter,
|
|
341
|
+
`sfRenderWindow_waitEvent`'s new timeout parameter, and `sfFloatRect`'s `position`/`size` fields
|
|
342
|
+
(was flat `left/top/width/height`).
|
|
343
|
+
* A `%ul` printf format-string bug in `ext/exceptions.c` produced garbled error messages (e.g.
|
|
344
|
+
"given 3l"); corrected to `%lu`.
|
|
345
|
+
* `test/sfml_test.rb`: `require 'minitest/unit'` (removed from modern minitest) →
|
|
346
|
+
`require 'minitest/autorun'`; classes referenced without their `SFML::` namespace;
|
|
347
|
+
`assert_in_epsilon` used directly on arrays, which fails because it calls `.abs` on the expected
|
|
348
|
+
value.
|
|
349
|
+
|
|
350
|
+
### Known issues
|
|
351
|
+
* Classes that wrap `T_DATA` never call `rb_define_alloc_func`, so Ruby prints `undefining the
|
|
352
|
+
allocator of T_DATA class ...` once per class on first construction. Harmless and long-standing;
|
|
353
|
+
fixing it means moving construction out of the singleton `new` into an alloc func plus
|
|
354
|
+
`initialize`.
|
|
355
|
+
* Of the nine binary-gem targets, only `x86_64-linux-gnu` has been verified end to end (built,
|
|
356
|
+
installed, full suite passes). `x64-mingw-ucrt` cross-builds and links cleanly with correct PE
|
|
357
|
+
imports but has not been run on Windows. The rest have not been run on their target hardware;
|
|
358
|
+
`aarch64-linux-gnu`, `x86_64-darwin` and `arm64-darwin` are marked `experimental` in
|
|
359
|
+
`publish.yaml`, so a failure can't hold back a release.
|
|
360
|
+
* The Windows gem imports `libwinpthread-1.dll`, which RubyInstaller ships in its
|
|
361
|
+
`ruby_builtin_dlls` directory. If that ever proves unreliable, add `-lwinpthread` to the
|
|
362
|
+
`-Wl,-Bstatic` group in `Ports.cxx_runtime`.
|
|
363
|
+
* `bundle exec rubocop` does not pass on the repository as a whole (55 offenses across 14 files, 40
|
|
364
|
+
autocorrectable, mostly `Style/FrozenStringLiteralComment`) — this predates the packaging work and
|
|
365
|
+
`check.yaml` has been failing on it. The gemspec's own remaining offence is
|
|
366
|
+
`Gemspec/RequireMFA`, left deliberately: setting `rubygems_mfa_required` requires MFA on every
|
|
367
|
+
owner's RubyGems account, and `publish.yaml` pushes with an API token.
|
|
368
|
+
* [TODO.md](TODO.md) tracks SFML 3 → Ruby API porting coverage, module by module.
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
BSD Zero Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Algaves
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# sfml3.rb
|
|
2
|
+
|
|
3
|
+
Ruby bindings for [SFML 3](https://www.sfml-dev.org/), via its C API, [CSFML](https://github.com/SFML/CSFML).
|
|
4
|
+
|
|
5
|
+
[](https://www.ruby-lang.org/)
|
|
6
|
+
[](https://github.com/algaves/sfml3.rb/actions/workflows/test.yaml)
|
|
7
|
+
[](https://github.com/algaves/sfml3.rb/actions/workflows/check.yaml)
|
|
8
|
+
[](https://rubygems.org/gems/sfml3-rb)
|
|
9
|
+
[](https://rubygems.org/gems/sfml3-rb)
|
|
10
|
+
[](LICENSE.md)
|
|
11
|
+
|
|
12
|
+
Latest release: **0.3.0**, bound against **CSFML 3**.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
* **Broad coverage of SFML 3**, bound through CSFML: windows and events, graphics, audio, network,
|
|
17
|
+
and the system layer, with every `sf*` entry point tracked in [TODO.md](TODO.md).
|
|
18
|
+
* **Precompiled binary gems** for common platforms, with FreeType, SFML 3 and CSFML 3 statically
|
|
19
|
+
linked in — no toolchain and nothing to install system-wide.
|
|
20
|
+
* **A source fallback everywhere else**, which downloads and builds the pinned, checksum-verified
|
|
21
|
+
dependencies at install time, so the gem works on macOS, ARM and the BSDs out of the box.
|
|
22
|
+
* **Complete API documentation and types**: every class, module, method and constant is documented
|
|
23
|
+
on [rubydoc.info](https://rubydoc.info/gems/sfml3-rb) and covered by RBS signatures shipped in
|
|
24
|
+
the gem.
|
|
25
|
+
* **A close fit to SFML's own model**: classes mirror the C++ types (Window, Texture, Sprite,
|
|
26
|
+
Sound, ...) minus the parts that only exist in C++, like `std::string` and exceptions.
|
|
27
|
+
|
|
28
|
+
## Table of Contents
|
|
29
|
+
|
|
30
|
+
* [Installation](#installation)
|
|
31
|
+
* [Quick Start](#quick-start)
|
|
32
|
+
* [Documentation](#documentation)
|
|
33
|
+
* [Development](#development)
|
|
34
|
+
* [Contributing](#contributing)
|
|
35
|
+
* [Acknowledgements](#acknowledgements)
|
|
36
|
+
* [License](#license)
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
gem install sfml3-rb
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
On a platform with a precompiled gem this installs a binary with FreeType, SFML 3 and CSFML 3
|
|
45
|
+
already linked in — no toolchain, no build, nothing to install system-wide:
|
|
46
|
+
|
|
47
|
+
| Platform | Ruby | Status |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `x86_64-linux-gnu` | 3.1 – 4.0 | built, installed and tested |
|
|
50
|
+
| `x86-linux-gnu` | 3.1 – 4.0 | 32-bit glibc Linux |
|
|
51
|
+
| `x86_64-linux-musl` | 3.1 – 4.0 | Alpine and other musl systems |
|
|
52
|
+
| `x86-linux-musl` | 3.1 – 4.0 | 32-bit musl |
|
|
53
|
+
| `x64-mingw-ucrt` | 3.1 – 4.0 | 64-bit Windows, RubyInstaller 3.1+ |
|
|
54
|
+
| `x86-mingw32` | 3.1 – **3.4** | 32-bit Windows |
|
|
55
|
+
| `aarch64-linux-gnu` | 3.1 – 4.0 | experimental, cross-built and run on a native arm64 CI runner |
|
|
56
|
+
| `aarch64-linux-musl`, `arm-linux-gnu`, `arm-linux-musl` | 3.1 – 4.0 | experimental, not yet built |
|
|
57
|
+
| `aarch64-mingw-ucrt` | 3.4 – **4.0** | experimental, 64-bit Windows on ARM |
|
|
58
|
+
| `x86_64-darwin`, `arm64-darwin` | 3.1 – 4.0 | experimental, not yet built |
|
|
59
|
+
|
|
60
|
+
Each gem carries one extension per Ruby ABI. Three gaps come from upstream rather than from this
|
|
61
|
+
project: **RubyInstaller publishes no 32-bit Ruby 4.0**, so `x86-mingw32` stops at 3.4; 64-bit
|
|
62
|
+
Windows before Ruby 3.1 used a different platform (`x64-mingw32`), which is not built; and the
|
|
63
|
+
cross-compilation image for `aarch64-mingw-ucrt` carries no cross Ruby older than 3.4, so that
|
|
64
|
+
gem has no floor below it.
|
|
65
|
+
|
|
66
|
+
### Building from source
|
|
67
|
+
|
|
68
|
+
Anywhere else — macOS, ARM, the BSDs — RubyGems falls back to the source gem, which downloads and
|
|
69
|
+
builds FreeType, SFML 3 and CSFML 3 from pinned, checksum-verified tarballs at install time. That
|
|
70
|
+
takes a few minutes and needs:
|
|
71
|
+
|
|
72
|
+
* Ruby >= 3.1
|
|
73
|
+
* A C/C++ toolchain and CMake >= 3.22
|
|
74
|
+
* On Linux, the X11/udev/OpenGL development headers SFML links against — these can't be bundled.
|
|
75
|
+
|
|
76
|
+
On Fedora:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
sudo dnf install cmake gcc-c++ libX11-devel \
|
|
80
|
+
libXrandr-devel libXcursor-devel libXi-devel systemd-devel libglvnd-devel
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
On Debian/Ubuntu:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
sudo apt-get install cmake build-essential libx11-dev \
|
|
87
|
+
libxrandr-dev libxcursor-dev libxi-dev libudev-dev libgl1-mesa-dev
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Each installed gem version builds its own copy; there's no build cache shared across versions.
|
|
91
|
+
|
|
92
|
+
### Linking against system libraries
|
|
93
|
+
|
|
94
|
+
To link against a system CSFML 3 instead (no download, no build):
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
gem install sfml3-rb -- --enable-system-libraries
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Quick Start
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
require 'sfml'
|
|
104
|
+
include SFML
|
|
105
|
+
|
|
106
|
+
window = Window.new VideoMode.new(640, 480, 32), 'SFML'
|
|
107
|
+
event = Event.new
|
|
108
|
+
|
|
109
|
+
while window.is_open?
|
|
110
|
+
while window.poll_event! event
|
|
111
|
+
window.close! if event.type == 'closed'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
window.clear [51, 76, 102, 255] # [r, g, b, a], 0-255
|
|
115
|
+
window.display
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Event types are strings (`'closed'`, `'resized'`, `'key-pressed'`, ...); keys and buttons are enums.
|
|
120
|
+
|
|
121
|
+
See [`test/hello-world.rb`](test/hello-world.rb) for a fuller example with shapes and transforms,
|
|
122
|
+
and [`test/matrix-transformable.rb`](test/matrix-transformable.rb) for a visual demo. Neither is
|
|
123
|
+
part of the test suite.
|
|
124
|
+
|
|
125
|
+
## Documentation
|
|
126
|
+
|
|
127
|
+
* [API reference](https://rubydoc.info/gems/sfml3-rb) — every class, module, method and constant,
|
|
128
|
+
built from the YARD comments in `ext/**/*.c`.
|
|
129
|
+
* RBS type signatures (`sig/**/*.rbs`) ship in the gem for IDE completion (Solargraph, RubyMine)
|
|
130
|
+
and static type-checking (Sorbet, Steep). Validate them with `rake rbs`.
|
|
131
|
+
* [CHANGELOG.md](CHANGELOG.md) — what changed in each release.
|
|
132
|
+
* [TODO.md](TODO.md) — module-by-module porting coverage and what is deliberately unbound.
|
|
133
|
+
|
|
134
|
+
## Development
|
|
135
|
+
|
|
136
|
+
```sh
|
|
137
|
+
rake ports # build the vendored FreeType + SFML 3 + CSFML 3 (rake compile does this too)
|
|
138
|
+
rake compile # build the C extension into lib/sfml/
|
|
139
|
+
rake test # compile, then run the test suite
|
|
140
|
+
rake gem # build the source gem into pkg/
|
|
141
|
+
rake yard # build API docs into doc/
|
|
142
|
+
rake rbs # validate sig/**/*.rbs
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`rake githooks:install` points your checkout at the committed `.githooks/` pre-commit hook, which
|
|
146
|
+
lints staged Ruby with RuboCop and auto-formats staged C with clang-format (`sudo dnf install
|
|
147
|
+
clang-tools-extra` on Fedora for the C side).
|
|
148
|
+
|
|
149
|
+
`CMakeLists.txt` is a CLion/IDE convenience build against the same vendored `ports/` prefix — `rake`
|
|
150
|
+
is the build of record.
|
|
151
|
+
|
|
152
|
+
The C extension under `ext/` mirrors SFML's own subsystems, with each binding's `.c` and `.h`
|
|
153
|
+
side by side: `core/` (CSFML umbrella header, macros, exceptions, UTF-32 conversion),
|
|
154
|
+
`system/` (Clock, Time, vectors, streams), `window/` (Window, Event, VideoMode, and the input
|
|
155
|
+
devices), `graphics/` (shapes, Color, Transform, View, Texture, Text, Shader, the render targets),
|
|
156
|
+
`audio/` and `network/`. Includes are subsystem-relative, e.g. `#include "graphics/circle.h"`.
|
|
157
|
+
|
|
158
|
+
Two `.inc` files hold method bodies shared by several classes and are included once per class with
|
|
159
|
+
a different macro prefix: `audio/sound_source.inc` (Sound, Music, SoundStream) and
|
|
160
|
+
`graphics/render_target.inc` (Window, RenderTexture).
|
|
161
|
+
|
|
162
|
+
Note that mkmf flattens object files to their basenames, so every `.c` filename has to stay
|
|
163
|
+
unique across the whole tree — and that `$srcs` is baked into the generated Makefile, so after
|
|
164
|
+
adding a `.c` file run `touch ext/extconf.rb && rake compile` (or `rake clean compile`), otherwise
|
|
165
|
+
it is silently left out of the link.
|
|
166
|
+
|
|
167
|
+
### Building the binary gems
|
|
168
|
+
|
|
169
|
+
Cross-compilation runs in [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock),
|
|
170
|
+
which supplies the cross toolchains and the cross-compiled rubies. It needs Docker or Podman, and
|
|
171
|
+
pulls a large image per platform on first use.
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
rake platforms # list the targets
|
|
175
|
+
rake gem:x86_64-linux-gnu # build one platform into pkg/
|
|
176
|
+
rake gem:native # build all of them
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Each run provisions the container with [`script/provision.sh`](script/provision.sh) — a current
|
|
180
|
+
CMake everywhere, plus the target-side X11/udev/GL development files on Linux targets, which the
|
|
181
|
+
images don't ship. Windows and macOS need nothing extra: SFML uses OS libraries and frameworks the
|
|
182
|
+
mingw toolchain and the osxcross SDK already provide.
|
|
183
|
+
|
|
184
|
+
Binary gems carry one extension per Ruby ABI under `lib/sfml/<major.minor>/`; `lib/sfml.rb` prefers
|
|
185
|
+
that and falls back to the single `lib/sfml/sfml_ext.so` a source build installs.
|
|
186
|
+
|
|
187
|
+
## Contributing
|
|
188
|
+
|
|
189
|
+
Bug reports and pull requests are welcome on
|
|
190
|
+
[GitHub](https://github.com/algaves/sfml3.rb/issues). Before opening a pull request:
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
bundle install
|
|
194
|
+
bundle exec rake test # build the extension and run the suite
|
|
195
|
+
bundle exec rubocop # lint Ruby (CI enforces this)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Install the pre-commit hook with `bundle exec rake githooks:install` so staged Ruby is linted and
|
|
199
|
+
staged C is formatted automatically. The C build is warning-clean under `SFML_STRICT=1`; keep it
|
|
200
|
+
that way.
|
|
201
|
+
|
|
202
|
+
## Acknowledgements
|
|
203
|
+
|
|
204
|
+
This gem would not exist without [SFML](https://www.sfml-dev.org/) and its C binding,
|
|
205
|
+
[CSFML](https://github.com/SFML/CSFML), both maintained by the SFML team. The source build also
|
|
206
|
+
vendors and links FreeType, Ogg, Vorbis and FLAC; see [`ext/ports.rb`](ext/ports.rb) and the
|
|
207
|
+
[LICENSE](LICENSE.md) for their terms.
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
This project is licensed under the BSD Zero Clause License (0BSD) - see the [LICENSE](LICENSE.md) file for details.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
Developed by: [Algaves](https://github.com/algaves/sfml3.rb) @ 2026
|