2023-01-19 16:28:07 -06:00
|
|
|
use shipyard::{World, Workload, IntoWorkload, View, UniqueView, NonSendSync};
|
|
|
|
use glium::{
|
|
|
|
Surface,
|
|
|
|
glutin::{
|
|
|
|
event_loop::{EventLoop, ControlFlow},
|
|
|
|
event::{Event, WindowEvent}
|
|
|
|
}
|
|
|
|
};
|
2023-01-19 14:27:34 -06:00
|
|
|
|
2023-01-19 14:58:49 -06:00
|
|
|
mod logging;
|
2023-01-19 16:28:07 -06:00
|
|
|
mod rendering;
|
|
|
|
|
|
|
|
use rendering::{Rederer, RenderTarget};
|
|
|
|
|
|
|
|
fn render() -> Workload {
|
|
|
|
(||()).into_workload()
|
|
|
|
}
|
|
|
|
fn update() -> Workload {
|
|
|
|
(||()).into_workload()
|
|
|
|
}
|
2023-01-19 14:58:49 -06:00
|
|
|
|
2023-01-14 13:08:14 -06:00
|
|
|
fn main() {
|
2023-01-19 14:58:49 -06:00
|
|
|
logging::init();
|
|
|
|
|
2023-01-19 16:28:07 -06:00
|
|
|
//Create event loop
|
2023-01-19 14:58:49 -06:00
|
|
|
let event_loop = EventLoop::new();
|
2023-01-19 16:28:07 -06:00
|
|
|
|
|
|
|
//Create a shipyard world
|
|
|
|
let world = World::new();
|
|
|
|
|
|
|
|
//Add systems and uniques
|
|
|
|
world.add_unique_non_send_sync(
|
|
|
|
Rederer::init(&event_loop)
|
|
|
|
);
|
|
|
|
world.add_workload(update);
|
|
|
|
world.add_workload(render);
|
|
|
|
|
|
|
|
//Run the event loop
|
2023-01-19 14:58:49 -06:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2023-01-19 16:28:07 -06:00
|
|
|
*control_flow = ControlFlow::Poll;
|
|
|
|
match event {
|
|
|
|
Event::WindowEvent { event, .. } => match event {
|
|
|
|
WindowEvent::CloseRequested => {
|
|
|
|
*control_flow = ControlFlow::Exit;
|
|
|
|
},
|
|
|
|
_ => (),
|
|
|
|
},
|
|
|
|
Event::MainEventsCleared => {
|
|
|
|
world.run_workload(update).unwrap();
|
|
|
|
let mut target = {
|
|
|
|
let renderer = world.borrow::<NonSendSync<UniqueView<Rederer>>>().unwrap();
|
|
|
|
renderer.display.draw()
|
|
|
|
};
|
|
|
|
target.clear_color_and_depth((0., 0., 0., 1.), 1.);
|
|
|
|
world.add_unique_non_send_sync(RenderTarget(target));
|
|
|
|
world.run_workload(render).unwrap();
|
|
|
|
let target = world.remove_unique::<RenderTarget>().unwrap();
|
|
|
|
target.0.finish().unwrap();
|
|
|
|
},
|
|
|
|
_ => (),
|
|
|
|
};
|
2023-01-19 14:58:49 -06:00
|
|
|
});
|
2023-01-14 13:08:14 -06:00
|
|
|
}
|