Crate sfml [−] [src]
rust-sfml
Rust bindings for SFML, the Simple and Fast Multimedia Library.
Prerequisites
SFML 2.4 and CSFML 2.4 must be installed on your computer. You can download them here:
- SFML 2.4: http://www.sfml-dev.org/download.php
- CSFML 2.4: http://www.sfml-dev.org/download/csfml/
Rust-sfml works on Linux, windows and OSX.
Short example
Here is a short example, draw a circle shape and display it.
extern crate sfml; use sfml::system::Vector2f; use sfml::window::{ContextSettings, VideoMode, Event, style}; use sfml::graphics::{CircleShape, Color, RenderTarget, RenderWindow, Shape, Transformable}; fn main() { // Create the window of the application let mut window = RenderWindow::new(VideoMode::new(800, 600, 32), "SFML Example", style::CLOSE, &ContextSettings::default()) .unwrap(); // Create a CircleShape let mut circle = CircleShape::new(); circle.set_radius(30.); circle.set_fill_color(&Color::red()); circle.set_position(&Vector2f::new(100., 100.)); loop { // Handle events for event in window.events() { if let Event::Closed = event { return; } } // Clear the window window.clear(&Color::rgb(0, 200, 200)); // Draw the shape window.draw(&circle); // Display things on screen window.display() } }
License
This software is a binding of the SFML library created by Laurent Gomila, which is provided under the Zlib/png license.
This software is provided under the same license than the SFML, the Zlib/png license.
Modules
audio |
Sounds, streaming (musics or custom sources), recording, spatialization |
graphics |
2D graphics module: sprites, text, shapes.. |
system |
Base module of SFML, defining various utilities. |
window |
Provides OpenGL-based windows, and abstractions for events and input handling. |