Split off present mode
This commit is contained in:
parent
cb227b1e03
commit
3195a945a4
@ -101,11 +101,19 @@ impl DerefMut for ExtractedWindows {
|
||||
fn extract_windows(
|
||||
mut extracted_windows: ResMut<ExtractedWindows>,
|
||||
mut closing: Extract<EventReader<WindowClosing>>,
|
||||
windows: Extract<Query<(Entity, &Window, &RawHandleWrapper, Option<&PrimaryWindow>)>>,
|
||||
windows: Extract<
|
||||
Query<(
|
||||
Entity,
|
||||
&Window,
|
||||
&PresentMode,
|
||||
&RawHandleWrapper,
|
||||
Option<&PrimaryWindow>,
|
||||
)>,
|
||||
>,
|
||||
mut removed: Extract<RemovedComponents<RawHandleWrapper>>,
|
||||
mut window_surfaces: ResMut<WindowSurfaces>,
|
||||
) {
|
||||
for (entity, window, handle, primary) in windows.iter() {
|
||||
for (entity, window, present_mode, handle, primary) in windows.iter() {
|
||||
if primary.is_some() {
|
||||
extracted_windows.primary = Some(entity);
|
||||
}
|
||||
@ -120,7 +128,7 @@ fn extract_windows(
|
||||
handle: handle.clone(),
|
||||
physical_width: new_width,
|
||||
physical_height: new_height,
|
||||
present_mode: window.present_mode,
|
||||
present_mode: *present_mode,
|
||||
desired_maximum_frame_latency: window.desired_maximum_frame_latency,
|
||||
swap_chain_texture: None,
|
||||
swap_chain_texture_view: None,
|
||||
@ -134,8 +142,7 @@ fn extract_windows(
|
||||
extracted_window.swap_chain_texture_view = None;
|
||||
extracted_window.size_changed = new_width != extracted_window.physical_width
|
||||
|| new_height != extracted_window.physical_height;
|
||||
extracted_window.present_mode_changed =
|
||||
window.present_mode != extracted_window.present_mode;
|
||||
extracted_window.present_mode_changed = *present_mode != extracted_window.present_mode;
|
||||
|
||||
if extracted_window.size_changed {
|
||||
debug!(
|
||||
@ -152,9 +159,9 @@ fn extract_windows(
|
||||
if extracted_window.present_mode_changed {
|
||||
debug!(
|
||||
"Window Present Mode changed from {:?} to {:?}",
|
||||
extracted_window.present_mode, window.present_mode
|
||||
extracted_window.present_mode, *present_mode
|
||||
);
|
||||
extracted_window.present_mode = window.present_mode;
|
||||
extracted_window.present_mode = *present_mode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -160,10 +160,8 @@ impl ContainsEntity for NormalizedWindowRef {
|
||||
all(feature = "serialize", feature = "bevy_reflect"),
|
||||
reflect(Serialize, Deserialize)
|
||||
)]
|
||||
#[require(CursorOptions)]
|
||||
#[require(CursorOptions, PresentMode)]
|
||||
pub struct Window {
|
||||
/// What presentation mode to give the window.
|
||||
pub present_mode: PresentMode,
|
||||
/// Which fullscreen or windowing mode should be used.
|
||||
pub mode: WindowMode,
|
||||
/// Where the window should be placed.
|
||||
@ -470,7 +468,6 @@ impl Default for Window {
|
||||
Self {
|
||||
title: DEFAULT_WINDOW_TITLE.to_owned(),
|
||||
name: None,
|
||||
present_mode: Default::default(),
|
||||
mode: Default::default(),
|
||||
position: Default::default(),
|
||||
resolution: Default::default(),
|
||||
@ -1207,11 +1204,11 @@ pub enum VideoModeSelection {
|
||||
/// [`AutoVsync`]: PresentMode::AutoVsync
|
||||
/// [`AutoNoVsync`]: PresentMode::AutoNoVsync
|
||||
#[repr(C)]
|
||||
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Component, Default, Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(
|
||||
feature = "bevy_reflect",
|
||||
derive(Reflect),
|
||||
reflect(Debug, PartialEq, Hash, Clone)
|
||||
reflect(Component, Debug, PartialEq, Hash, Clone)
|
||||
)]
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(
|
||||
|
||||
@ -15,7 +15,7 @@ use bevy::{
|
||||
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
||||
},
|
||||
sprite::AlphaMode2d,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
use rand::{seq::SliceRandom, Rng, SeedableRng};
|
||||
@ -132,16 +132,7 @@ fn main() {
|
||||
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "BevyMark".into(),
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -154,6 +145,7 @@ fn main() {
|
||||
count: 0,
|
||||
color: Color::WHITE,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(FixedUpdate, scheduled_spawner)
|
||||
.add_systems(
|
||||
@ -171,6 +163,16 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.title = "BevyMark".to_string();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct BirdScheduled {
|
||||
waves: usize,
|
||||
|
||||
@ -8,7 +8,7 @@ use std::time::Duration;
|
||||
use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
@ -22,20 +22,13 @@ fn main() {
|
||||
.add_plugins((
|
||||
LogDiagnosticsPlugin::default(),
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
))
|
||||
.insert_resource(WinitSettings {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -48,6 +41,15 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
assets: Res<AssetServer>,
|
||||
|
||||
@ -6,7 +6,7 @@ use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
text::TextColor,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
@ -73,14 +73,7 @@ fn main() {
|
||||
let mut app = App::new();
|
||||
|
||||
app.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -88,6 +81,7 @@ fn main() {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Update, (button_system, set_text_colors_changed));
|
||||
|
||||
if !args.no_camera {
|
||||
@ -129,6 +123,15 @@ fn main() {
|
||||
app.insert_resource(args).run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn set_text_colors_changed(mut colors: Query<&mut TextColor>) {
|
||||
for mut text_color in colors.iter_mut() {
|
||||
text_color.set_changed();
|
||||
|
||||
@ -6,24 +6,27 @@ use bevy::{
|
||||
math::ops::{cos, sin},
|
||||
prelude::*,
|
||||
render::camera::Viewport,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}))
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, rotate_cameras)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
const CAMERA_ROWS: usize = 4;
|
||||
const CAMERA_COLS: usize = 4;
|
||||
const NUM_LIGHTS: usize = 5;
|
||||
|
||||
@ -22,7 +22,7 @@ use bevy::{
|
||||
render_resource::{Extent3d, TextureDimension, TextureFormat},
|
||||
view::{NoCpuCulling, NoFrustumCulling, NoIndirectDrawing},
|
||||
},
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
use rand::{seq::SliceRandom, Rng, SeedableRng};
|
||||
@ -106,14 +106,7 @@ fn main() {
|
||||
|
||||
let mut app = App::new();
|
||||
app.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -121,6 +114,7 @@ fn main() {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (move_camera, print_mesh_count));
|
||||
|
||||
@ -131,6 +125,15 @@ fn main() {
|
||||
app.insert_resource(args).run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
const WIDTH: usize = 200;
|
||||
const HEIGHT: usize = 200;
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
pbr::CascadeShadowConfigBuilder,
|
||||
prelude::*,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
@ -41,16 +41,7 @@ fn main() {
|
||||
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "🦊🦊🦊 Many Foxes! 🦊🦊🦊".into(),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -64,6 +55,7 @@ fn main() {
|
||||
moving: true,
|
||||
sync: args.sync,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -76,6 +68,16 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.title = "🦊🦊🦊 Many Foxes! 🦊🦊🦊".to_string();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct Animations {
|
||||
node_indices: Vec<AnimationNodeIndex>,
|
||||
|
||||
@ -5,7 +5,7 @@ use std::f32::consts::TAU;
|
||||
use bevy::{
|
||||
diagnostic::{Diagnostic, DiagnosticsStore, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
@ -14,15 +14,7 @@ const SYSTEM_COUNT: u32 = 10;
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
app.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "Many Debug Lines".to_string(),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -34,6 +26,7 @@ fn main() {
|
||||
line_count: 50_000,
|
||||
fancy: false,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (input, ui_system));
|
||||
|
||||
@ -44,6 +37,16 @@ fn main() {
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.title = "Many Debug Lines".to_string();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug)]
|
||||
struct Config {
|
||||
line_count: u32,
|
||||
|
||||
@ -11,7 +11,7 @@ use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
text::{LineBreak, TextBounds},
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
@ -40,14 +40,7 @@ fn main() {
|
||||
|
||||
let mut app = App::new();
|
||||
app.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -55,6 +48,7 @@ fn main() {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup);
|
||||
|
||||
if args.recompute_text {
|
||||
@ -64,6 +58,15 @@ fn main() {
|
||||
app.insert_resource(args).run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, args: Res<Args>) {
|
||||
warn!(include_str!("warning_string.txt"));
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ use bevy::{
|
||||
pbr::{ExtractedPointLight, GlobalClusterableObjectMeta},
|
||||
prelude::*,
|
||||
render::{camera::ScalingMode, Render, RenderApp, RenderSystems},
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
use rand::{thread_rng, Rng};
|
||||
@ -18,16 +18,7 @@ use rand::{thread_rng, Rng};
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
title: "many_lights".into(),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
LogVisibleLights,
|
||||
@ -36,11 +27,22 @@ fn main() {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (move_camera, print_light_count))
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.title = "many_lights".to_string();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
|
||||
@ -3,7 +3,7 @@ use argh::FromArgs;
|
||||
use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
window::{PresentMode, WindowPlugin, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
};
|
||||
use std::f32::consts::PI;
|
||||
|
||||
@ -24,25 +24,27 @@ fn main() {
|
||||
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
title: "many_materials".into(),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
.insert_resource(args)
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, animate_materials)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
window.title = "many_materials".into();
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
args: Res<Args>,
|
||||
|
||||
@ -11,7 +11,7 @@ use bevy::{
|
||||
color::palettes::css::*,
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
@ -33,20 +33,13 @@ fn main() {
|
||||
.add_plugins((
|
||||
LogDiagnosticsPlugin::default(),
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
))
|
||||
.insert_resource(WinitSettings {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -55,6 +48,15 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, assets: Res<AssetServer>, color_tint: Res<ColorTint>) {
|
||||
warn!(include_str!("warning_string.txt"));
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ use bevy::{
|
||||
prelude::*,
|
||||
render::view::NoFrustumCulling,
|
||||
text::FontAtlasSets,
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
};
|
||||
|
||||
use argh::FromArgs;
|
||||
@ -72,16 +72,10 @@ fn main() {
|
||||
app.add_plugins((
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
))
|
||||
.init_resource::<FontHandle>()
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (move_camera, print_counts));
|
||||
|
||||
@ -101,6 +95,15 @@ impl Default for PrintingTimer {
|
||||
}
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, font: Res<FontHandle>, args: Res<Args>) {
|
||||
warn!(include_str!("warning_string.txt"));
|
||||
|
||||
|
||||
@ -7,22 +7,14 @@ use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
text::{LineBreak, TextBounds},
|
||||
window::{PresentMode, WindowResolution},
|
||||
window::{PresentMode, PrimaryWindow, WindowResolution},
|
||||
winit::{UpdateMode, WinitSettings},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
resolution: WindowResolution::new(1920.0, 1080.0)
|
||||
.with_scale_factor_override(1.0),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
@ -30,11 +22,21 @@ fn main() {
|
||||
focused_mode: UpdateMode::Continuous,
|
||||
unfocused_mode: UpdateMode::Continuous,
|
||||
})
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, spawn)
|
||||
.add_systems(Update, update_text_bounds)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.resolution = WindowResolution::new(1920.0, 1080.0).with_scale_factor_override(1.0);
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn spawn(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
warn!(include_str!("warning_string.txt"));
|
||||
|
||||
|
||||
@ -7,26 +7,23 @@ use bevy::{
|
||||
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
ui::widget::TextUiWriter,
|
||||
window::PresentMode,
|
||||
window::{PresentMode, PrimaryWindow},
|
||||
};
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
))
|
||||
.add_plugins((DefaultPlugins, FrameTimeDiagnosticsPlugin::default()))
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, infotext_system)
|
||||
.add_systems(Update, change_text_system)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut PresentMode>) {
|
||||
let mut present_mode = window.get_mut(trigger.target()).unwrap();
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct TextChanges;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
use bevy::{
|
||||
prelude::*,
|
||||
window::{PresentMode, RequestRedraw, WindowPlugin},
|
||||
window::{PresentMode, PrimaryWindow, RequestRedraw},
|
||||
winit::{EventLoopProxyWrapper, WakeUp, WinitSettings},
|
||||
};
|
||||
use core::time::Duration;
|
||||
@ -22,14 +22,8 @@ fn main() {
|
||||
unfocused_mode: bevy::winit::UpdateMode::reactive_low_power(Duration::from_millis(10)),
|
||||
})
|
||||
.insert_resource(ExampleMode::Game)
|
||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
// Turn off vsync to maximize CPU/GPU usage
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}))
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, test_setup::setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -43,6 +37,12 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(trigger: On<Add, PrimaryWindow>, mut window: Query<&mut PresentMode>) {
|
||||
let mut present_mode = window.get_mut(trigger.target()).unwrap();
|
||||
// Turn off vsync to maximize CPU/GPU usage
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug)]
|
||||
enum ExampleMode {
|
||||
Game,
|
||||
|
||||
@ -7,7 +7,8 @@ use bevy::{
|
||||
diagnostic::{FrameCount, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
prelude::*,
|
||||
window::{
|
||||
CursorGrabMode, CursorOptions, PresentMode, SystemCursorIcon, WindowLevel, WindowTheme,
|
||||
CursorGrabMode, CursorOptions, PresentMode, PrimaryWindow, SystemCursorIcon, WindowLevel,
|
||||
WindowTheme,
|
||||
},
|
||||
winit::cursor::CursorIcon,
|
||||
};
|
||||
@ -15,32 +16,11 @@ use bevy::{
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "I am a window!".into(),
|
||||
name: Some("bevy.app".into()),
|
||||
resolution: (500., 300.).into(),
|
||||
present_mode: PresentMode::AutoVsync,
|
||||
// Tells Wasm to resize the window according to the available canvas
|
||||
fit_canvas_to_parent: true,
|
||||
// Tells Wasm not to override default event handling, like F5, Ctrl+R etc.
|
||||
prevent_default_event_handling: false,
|
||||
window_theme: Some(WindowTheme::Dark),
|
||||
enabled_buttons: bevy::window::EnabledButtons {
|
||||
maximize: false,
|
||||
..Default::default()
|
||||
},
|
||||
// This will spawn an invisible window
|
||||
// The window will be made visible in the make_visible() system after 3 frames.
|
||||
// This is useful when you want to avoid the white window that shows up before the GPU is ready to render the app.
|
||||
visible: false,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
DefaultPlugins,
|
||||
LogDiagnosticsPlugin::default(),
|
||||
FrameTimeDiagnosticsPlugin::default(),
|
||||
))
|
||||
.add_observer(configure_window)
|
||||
.add_systems(Startup, init_cursor_icons)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -58,6 +38,28 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
fn configure_window(
|
||||
trigger: On<Add, PrimaryWindow>,
|
||||
mut window: Query<(&mut Window, &mut PresentMode)>,
|
||||
) {
|
||||
let (mut window, mut present_mode) = window.get_mut(trigger.target()).unwrap();
|
||||
window.title = "I am a window!".into();
|
||||
window.name = Some("bevy.app".into());
|
||||
window.resolution = (500., 300.).into();
|
||||
// Tells Wasm to resize the window according to the available canvas
|
||||
window.fit_canvas_to_parent = true;
|
||||
// Tells Wasm not to override default event handling, like F5, Ctrl+R etc.
|
||||
window.prevent_default_event_handling = false;
|
||||
window.window_theme = Some(WindowTheme::Dark);
|
||||
window.enabled_buttons.maximize = false;
|
||||
// This will spawn an invisible window
|
||||
// The window will be made visible in the make_visible() system after 3 frames.
|
||||
// This is useful when you want to avoid the white window that shows up before the GPU is ready to render the app.
|
||||
window.visible = false;
|
||||
|
||||
*present_mode = PresentMode::AutoNoVsync;
|
||||
}
|
||||
|
||||
fn make_visible(mut window: Single<&mut Window>, frames: Res<FrameCount>) {
|
||||
// The delay may be different for your app or system.
|
||||
if frames.0 == 3 {
|
||||
@ -70,14 +72,14 @@ fn make_visible(mut window: Single<&mut Window>, frames: Res<FrameCount>) {
|
||||
|
||||
/// This system toggles the vsync mode when pressing the button V.
|
||||
/// You'll see fps increase displayed in the console.
|
||||
fn toggle_vsync(input: Res<ButtonInput<KeyCode>>, mut window: Single<&mut Window>) {
|
||||
fn toggle_vsync(input: Res<ButtonInput<KeyCode>>, mut present_mode: Single<&mut PresentMode>) {
|
||||
if input.just_pressed(KeyCode::KeyV) {
|
||||
window.present_mode = if matches!(window.present_mode, PresentMode::AutoVsync) {
|
||||
**present_mode = if matches!(**present_mode, PresentMode::AutoVsync) {
|
||||
PresentMode::AutoNoVsync
|
||||
} else {
|
||||
PresentMode::AutoVsync
|
||||
};
|
||||
info!("PRESENT_MODE: {:?}", window.present_mode);
|
||||
info!("PRESENT_MODE: {:?}", *present_mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user