-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Change RawHandleWrapper so that we can create it #15380
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
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
I'm pretty sure the |
It's needed to drop the window at the correct time. See this comment on window wrapper. https://docs.rs/bevy/latest/bevy/window/struct.WindowWrapper.html |
Hello, I came up with this wrapper.
This is very much by design. If you want a mutable reference to the inner window, you're gonna need to use a Mutex (or similar). I know it's ugly. Sorry. |
And how exactly would I do that? |
Closing this out, but do continue discussing workarounds and alternatives: this is something that would be nice to ensure is possible. |
@Jakkestt Hmm, you're right, it's not as straightforward as I thought. The thing is that winit makes all this very easy for us. On top of their |
Objective
The winit windowing backend does not require a mutable reference to the window to be able to change it. For example you can set the window fullscreen or change the title without needing a mutable reference. The same cannot be said for other windowing backends like glfw. This becomes a problem when, to create a WindowWrapper, you need to give it ownership of the window. And you need a WindowWrapper to create a RawHandleWrapper which you need to render things to the window. There doesn't seem to be any reason to give ownership of the window to the WindowWrapper, but in doing so, there is no easy way of getting a mutable reference to the window anymore.
Solution
The solution that I came to was to remove _window field from the RawHandleWrapper so that I could construct a RawHandleWrapper without needing to give ownership of the window itself. I don't know what the _window field did, but removing it didn't seem to do anything.
Testing
I ran a window_resizing example and 2d_shapes example and they both ran well enough. I didn't really change much and I think that any errors should have been caught when building the engine.