From 7646c2d6def8f201dd0d2554a0aebdd295f69d09 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Tue, 12 May 2020 10:12:48 +0200 Subject: [PATCH] sdl2: Clear Sdl2Video canvas before drawing onto it Resizing the window could leave artifacts from the previous frame on the canvas that is not overwritten by the self.canvas.copy(...) call. Former-commit-id: c5479c3e9346a25f2d5e7a7f7b8198a71d16e16a Former-commit-id: a2cc07de426ed1eca5437e30f4a15278065d856c --- platform/rustboyadvance-sdl2/src/video.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/rustboyadvance-sdl2/src/video.rs b/platform/rustboyadvance-sdl2/src/video.rs index f901e17..91370bd 100644 --- a/platform/rustboyadvance-sdl2/src/video.rs +++ b/platform/rustboyadvance-sdl2/src/video.rs @@ -1,4 +1,4 @@ -use sdl2::pixels::PixelFormatEnum; +use sdl2::pixels::{Color, PixelFormatEnum}; use sdl2::rect::Rect; use sdl2::render::{Texture, TextureCreator, WindowCanvas}; use sdl2::video::WindowContext; @@ -30,6 +30,8 @@ impl<'a> VideoInterface for Sdl2Video<'a> { (SCREEN_WIDTH as usize) * 4, ) .unwrap(); + self.canvas.set_draw_color(Color::RGB(0, 0, 0)); + self.canvas.clear(); self.canvas .copy( &self.texture,