Implement Engine, add compile_shader to rendering systems
- Implement the initial version of the run method of the glium platform - Add asset manager to the context of the renderer. I will probably move that to either the engine or somewhere else later. - Other unimportant stuff that I'm too lazy to include here. Early stage commit messages don't really matter anyways.
This commit is contained in:
parent
e817abf8ab
commit
1cc63a0dab
7 changed files with 32 additions and 6 deletions
|
|
@ -1,14 +1,16 @@
|
|||
use std::sync::{Arc, RwLock};
|
||||
use glium::backend::Facade;
|
||||
use raidillon_platform::Platform;
|
||||
use glium::winit::event_loop::EventLoop;
|
||||
use glium::winit::window::Window;
|
||||
use glium::backend::glutin::Display;
|
||||
use glium::glutin::surface::WindowSurface;
|
||||
use glium::backend::glutin::SimpleWindowBuilder;
|
||||
use crate::system::{RenderingSystemManager, RenderingSystem};
|
||||
use glium::Surface;
|
||||
use crate::system::{RenderingSystemManager, RenderingSystem, RenderingContext};
|
||||
use winit::event::{Event, WindowEvent};
|
||||
use raidillon_core::Engine;
|
||||
use crate::GliumAssetManager;
|
||||
use crate::render::BasicRenderingSystem;
|
||||
|
||||
pub struct GliumPlatform<RS: RenderingSystem> {
|
||||
event_loop: EventLoop<()>,
|
||||
|
|
@ -29,8 +31,8 @@ impl<RS: RenderingSystem> Platform for GliumPlatform<RS> {
|
|||
.with_inner_size(width, height)
|
||||
.build(&event_loop);
|
||||
|
||||
let rendering_system_manager = RenderingSystemManager::new();
|
||||
let asset_manager = Arc::new(RwLock::new(GliumAssetManager::new(Box::new(display.clone()))));
|
||||
let rendering_system_manager = RenderingSystemManager::new();
|
||||
Self {
|
||||
event_loop,
|
||||
window,
|
||||
|
|
@ -40,17 +42,24 @@ impl<RS: RenderingSystem> Platform for GliumPlatform<RS> {
|
|||
}
|
||||
}
|
||||
|
||||
fn run(self) {
|
||||
fn run(mut self, engine: Engine) {
|
||||
let _ = &self.event_loop.run(move |event, el| {
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => {},
|
||||
WindowEvent::RedrawRequested => {
|
||||
let mut target = self.display.draw();
|
||||
target.clear_color(0.0, 0.0, 0.0, 1.0);
|
||||
// TODO: let mut context;
|
||||
|
||||
for (system_id, system) in self.rendering_system_manager.systems.iter_mut() {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
_ => {},
|
||||
},
|
||||
Event::AboutToWait => {
|
||||
// TODO: Run <engine: Engine> systems here
|
||||
self.window.request_redraw();
|
||||
}
|
||||
_ => {},
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use raidillon_core::Scene;
|
||||
use glium::Surface;
|
||||
use crate::GliumAssetManager;
|
||||
|
||||
pub struct RenderingContext<'a, S: Surface> {
|
||||
pub scene: &'a mut Scene,
|
||||
pub target: &'a mut S,
|
||||
pub asset_manager: Arc<RwLock<GliumAssetManager>>,
|
||||
}
|
||||
|
||||
/// 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>);
|
||||
fn compile_shaders() {}
|
||||
}
|
||||
|
||||
type SystemID = String;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue