An SDL (3.4) & SDL_ttf (3.2) Rust wrapper.
It's somewhere between raw sdl3-sys bindings, and a higher-level graphics framework with a radically different API. The general plan is:
[!IMPORTANT] This crate isn't concerned with how you find, and link with, SDL and its satellite libraries on your system. These topics are better covered by the sdl3-sys docs.
[!NOTE] Functions and methods usually map 1:1 to their SDL counterparts in terms of functionality (in such cases, there is always a corresponding
#[doc(alias = "...")]attribute). There is an effort to "pluck" documentation from the SDL wiki and map it to Rust abstractions, while preserving the meaning. The first pass has been done via LLMs, so there may be some slop.
Most, but not all, functionality requires two things from the init module to be in scope:
init::Contextinit::Video for Window::newSince SDL works with opaque pointers, using Rust references would cause unnecessary double indirection. To avoid this, Sandlot uses custom types with matching properties. For example:
Texture is an owned object which will Drop the underlying handle upon going out of scopeRef<'a, Texture> and RefMut<'a, Texture> mimic &Texture and &mut Texture
as_ref() methodRef only implements Deref for its handle, while RefMut also implements DerefMutTextureHandle is analogous to a pointer. It exposes all methods, but is not lifetime-bound to anythingAllocations originating from SDL are wrapped in a custom implementation of Box and String.
These might not have exact 1:1 semantics with their Rust counterparts; check documentation for specifics.
In an attempt to justify the time spent on this project, here is a list of things that, in my eyes, make Sandlot much neater to use over raw SDL bindings:
Drop impl'd where applicable1Ref for borrowing opaque handles without extra indirectionsandlot::Result<T> instead of SDL_GetError()Box and String for mapping SDL allocations to RustCertain SDL_gpu objects are an exception, since their destructors require an extra parameter. Such objects have a "manual" drop() method, and have proper documentation of this fact. ↩
518 commits
Rust
99.0%
An SDL (3.4) & SDL_ttf (3.2) Rust wrapper.
It's somewhere between raw sdl3-sys bindings, and a higher-level graphics framework with a radically different API. The general plan is:
[!IMPORTANT] This crate isn't concerned with how you find, and link with, SDL and its satellite libraries on your system. These topics are better covered by the sdl3-sys docs.
[!NOTE] Functions and methods usually map 1:1 to their SDL counterparts in terms of functionality (in such cases, there is always a corresponding
#[doc(alias = "...")]attribute). There is an effort to "pluck" documentation from the SDL wiki and map it to Rust abstractions, while preserving the meaning. The first pass has been done via LLMs, so there may be some slop.
Most, but not all, functionality requires two things from the init module to be in scope:
init::Contextinit::Video for Window::newSince SDL works with opaque pointers, using Rust references would cause unnecessary double indirection. To avoid this, Sandlot uses custom types with matching properties. For example:
Texture is an owned object which will Drop the underlying handle upon going out of scopeRef<'a, Texture> and RefMut<'a, Texture> mimic &Texture and &mut Texture
as_ref() methodRef only implements Deref for its handle, while RefMut also implements DerefMutTextureHandle is analogous to a pointer. It exposes all methods, but is not lifetime-bound to anythingAllocations originating from SDL are wrapped in a custom implementation of Box and String.
These might not have exact 1:1 semantics with their Rust counterparts; check documentation for specifics.
In an attempt to justify the time spent on this project, here is a list of things that, in my eyes, make Sandlot much neater to use over raw SDL bindings:
Drop impl'd where applicable1Ref for borrowing opaque handles without extra indirectionsandlot::Result<T> instead of SDL_GetError()Box and String for mapping SDL allocations to RustCertain SDL_gpu objects are an exception, since their destructors require an extra parameter. Such objects have a "manual" drop() method, and have proper documentation of this fact. ↩
518 commits
Rust
99.0%