mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
4.1 KiB
4.1 KiB
In this file will be listed the changes, especially the breaking ones that one should be careful of when upgrading from a version of rust-sdl2 to another.
v0.31
- Support Audio Capture in AudioCallbacks.
- Breaking change Make get_swap_interval return an enum instead of i32
- The signature of set_swap_interval has been changed as well, but it shouldn't breaking exisitng code too much.
- Adds the
unsafe_texturesfeature to this crate, allowing to get rid of the lifetimes inTextures in therendermodule.
v0.30
Re-exported sdl2_sys as sdl2::sys
The path of soundness isn't an easy one; sometimes ease of use has to be sacrificed for soundness and safety! This change is a breaking change, and a huge one at that.
You will probably have to refactor some parts of your code, but this is the price to pay for soundness and runtime safety.
Breaking Changes:
Rendererhas been renamed and split intoCanvasandTextureCreator.Canvascan store aSurfaceor aWindow, and can be used to render into these as well.TextureCreatorcreatesTextures and is used by Texture to make sure they don't live longer than expected.set_render_targethas been removed and has been replaced withCanvas::with_texture_canvasandCanvas::with_multiple_texture_canvas- Deleted
WindowRef, it wasn't useful anymore.
Other Changes:
- Added
PixelFormatEnum::supports_alpha(&self) -> boolmethod. - A single Game Of Life example has been added to show the basic capabilities of the new
CanvasandTextureCreatorstructs, as well as adding a very basic game to show how to handle input / game changes in a basic game.
You won't have to worry about what target your Renderer has at runtime anymore, everything
is done at compile time now !
- Changed signature of
Surface::fill_rects(old | new) - Changed various
Option<T>parameters intoInto<Option<T>>parameters. For instance, it is now possible to do this:
surface.blit(None,Rect::new(5,5,5,5)); // instead of surface.blit(None,Some(Rect::new(5,5,5,5)));
- Added hint-specific functions to
sdl2::hint
sdl2::hint::set_video_minimize_on_focus_lost(bool) -> bool;
sdl2::hint::set_video_minimize_on_focus_lost_with_priority(bool, sdl2::hint::Hint) -> bool;
sdl2::hint::get_video_minimize_on_focus_lost() -> bool;
- Breaking Change: Changed Color to be a struct rather than an enum.
- Takes less space, easier to use, old constructors are still available.
- Matching is no longer necessary to read the component values.
- Struct rather than variant construction is required in static initializers.
let color = Color { r: 255, g: 0, b: 0, a: 255 };
let color = Color::RGBA(255, 0, 0, 255);
let color = Color::RGB(255, 0, 0);
let (r, g, b) = color.rgb();
let (r, g, b, a) = color.rgba();
- VideoSystem::display_name now returns a
Result<String, String>instead of aString. - This prevents a segfault when the requested display index is out of bounds
window.surface()has been changed and is now more intuitive to use.- The example in
examples/no-renderer.rsshows how to use this feature.
- Deprecated
Rect::contains, addedRect::contains_pointandRect::contains_rect.containsandcontains_pointare close but different ! See here