-
Notifications
You must be signed in to change notification settings - Fork 120
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
Fixes #372: calling size() in setup() producing weird behavior #423
Conversation
Polling for events within the size() function right after the size has been changed will make glfw trigger the window resize event right then and there. This will create a new surface right after the call to size(), so that any graphics drawn from this point on in size() will be preserved.
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.
Thank you for contributing to p5py
This PR is not meant to be merged (yet). I just wanted to provide an example of what my fix would look like in code and also showcase this weird buffer change issue. |
I will test these changes, can you open an issue for the jittery behaviour? |
Yup! I'll create it tomorrow (It's a bit late now lol) |
Ah there's some tests failing cause I haven't taken vispy into account. Should be an easy enough fix |
Can you do the fix as well ? |
Add a check and call poll_events() only if the current renderer is skia.
Added a check to call However, this simply eliminates the error when vispy is used. The behavior is not fixed for vispy. It doesn't seem as trivial to me right now because you don't control when the events are processed in vispy. It always happens after every timer "tick". There might be a way to force an event poll before the next "tick" but a google search yielded no results. |
I checked this PR, but configuration in |
Thats cool! |
Thank you @procub3r, closing this PR. |
Polling for events within the size() function right after the size has been changed will make glfw trigger the window resize event right then and there.
This will create a new surface right after the call to size(), so that any graphics drawn from this point on in size() will be preserved.
Another issue still remains. The one where the buffers are not being swapped properly. Once a sketch is started, after a few seconds, the buffer being rendered to the window completely changes. After a few more seconds, the old buffer is rendered again, and this continues indefinitely.
I highly suspect that this is the same issue described by @tushar5526 here: #420 (comment)
As a result of this issue, the fix proposed in this PR will only be seen when this "buffer change" takes place. To confirm this:
background(220)
has taken effect, but in this other buffer.Demonstration:
bufferchangeglitch.mov
In the current master branch (without the fix in this PR), the
background(220)
call would not have taken effect in any buffer. I will be investigating the "buffer change" issue further.