radiant-rs
Very easy to use, thread-safe Rust sprite rendering engine.
This is work-in-progress. The API is incomplete and will likely still change somewhat. Have a look if you like, but don't depend on it :)
To compile the examples, use e.g. cargo run --release --example blobs
. See examples folder for other available examples.
10 lines to the first frame
- Create a display with
Display::new()
. This represents the window/fullscreen. - Create a renderer with
Renderer::new()
. It does all the work. - Grab a context from the renderer using the
context()
method. It is only required in order to load resources. - Use it to load sprites or fonts with e.g.
Font::from_file()
orSprite::from_file()
. - Create as many drawing layers as you need using
Layer::new()
. - Draw stuff onto the layer using the
Font::write()
orSprite::draw()
methods. - Clear the drawing target using
Renderer::clear_target()
. (If you don't want to clear, useRenderer::prepare_target()
instead.) - Draw the contents of your layers onto the target using
Renderer::draw_layer()
. - Make the target visible via
Renderer::swap_target()
. - Goto 6.
Multi-threaded environments
- Stick fonts, sprites, and layers or scenes into
Arc
s.
The context received fromRenderer::context()
is already wrapped inArc
. - Clone the
Arc
s for each thread that needs their contents. - Move the clones into the thread.
- Draw onto your layers, load sprites etc. from however many threads you like. Layers are non-blocking for drawing operations, blocking for other manipulations (e.g. matrix modification).
- Perform steps 7-10 from the above list in the thread that created the
Renderer
; both it andDisplay
do not implementSend