1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
mod application;
pub mod animation;
pub mod assets;
mod camera;
pub mod ecs;
mod frame;
pub mod input;
pub mod renderer;
mod scheduler;
mod world;
pub use application::{ Application, Service };
pub mod components {
pub use crate::{
animation::Animator,
renderer::{
Light,
Model,
SkyBox,
},
};
}
pub mod services {
pub use crate::{
assets::Assets,
camera::Camera,
input::Input,
frame::Frame,
renderer::Renderer,
world::World,
};
}
pub mod systems {
pub use crate::{
renderer::{
world_renderer,
},
renderer::overlay_update,
animation::skeletal_animation,
camera::camera_control,
};
}
use ecs::System;
pub struct Dotrix {
app: Option<Application>,
}
#[derive(Default)]
pub struct Display {
pub clear_color: [f64; 4],
pub fullscreen: bool,
}
impl Dotrix {
pub fn application(name: &'static str) -> Self {
Self {
app: Some(Application::new(name)),
}
}
pub fn with_display(&mut self, display: Display) -> &mut Self {
let app = self.app.as_mut().unwrap();
app.set_display(display.clear_color, display.fullscreen);
self
}
pub fn with_system(&mut self, system: System) -> &mut Self {
self.app.as_mut().unwrap().add_system(system);
self
}
pub fn with_service<T: Service>(&mut self, service: T) -> &mut Self
{
self.app.as_mut().unwrap().add_service(service);
self
}
pub fn run(&mut self) {
let app = self.app.take().unwrap();
app.run();
}
}
#[macro_export]
macro_rules! count {
() => (0usize);
( $x:tt, $($xs:tt)* ) => (1usize + count!($($xs)*));
}
#[macro_export]
macro_rules! recursive {
($macro: ident, $args: ident) => {
$macro!{$args}
};
($macro: ident, $first: ident, $($rest: ident),*) => {
$macro!{$first, $($rest),*}
recursive!{$macro, $($rest),*}
};
}