use std::ops::Range;
use legion::{Resources, World};
use scion2d::Scion2D;
use wgpu::{
util::BufferInitDescriptor, CommandEncoder, Device, Queue, SurfaceConfiguration, TextureView,
};
use crate::{config::scion_config::ScionConfig, core::components::material::Material};
pub(crate) mod gl_representations;
pub(crate) mod renderer_state;
pub(crate) mod scion2d;
pub(crate) mod shaders;
pub trait ScionRenderer {
fn start(&mut self, device: &Device, surface_config: &SurfaceConfiguration);
fn update(
&mut self,
world: &mut World,
resources: &mut Resources,
device: &Device,
surface_config: &SurfaceConfiguration,
queue: &mut Queue,
);
fn render(
&mut self,
world: &mut World,
config: &ScionConfig,
texture_view: &TextureView,
encoder: &mut CommandEncoder,
);
}
pub enum RendererType {
Scion2D,
Custom(Box<dyn ScionRenderer>),
}
impl Default for RendererType {
fn default() -> Self {
RendererType::Scion2D
}
}
impl RendererType {
pub(crate) fn into_boxed_renderer(self) -> Box<dyn ScionRenderer> {
match self {
RendererType::Scion2D => Box::new(Scion2D::default()),
RendererType::Custom(boxed) => boxed,
}
}
}
pub(crate) trait Renderable2D {
fn vertex_buffer_descriptor(&mut self, material: Option<&Material>) -> BufferInitDescriptor;
fn indexes_buffer_descriptor(&self) -> BufferInitDescriptor;
fn range(&self) -> Range<u32>;
fn topology() -> wgpu::PrimitiveTopology;
fn dirty(&self) -> bool;
fn set_dirty(&mut self, is_dirty: bool);
}
pub(crate) trait RenderableUi: Renderable2D {
fn get_texture_path(&self) -> Option<String> {
None
}
}