-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Poll system information in separate thread
- Loading branch information
Showing
3 changed files
with
136 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#![allow(missing_docs)] | ||
|
||
use bevy::{ | ||
diagnostic::{ | ||
FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin, SystemInformationDiagnosticsPlugin, | ||
}, | ||
prelude::*, | ||
window::PresentMode, | ||
}; | ||
|
||
fn main() { | ||
App::new() | ||
.add_plugins(( | ||
DefaultPlugins, | ||
FrameTimeDiagnosticsPlugin, | ||
LogDiagnosticsPlugin::default(), | ||
SystemInformationDiagnosticsPlugin, | ||
)) | ||
.add_systems(Startup, setup) | ||
.add_systems(Update, change_window_mode) | ||
.run(); | ||
} | ||
|
||
fn change_window_mode(mut windows: Query<&mut Window, Added<Window>>) { | ||
for mut window in &mut windows { | ||
window.present_mode = PresentMode::AutoNoVsync; | ||
} | ||
} | ||
|
||
/// set up a simple 3D scene | ||
fn setup( | ||
mut commands: Commands, | ||
mut meshes: ResMut<Assets<Mesh>>, | ||
mut materials: ResMut<Assets<StandardMaterial>>, | ||
) { | ||
// circular base | ||
commands.spawn(PbrBundle { | ||
mesh: meshes.add(Circle::new(4.0)), | ||
material: materials.add(Color::WHITE), | ||
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), | ||
..default() | ||
}); | ||
// cube | ||
commands.spawn(PbrBundle { | ||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), | ||
material: materials.add(Color::srgb_u8(124, 144, 255)), | ||
transform: Transform::from_xyz(0.0, 0.5, 0.0), | ||
..default() | ||
}); | ||
// light | ||
commands.spawn(PointLightBundle { | ||
point_light: PointLight { | ||
shadows_enabled: true, | ||
..default() | ||
}, | ||
transform: Transform::from_xyz(4.0, 8.0, 4.0), | ||
..default() | ||
}); | ||
// camera | ||
commands.spawn(Camera3dBundle { | ||
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), | ||
..default() | ||
}); | ||
} |