-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Bevy version
Reproducible on 0.14.2, 0.15.0-rc1, and main.
[Optional] Relevant system information
Rust: 1.82.0
OS: Nobara Linux 40
`AdapterInfo { name: "NVIDIA GeForce RTX 2070 SUPER", vendor: 4318, device: 7812, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "560.35.03", backend: Vulkan }`I have tested on upstream wgpu and experiences no rendering issues.
What you did
I created a simple project with only the most recent release of bevy as the dependency. I setup the project as needed for what I am trying to accomplish. That being getting a sprite to render to the screen, be able to move around the screen using the middle mouse button, and then use the scroll wheel to be able to zoom in/out.
Upon running the project, I received the following output:
What went wrong
Sometimes, it seems like the sprite doesn't render, and other times, the sprite renders, but the systems seem not to function as expected, seeming to do nothing. Various println have confirmed that the systems are in fact running, and handle proper mouse input, but seem to have no effect. This usually required me to run the app a few times before both the sprite renders and the systems function. Furthermore, even if the mouse systems section is removed, the issue with the sprite randomly not rendering still persists.
- what were you expecting?
The sprite would render and the systems would function consistently.
MRE of the project code:
use bevy::{input::{common_conditions::input_pressed, mouse::{MouseMotion, MouseWheel}}, prelude::*};
#[derive(Component)]
struct MainCamera;
fn main() {
App::new()
.add_plugins(
DefaultPlugins
.set(ImagePlugin::default_nearest())
)
.add_systems(Startup, setup)
.add_systems(Update, (
mouse_zoom,
mouse_pan.run_if(input_pressed(MouseButton::Middle))
))
.run();
}
fn setup(mut commands: Commands, server: Res<AssetServer>) {
commands.spawn((Camera2d::default(), MainCamera));
commands.spawn(Sprite{
image: server.load("placeholder.png"),
..default()
});
}
fn mouse_zoom(
mut scroll_events: EventReader<MouseWheel>,
mut query_camera: Query<&mut OrthographicProjection>
) {
let mut projection = query_camera.single_mut();
for ev in scroll_events.read() {
if ev.y > 0. {
projection.scale /= 1.25;
} else if ev.y < 0. {
projection.scale *= 1.25;
}
}
}
fn mouse_pan(
mut evr_motion: EventReader<MouseMotion>,
mut q_transform: Query<&mut Transform, With<MainCamera>>
) {
let mut transform = q_transform.single_mut();
for ev in evr_motion.read() {
transform.translation.x += ev.delta.x * -1.;
transform.translation.y += ev.delta.y;
}
}Additional information
I believe that the error that I am seeing related to EGL 'eglCreateSyncKHR' can likely be ignored as I see the same error as part of testing wgpu and didn't not experience any rendering difficulties there across multiple examples runs.
