fix dupe frames
This commit is contained in:
parent
709a23307a
commit
72366248d7
1 changed files with 10 additions and 10 deletions
|
@ -11,7 +11,6 @@ use sdl2::video::FullscreenType;
|
||||||
pub(crate) fn paint_frame_on_canvas(frame: &VideoFrame, canvas: &mut WindowCanvas) -> bool {
|
pub(crate) fn paint_frame_on_canvas(frame: &VideoFrame, canvas: &mut WindowCanvas) -> bool {
|
||||||
if let Ok(surf) = frame_to_surface(frame) {
|
if let Ok(surf) = frame_to_surface(frame) {
|
||||||
let (cw, ch) = canvas.output_size().unwrap();
|
let (cw, ch) = canvas.output_size().unwrap();
|
||||||
|
|
||||||
let should_intscale = if cw >= surf.width() && ch >= surf.height() {
|
let should_intscale = if cw >= surf.width() && ch >= surf.height() {
|
||||||
sdl2::sys::SDL_bool::SDL_TRUE
|
sdl2::sys::SDL_bool::SDL_TRUE
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,15 +19,16 @@ pub(crate) fn paint_frame_on_canvas(frame: &VideoFrame, canvas: &mut WindowCanva
|
||||||
unsafe {
|
unsafe {
|
||||||
sdl2::sys::SDL_RenderSetIntegerScale(canvas.raw(), should_intscale);
|
sdl2::sys::SDL_RenderSetIntegerScale(canvas.raw(), should_intscale);
|
||||||
}
|
}
|
||||||
|
if surf.pixel_format_enum() != PixelFormatEnum::Unknown {
|
||||||
|
let format = sdl2::pixels::PixelFormat::try_from(canvas.default_pixel_format()).unwrap();
|
||||||
|
let surface = surf.convert(&format).unwrap();
|
||||||
|
|
||||||
let format = sdl2::pixels::PixelFormat::try_from(canvas.default_pixel_format()).unwrap();
|
if let Ok(tex) = canvas
|
||||||
let surface = surf.convert(&format).unwrap();
|
.texture_creator()
|
||||||
|
.create_texture_from_surface(surface)
|
||||||
if let Ok(tex) = canvas
|
{
|
||||||
.texture_creator()
|
canvas.copy(&tex, None, None).unwrap();
|
||||||
.create_texture_from_surface(surface)
|
}
|
||||||
{
|
|
||||||
canvas.copy(&tex, None, None).unwrap();
|
|
||||||
}
|
}
|
||||||
canvas.present();
|
canvas.present();
|
||||||
true
|
true
|
||||||
|
@ -63,7 +63,7 @@ pub(crate) fn frame_to_surface<'a>(frame: &'a VideoFrame) -> crate::base::Result
|
||||||
let pixel_format = frame
|
let pixel_format = frame
|
||||||
.pixel_format()
|
.pixel_format()
|
||||||
.map(sdl2_pixfmt)
|
.map(sdl2_pixfmt)
|
||||||
.unwrap_or(PixelFormatEnum::ARGB8888);
|
.unwrap_or(PixelFormatEnum::Unknown);
|
||||||
sdl2::surface::Surface::new(width, height, pixel_format)
|
sdl2::surface::Surface::new(width, height, pixel_format)
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue