When you attempt to render a texture with the canvas.copy_ex_f() function where both flip_{horizontal/vertical} are true, an invalid enum variant of SDL_RenderFlip is created via a transmute, which causes a panic. The message being:
thread 'main' (12499107) panicked at user/.cargo/registry/src/index.crates.io-*/sdl2-0.38.0/src/sdl2/render.rs:1646:33:
trying to construct an enum from an invalid value 0x3
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This is this panic-causing operation located in line 1640 of src/sdl2.render.rs:
use crate::sys::SDL_RendererFlip::*;
let flip: sys::SDL_RendererFlip = unsafe {
match (flip_horizontal, flip_vertical) {
(false, false) => SDL_FLIP_NONE,
(true, false) => SDL_FLIP_HORIZONTAL,
(false, true) => SDL_FLIP_VERTICAL,
(true, true) => transmute::<u32, sys::SDL_RendererFlip>(
transmute::<sys::SDL_RendererFlip, u32>(SDL_FLIP_HORIZONTAL)
| transmute::<sys::SDL_RendererFlip, u32>(SDL_FLIP_VERTICAL),
),
}
};
When you attempt to render a texture with the
canvas.copy_ex_f()function where bothflip_{horizontal/vertical}aretrue, an invalid enum variant ofSDL_RenderFlipis created via a transmute, which causes a panic. The message being:This is this panic-causing operation located in
line 1640ofsrc/sdl2.render.rs: