Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

feat: implemented swap chain recreation #103#130

Closed
jirislav wants to merge 1 commit intoEmbarkStudios:mainfrom
jirislav:issue-103
Closed

feat: implemented swap chain recreation #103#130
jirislav wants to merge 1 commit intoEmbarkStudios:mainfrom
jirislav:issue-103

Conversation

@jirislav
Copy link
Copy Markdown

As requested in #103

@expenses
Copy link
Copy Markdown
Contributor

Here's a fix for what you encountered in #103 (comment):

diff --git a/examples/example-runner/src/main.rs b/examples/example-runner/src/main.rs
index 7ca6bc1..99f4858 100644
--- a/examples/example-runner/src/main.rs
+++ b/examples/example-runner/src/main.rs
@@ -200,8 +200,8 @@ pub struct ExampleBase {
 }

 impl ExampleBase {
-    pub fn render_loop<T, F: Fn(&Self) + 'static>(
-        self,
+    pub fn render_loop<T, F: Fn(&mut Self) + 'static>(
+        mut self,
         events_loop: winit::event_loop::EventLoop<T>,
         f: F,
     ) -> ! {
@@ -209,7 +209,7 @@ impl ExampleBase {
         use winit::event_loop::*;
         events_loop.run(move |event, _window_target, control_flow| match event {
             Event::RedrawEventsCleared { .. } => {
-                f(&self);
+                f(&mut self);
             }
             Event::WindowEvent { event, .. } => match event {
                 WindowEvent::KeyboardInput { input, .. } => {

@jirislav jirislav force-pushed the issue-103 branch 2 times, most recently from 4ced217 to 9bfa4c2 Compare October 24, 2020 19:41
@jirislav
Copy link
Copy Markdown
Author

Here's a fix for what you encountered in #103 (comment):

diff --git a/examples/example-runner/src/main.rs b/examples/example-runner/src/main.rs
index 7ca6bc1..99f4858 100644
--- a/examples/example-runner/src/main.rs
+++ b/examples/example-runner/src/main.rs
@@ -200,8 +200,8 @@ pub struct ExampleBase {
 }

 impl ExampleBase {
-    pub fn render_loop<T, F: Fn(&Self) + 'static>(
-        self,
+    pub fn render_loop<T, F: Fn(&mut Self) + 'static>(
+        mut self,
         events_loop: winit::event_loop::EventLoop<T>,
         f: F,
     ) -> ! {
@@ -209,7 +209,7 @@ impl ExampleBase {
         use winit::event_loop::*;
         events_loop.run(move |event, _window_target, control_flow| match event {
             Event::RedrawEventsCleared { .. } => {
-                f(&self);
+                f(&mut self);
             }
             Event::WindowEvent { event, .. } => match event {
                 WindowEvent::KeyboardInput { input, .. } => {

thank you, I didn't think about the callback definition, that solves my problem :)

And to my surprise, the rest of code actually handles the ERROR_OUT_OF_DATE_KHR panic, the window doesn't crash on a resize event anymore (maximize / unmaximize / minize using the window buttons).

But I see there is another bug, when I drag the window border to apply a manual resize (or double click the window title), I get error Failed to unfocus input context: XError { description: "BadDrawable (invalid Pixmap or Window parameter)", error_code: 9, request_code: 149, minor_code: 4 }.

@jirislav jirislav marked this pull request as ready for review October 24, 2020 19:41
@jirislav jirislav force-pushed the issue-103 branch 2 times, most recently from 4664f76 to 33bb375 Compare October 25, 2020 20:57
@XAMPPRocky
Copy link
Copy Markdown
Member

@jirislav Thank you for your PR! I think you need to rebase your changes with the latest main to get CI to pass.

@XAMPPRocky XAMPPRocky added the s: waiting on review PRs that blocked on a team member's review. label Oct 30, 2020
@khyperia
Copy link
Copy Markdown
Contributor

Also just a warning that if #109 merges first, this will presumably have lots of conflicts

@jirislav
Copy link
Copy Markdown
Author

Also just a warning that if #109 merges first, this will presumably have lots of conflicts

Thanks for the heads up. I think I'm going to wait for it to merge and then redo my work on wgpu sample 🙂

@fu5ha fu5ha added s: waiting on author PRs that blocked on the author implementing feedback. and removed s: waiting on review PRs that blocked on a team member's review. labels Oct 30, 2020
@fu5ha fu5ha self-assigned this Oct 30, 2020
@fu5ha
Copy link
Copy Markdown
Member

fu5ha commented Oct 30, 2020

@jirislav #109 is in, I'll be happy to review and merge this when you get a chance to rebase or rewrite it on top of that :)

@khyperia
Copy link
Copy Markdown
Contributor

I believe this has been done by #299, but thanks for your work here!

@khyperia khyperia closed this Jan 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

s: waiting on author PRs that blocked on the author implementing feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants