Continue new platform/glium implementations
- Assets, asset manager system - Rendering system trait - Kick off glium platform implementation - And more
This commit is contained in:
parent
f7d5c14caf
commit
e817abf8ab
18 changed files with 2557 additions and 32 deletions
35
raidillon_glium/src/system.rs
Normal file
35
raidillon_glium/src/system.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use std::collections::HashMap;
|
||||
use raidillon_core::Scene;
|
||||
use glium::Surface;
|
||||
|
||||
pub struct RenderingContext<'a, S: Surface> {
|
||||
pub scene: &'a mut Scene,
|
||||
pub target: &'a mut S,
|
||||
}
|
||||
|
||||
/// The internal "rendering system" trait of raidillon_glium.
|
||||
/// This is unrelated to the main System trait in raidillon_core.
|
||||
pub trait RenderingSystem {
|
||||
fn render<S: Surface>(ctx: &mut RenderingContext<S>);
|
||||
}
|
||||
|
||||
type SystemID = String;
|
||||
|
||||
pub struct RenderingSystemManager<T: RenderingSystem> {
|
||||
pub systems: HashMap<SystemID, Box<T>>,
|
||||
}
|
||||
|
||||
impl<T: RenderingSystem> RenderingSystemManager<T> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
systems: HashMap::new(),
|
||||
}
|
||||
}
|
||||
pub fn add_system(&mut self, id: SystemID, system: T) {
|
||||
self.systems.insert(id, Box::new(system));
|
||||
}
|
||||
|
||||
pub fn remove_system(&mut self, id: SystemID) {
|
||||
self.systems.remove(&id);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue