get rid of sdl2surf_comp_id, we can just use TypeId

This commit is contained in:
lifning 2021-10-17 22:09:12 -07:00
parent 7af0f4a3f1
commit f53aef4f67
1 changed files with 2 additions and 4 deletions

View File

@ -45,7 +45,6 @@ struct Zretro {
rng: Xoshiro128Plus,
ui_bg: Option<Surface<'static>>,
snowflakes: Vec<Rect>,
sdl2surf_comp_id: RetroComponentId,
}
const FONT_PNG: &'static [u8] = include_bytes!("lifont.png");
@ -71,7 +70,7 @@ impl Zretro {
let canvas = window.into_canvas().build()?;
let sdl2surf_comp = Sdl2SurfaceComponent::new(emu.libretro_core())?;
let sdl2surf_comp_id = emu.register_component(sdl2surf_comp)?;
emu.register_component(sdl2surf_comp)?;
let sdl2_audio = SimpleSdl2AudioComponent::new(&mut sdl_context, emu.libretro_core());
emu.register_component(sdl2_audio)?;
@ -115,7 +114,6 @@ impl Zretro {
rng,
ui_bg: Some(ui_bg),
snowflakes,
sdl2surf_comp_id,
})
}
@ -144,7 +142,7 @@ impl Zretro {
font_rect.set_height(64);
while let ControlFlow::Continue = self.emu.run() {
self.update_snow()?;
let surfcomp = self.emu.component_ref::<Sdl2SurfaceComponent>(self.sdl2surf_comp_id)?;
let surfcomp: &Sdl2SurfaceComponent = self.emu.component_ref()?;
let surface = surfcomp.surface();
let emu_tx = tc.create_texture_from_surface(surface)?;