bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
34.24k stars 3.35k forks source link

Expose common window resolutions #14153

Open janhohenheim opened 2 weeks ago

janhohenheim commented 2 weeks ago

What problem does this solve or what need does it fill?

Users often need to set specific window resolutions. For example, a player will probably want a dropdown menu for a 3D game to tweak the resolution. A game designer might want to use a specific resolution for stylistic reasons. This is also relevant for 2D camera setups, see this chapter of the cheatbook. As a result, lots of Bevy users will need to define their own resolution constants, resulting in unnecessary boilerplate.

What solution would you like?

Add resolution constants somewhere. My suggestion is adding constructors to WindowResolution like this:

let lowres = WindowResolution::from_360p();
let highres = WindowResolution::from_2k();
// etc.

But other options like associated constants would also work

What alternative(s) have you considered?

Leave it as is. Users can copy-paste their own resolution constants or create a third-party crate.

Additional context

We don't need to add all resolutions, that would be way too much. But something like the 10 most common ones should be feasible.

This issue was originally raised by @Sapein on Discord

alice-i-cecile commented 2 weeks ago

I think an enum here is actually probably ideal, with an iterable list and then an Into UVec2.

janhohenheim commented 2 weeks ago

@alice-i-cecile that's a pretty good idea. I like that better 👍