-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Add PossiblyCurrentContext::make_not_current_as_possibly_current #1705
Add PossiblyCurrentContext::make_not_current_as_possibly_current #1705
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like in_place
is a bit better, since it's just shorter...
Other than that should be good.
Allow making the context not current by reference.
1497b4f
to
6701890
Compare
I rebased to redo the commit message after the name-change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely forgot, could you change the src/lib.rs
in examples to also use this function and not Option
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though, it has reasons to use Option
since it's needed during drop, so maybe it's fine as is.
Up to you, but I won't block on it, since it won't save much, just by looking more into it.
I think the example code can be reworked to match the diagram I sketched in #1704. There are a number of If you are curious what I mean, I'm happy to take a shot at improving the example code and make a proposal. For this PR however, I think this is good enough. The proposal would look something like this (taken from the engine I'm working on): #[derive(Default)]
enum EngineState<TGame, TRenderContext: craft_engine_core::RenderContext> {
#[default]
Uninitialized,
Initialized {
game: TGame,
render_context: TRenderContext,
window: winit::window::Window,
},
Suspended {
game: TGame,
render_context: TRenderContext::Suspended,
},
Exited,
} Except that there would not be a generic game state or render context, and the render context can be inlined. |
Nah, the only issue is because we need to drop the context from inside the resume without moving it out, which is not possible, since it's all RAII... Like the example is already quite complex, so I'd probably won't add anthying more to it. |
Fixes #1704
Allow making the context not current by reference.
CHANGELOG.md
if knowledge of this change could be valuable to users