Draw Rate Addition and Update Event Cleanup#1289
Merged
Cleptomania merged 8 commits intodevelopmentfrom Aug 2, 2022
Merged
Conversation
Member
Author
|
We are no longer removing the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Throughout Arcade 2.6, it has been not possible to increase the frequency of dispatching the
on_drawfunction from a target of 60 FPS. This is because of a change in Pyglet 2.0 from the legacy versions. Previously in Pyglet, theon_drawevent was dispatched whenever any other event was. In Pyglet 2.0 this behavior changed such that it is dispatched at a set interval using the clock, like we do for theon_updateevent. The rate for this dispatch is set as an argument to thepyglet.app.run()function, and defaults to1 / 60.The first thing this PR does is add the ability to set a
draw_rateparameter in the Window's constructor, and that value will then be passed down topyglet.app.run(). This alone doesn't make any breaking change, the value defaults to1 / 60like it always has, you now just have the ability to set it. Theupdate_rateparameter has also been changed to no longer be able to be None. If it is None an error will be introduced. There is almost certainly no usage of making this value None, but it was technically possible before. You don't actually have to set this, it will default to 1 / 60 same as before, it just can't be explicitly set to None anymore.The next thing in this PR is the removal of the
updateevent. This has been discussed many times previously, but with a shift to more things being able to separately control draw rate vs update rate, it is more important that we stress the available of thedelta_timevalue that you get with theon_updatefunction. This has been the sort of soft recommended one for quite some time, but with this the oldupdatefunction is explicitly removed and you are forced to use the neweron_updateone. This applies to the Window, View, and Section classes.Another thing here is the removal of the
arcade.run()function. There has existed aWindow.run()method for some time now, which has just been an alias to the mainarcade.run(). This PR removes the direct call, and you now have to call it as a method on the Window class. This mostly just serves to unify the API around the object-oriented approach and using less static functions, and makes therun()function not be dependent on a singleton global Window value since therun()function now needs to know thedraw_ratevalue from the Window. There are other solutions to this that don't introduce a breaking change, but with already removing theupdatefunction, this is a fairly light change that will introduce at most a one line change for any applications and create a more unified API so it is probably worth it.Task Breakdown
updateevents from Window, View, and Section classesupdateevent