piston v0.33.0 Release Notes

Release Date: 2017-08-28 // over 4 years ago
  • ๐Ÿš€ A new version of the Piston core is released and the ecosystem has been updated.

    โšก๏ธ It is strongly recommended to use event traits to handle events. Use E: GenericEvent in generic code. When following this pattern this update will simply require a version bump in "Cargo.toml".

    ๐Ÿš€ This release includes the following improvements:

    ๐Ÿ‘ Better lazy event loop

    ๐Ÿ“ฑ In some application modes that do not require animations, one can save CPU cycles by setting EventSettings::lazy to true. The event loop logic has been changed to a version that behaves better under heavy rendering loads. Instead of rendering on each input event, the event loop now waits for the first event and then polls the event queue empty before rendering. This makes applications more responsive.

    ๐ŸŽ The lazy event loop now also got support for benchmark mode. Since most benchmarks are measuring render + updates it is still recommended to disable EventSettings::lazy when measuring game engine performance. An alternative is to use a frame counter.

    ๐Ÿ†• New button event

    โšก๏ธ You can now read scancodes from the window backend using ButtonEvent. This gives you a ButtonArgs struct similar to render and update events. Scancodes are stored inside ButtonArgs to preserve equality checks for the Button enum.

    ๐Ÿš€ The PressEvent and ReleaseEvent traits try to preserve the scancode when transforming an event. This makes it possible to write controllers for custom keyboard layouts, e.g. for testing globalization features. If you do not want this behavior, use the ButtonEvent trait when transforming the event.

    ๐Ÿ”จ Refactoring

    ๐Ÿšš Two new enums has been added: Loop and Event. Some variants was moved from Input to Loop. The design is as following:

    pub enum Loop { Render(RenderArgs), AfterRender(AfterRenderArgs), Update(UpdateArgs), Idle(IdleArgs), }pub enum Event { Input(Input), Loop(Loop), Custom(EventId, Arc\<Any + Send + Sync\>), }

    ๐Ÿ‘ This solves a design conflict to support custom events while cleanly separating Input. The GenericEvent trait is now only implemented for Event. To convert to Input one can write:

    if let Some(input) = e.into() { call\_some\_input\_function(input); }

    โšก๏ธ To support custom events in a generic library, use a generic parameter E: GenericEvent. This allows custom window backends and event transformers to e.g. add hardware or network events and change application code without updating libraries.

    Serde integration

    ๐Ÿ—„ With the deprecation of rustc-serialize, the Piston core is now using serde. Serialization is supported for Input and Loop, but not for Event since custom events are not serializable. Use conversion traits when storing and loading events, for example when replaying user input.

Previous changes from v0.23.0

  • ๐Ÿš€ This release adds some new functionality to AdvancedWindow to hide, show and change position of windows. A minor change was made to the BuildFromWindowSettings trait to make it easier to reuse window settings when creating a new window.

    ๐Ÿš€ For release notes, see #1092