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
This commit is contained in:
Tibor Nagy 2020-05-12 10:12:48 +02:00 committed by MishMish
parent b980c7aa7d
commit 7646c2d6de

View file

@ -1,4 +1,4 @@
use sdl2::pixels::PixelFormatEnum; use sdl2::pixels::{Color, PixelFormatEnum};
use sdl2::rect::Rect; use sdl2::rect::Rect;
use sdl2::render::{Texture, TextureCreator, WindowCanvas}; use sdl2::render::{Texture, TextureCreator, WindowCanvas};
use sdl2::video::WindowContext; use sdl2::video::WindowContext;
@ -30,6 +30,8 @@ impl<'a> VideoInterface for Sdl2Video<'a> {
(SCREEN_WIDTH as usize) * 4, (SCREEN_WIDTH as usize) * 4,
) )
.unwrap(); .unwrap();
self.canvas.set_draw_color(Color::RGB(0, 0, 0));
self.canvas.clear();
self.canvas self.canvas
.copy( .copy(
&self.texture, &self.texture,