Rust
This plugin enables full access to Tellusim API from the Rust programming language. It is compatible with Windows, Linux, and macOS platforms. The plugin also includes a comprehensive and user-friendly 3D math library for high-performance graphics development.
info
The plugins/binding/rust/source
directory contains Rust bindings.
The target Rust library is libTellusimRS
, which depends on libTellusimC
and libTellusim
.
See Readme.txt for build instructions.
// create app
let mut app = App::new();
if !app.create() { exit(1) }
// create window
let mut window = Window::new_with_platform_index(app.platform(), app.device());
if !window.is_valid_ptr() { exit(1) }
window.set_size(app.width(), app.height());
// set close callback
window.set_close_clicked_callback({
let mut window = window.copy_ptr();
move || { window.stop() }
});
// set keyboard callback
window.set_keyboard_pressed_callback({
let mut window = window.copy_ptr();
move |key: u32, _code: u32| {
if key == WindowKey::Esc as u32 { window.stop() }
if key == WindowKey::F12 as u32 {
let mut image = Image::new();
if window.grab(&mut image) && image.save("screenshot.png") {
ts_log!(Message, "Screenshot\n");
}
}
}
});
// create and show the window
let title = window.platform_name() + &" Tellusim::Rust";
if !window.create_with_title_flags(&title, WindowFlags::DefaultFlags) || !window.set_hidden(false) { exit(1) }