Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Use updated window size in bevymark example #3335

Closed
wants to merge 3 commits into from

Conversation

tobenaii
Copy link
Contributor

Objective

Have the bird spawning/collision systems in bevymark use the proper window size, instead of the size set in WindowDescriptor which isn't updated when the window is resized.

Solution

Use the Windows resource to grab the width/height from the primary window. This is consistent with the other examples.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Dec 15, 2021
@mockersf mockersf added C-Examples An addition or correction to our examples and removed S-Needs-Triage This issue needs to be labelled labels Dec 15, 2021
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

My one concern with this is that bevymark is intended to be a benchmark, to test bevy's sprite performance across platforms - I'm not sure how useful having the window be resizable is for that purpose.

That being said, if we do choose to go that route, we should also lock the scale factor and make the window not resizable, which we don't do currently.

This PR is fixing another issue stemming of #2879, so may as well have the backlink from that to here.

let bird_x = (window.width / -2.) + HALF_BIRD_SIZE;
let bird_y = (window.height / 2.) - HALF_BIRD_SIZE;
let window = windows.get_primary().unwrap();
let bird_x = (window.physical_width() as f32 / -2.) + HALF_BIRD_SIZE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this physical width?

That makes the behaviour with a non-1 scale factor is to spawn the birds off-screen, and let them bounce off-screen. That doesn't seem ideal for a benchmark, as it might make the performance seem better (as off-screen sprites are planned to be culled). I think bevymark is meant to be a stress-test for sprite rendering, not culling behaviour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah my bad, it shouldn't use the physical size, I will fix it.

I agree with your concern for the usefulness of resizing, though the main issue I had here was the use of WindowDescriptor since it gave the wrong impression (to me at least) that WindowDescriptor would be updated.

@mockersf
Copy link
Member

My one concern with this is that bevymark is intended to be a benchmark, to test bevy's sprite performance across platforms - I'm not sure how useful having the window be resizable is for that purpose.

If we don't want the window to be resizable, it should set resizable to false when creating it rather than not handling the size correctly. Currently the window is resizable but birds will still bounce on the size of the window at start

@cart
Copy link
Member

cart commented Dec 18, 2021

Yup I agree that this is a positive change because it encourages people to follow best practices (accessing WindowDescriptor data at runtime is rarely a good idea). Possibly worth disabling window resizing, but im cool with merging this as is.

@cart
Copy link
Member

cart commented Dec 18, 2021

bors r+

bors bot pushed a commit that referenced this pull request Dec 18, 2021
# Objective

Have the bird spawning/collision systems in bevymark use the proper window size, instead of the size set in WindowDescriptor which isn't updated when the window is resized.

## Solution

Use the Windows resource to grab the width/height from the primary window. This is consistent with the other examples.
@bors bors bot changed the title Use updated window size in bevymark example [Merged by Bors] - Use updated window size in bevymark example Dec 18, 2021
@bors bors bot closed this Dec 18, 2021
@tobenaii tobenaii deleted the bevymark-resize branch December 18, 2021 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Examples An addition or correction to our examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants