use crate::ecs::world::World;

#[cfg(feature = "egui")]
pub type UiOutput = egui::FullOutput;
#[cfg(not(feature = "egui"))]
pub type UiOutput = ();

#[cfg(feature = "egui")]
pub type UiPrimitives = Vec<egui::ClippedPrimitive>;
#[cfg(not(feature = "egui"))]
pub type UiPrimitives = ();

pub trait Render {
    fn render_frame(
        &mut self,
        _world: &mut World,
        ui_output: Option<UiOutput>,
        ui_primitives: Option<UiPrimitives>,
    ) -> Result<(), Box<dyn std::error::Error>>;

    fn resize_surface(&mut self, width: u32, height: u32)
    -> Result<(), Box<dyn std::error::Error>>;

    fn surface_size(&self) -> (u32, u32);

    fn configure_with_state(
        &mut self,
        _state: &mut dyn crate::run::State,
    ) -> Result<(), Box<dyn std::error::Error>> {
        Ok(())
    }

    fn update_with_state(
        &mut self,
        _state: &mut dyn crate::run::State,
        _world: &mut World,
    ) -> Result<(), Box<dyn std::error::Error>> {
        Ok(())
    }

    fn initialize_fonts(&mut self, _world: &mut World) {}
}
