Set up Fedora for Rust development with Bevy engine!
Fedora dependencies
First of all, if we have Rust installed on our system, we will uninstall it.
$ sudo dnf remove rust -y; sudo dnf autoremove -y; sudo dnf clean packages
We install the rustup tool.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the instructions from the terminal output.
It is necessary to install graphics and audio dependencies that will be used by Bevy game engine. For Fedora Linux the needed packages are:
gcc-c++
libX11-devel
alsa-lib-devel
systemd-devel
We use dnf to install all of them.
$ sudo dnf install gcc-c++ libX11-devel alsa-lib-devel systemd-devel
If you are GNOME user you also need to install the wayland development package and xkbcommon library for Fedora.
$ sudo dnf install wayland-devel libxkbcommon-devel
Project example
Now everything should be ready for Rust development with bevy. Let's do a quick example creating a new project.
$ cargo new example_3d_scene
Let's add Bevy to the project dependencies (project root directory). It takes a while downloading all the dependencies for the first time.
$ cargo add bevy
Place the following code from Bevy GitHub repo into 'src/main.rs' file.
//! A simple 3D scene with light shining over a cube sitting on a plane.
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
}
/// set up a simple 3D scene
fn setup(
mut commands: Commands,
mut meshes: ResMut>,
mut materials: ResMut>,
) {
// plane
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..default()
});
// cube
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
// light
commands.spawn_bundle(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
// camera
commands.spawn_bundle(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
}
$ cargo run
When compilation is finished you should see a window like this.