Fix circular dependencies in workspace
This commit is contained in:
parent
960e2f8a37
commit
173cfe2acf
22
Cargo.lock
generated
22
Cargo.lock
generated
|
@ -1280,6 +1280,27 @@ dependencies = [
|
|||
name = "khors"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "khors-app"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"downcast-rs",
|
||||
"egui",
|
||||
"flax",
|
||||
"flume",
|
||||
"glam",
|
||||
"khors-core",
|
||||
"khors-graphics",
|
||||
"parking_lot",
|
||||
"serde",
|
||||
"serde-lexpr",
|
||||
"vulkano",
|
||||
"vulkano-shaders",
|
||||
"vulkano-util",
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "khors-config"
|
||||
version = "0.1.0"
|
||||
|
@ -1349,6 +1370,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"egui-vulkano",
|
||||
"khors-app",
|
||||
"khors-config",
|
||||
"khors-core",
|
||||
"khors-graphics",
|
||||
|
|
|
@ -9,6 +9,7 @@ edition = "2021"
|
|||
members = [
|
||||
"khors-core",
|
||||
"vendor/egui-vulkano",
|
||||
"modules/khors-app",
|
||||
"modules/khors-graphics",
|
||||
"modules/khors-window",
|
||||
"modules/khors-config",
|
||||
|
@ -18,6 +19,9 @@ members = [
|
|||
|
||||
default-members = [ "khors-test" ]
|
||||
|
||||
[workspace.dependencies]
|
||||
flax = { version = "0.6.2", features = ["derive", "serde", "tokio", "tracing"] }
|
||||
|
||||
[[bin]]
|
||||
name = "khors-test"
|
||||
path = "./khors-test"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
pub mod app;
|
||||
pub mod events;
|
||||
pub mod module;
|
||||
pub mod time;
|
||||
pub mod debug_gui;
|
||||
|
|
|
@ -5,10 +5,13 @@ use flax::World;
|
|||
|
||||
use super::events::Events;
|
||||
|
||||
use super::debug_gui::DebugGuiStack;
|
||||
|
||||
pub trait Module {
|
||||
fn on_update(&mut self, world: &mut World, events: &mut Events, frame_time: Duration) -> Result<()>;
|
||||
fn on_update(
|
||||
&mut self,
|
||||
world: &mut World,
|
||||
events: &mut Events,
|
||||
frame_time: Duration,
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
pub struct ModulesStack {
|
||||
|
@ -17,7 +20,9 @@ pub struct ModulesStack {
|
|||
|
||||
impl ModulesStack {
|
||||
pub fn new() -> Self {
|
||||
Self { modules: Vec::new() }
|
||||
Self {
|
||||
modules: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> std::slice::Iter<Box<dyn Module>> {
|
||||
|
@ -64,63 +69,3 @@ impl<'a> IntoIterator for &'a mut ModulesStack {
|
|||
self.iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
// THREAD LOCAL STUFF
|
||||
|
||||
pub trait RenderModule {
|
||||
fn on_update(&mut self, gui_stack: &mut DebugGuiStack, vk_context: &mut vulkano_util::context::VulkanoContext, vk_windows: &mut vulkano_util::window::VulkanoWindows, world: &mut World, events: &mut Events, frame_time: Duration) -> Result<()>;
|
||||
}
|
||||
|
||||
pub struct RenderModulesStack {
|
||||
modules: Vec<Box<dyn RenderModule>>,
|
||||
}
|
||||
|
||||
impl RenderModulesStack {
|
||||
pub fn new() -> Self {
|
||||
Self { modules: Vec::new() }
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> std::slice::Iter<Box<dyn RenderModule>> {
|
||||
self.modules.iter()
|
||||
}
|
||||
|
||||
pub fn iter_mut(&mut self) -> std::slice::IterMut<Box<dyn RenderModule>> {
|
||||
self.modules.iter_mut()
|
||||
}
|
||||
|
||||
pub fn push<T: 'static + RenderModule>(&mut self, layer: T) {
|
||||
let layer = Box::new(layer);
|
||||
self.modules.push(layer);
|
||||
}
|
||||
|
||||
pub fn insert<T: 'static + RenderModule>(&mut self, index: usize, layer: T) {
|
||||
let layer = Box::new(layer);
|
||||
self.modules.insert(index, layer);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RenderModulesStack {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a RenderModulesStack {
|
||||
type Item = &'a Box<dyn RenderModule>;
|
||||
|
||||
type IntoIter = std::slice::Iter<'a, Box<dyn RenderModule>>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a mut RenderModulesStack {
|
||||
type Item = &'a mut Box<dyn RenderModule>;
|
||||
|
||||
type IntoIter = std::slice::IterMut<'a, Box<dyn RenderModule>>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter_mut()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
khors-core = { path = "../khors-core", version = "0.1.0" }
|
||||
khors-app = { path = "../modules/khors-app", version = "0.1.0" }
|
||||
egui-vulkano = { path = "../vendor/egui-vulkano", version = "0.1.0" }
|
||||
khors-graphics = { path = "../modules/khors-graphics", version = "0.1.0" }
|
||||
khors-window = { path = "../modules/khors-window", version = "0.1.0" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use khors_config::ConfigModule;
|
||||
use khors_core::app::App;
|
||||
use khors_app::App;
|
||||
use khors_graphics::RenderModule;
|
||||
use khors_window::WindowModule;
|
||||
use tokio::runtime::Builder;
|
||||
|
|
24
modules/khors-app/Cargo.toml
Normal file
24
modules/khors-app/Cargo.toml
Normal file
|
@ -0,0 +1,24 @@
|
|||
[package]
|
||||
name = "khors-app"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
khors-core = { path = "../../khors-core", version = "0.1.0" }
|
||||
khors-graphics = { path = "../khors-graphics", version = "0.1.0" }
|
||||
|
||||
anyhow = "1.0.80"
|
||||
egui = "0.27.1"
|
||||
glam = "0.27.0"
|
||||
winit = { version = "0.29.15",features = ["rwh_05"] }
|
||||
vulkano = { git = "https://github.com/vulkano-rs/vulkano.git", branch = "master" }
|
||||
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano.git", branch = "master" }
|
||||
vulkano-util = { git = "https://github.com/vulkano-rs/vulkano.git", branch = "master" }
|
||||
flax = { version = "0.6.2", features = ["derive", "serde", "tokio", "tracing"] }
|
||||
flume = "0.11.0"
|
||||
parking_lot = "0.12.1"
|
||||
downcast-rs = "1.2.0"
|
||||
serde = { version = "1.0.197", features = ["derive"] }
|
||||
serde-lexpr = "0.1.3"
|
|
@ -1,10 +1,13 @@
|
|||
#![warn(dead_code)]
|
||||
|
||||
use crate::{
|
||||
debug_gui::DebugGuiStack,
|
||||
use khors_core::{
|
||||
events::Events,
|
||||
module::{Module, ModulesStack, RenderModule as ThreadLocalModule, RenderModulesStack},
|
||||
module::{Module, ModulesStack},
|
||||
};
|
||||
use khors_graphics::{
|
||||
debug_gui::DebugGuiStack,
|
||||
render_module::{RenderModule as ThreadLocalModule, RenderModulesStack},
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use flax::{component, Schedule, World};
|
||||
use vulkano::device::DeviceFeatures;
|
|
@ -1,3 +1,6 @@
|
|||
pub mod debug_gui;
|
||||
pub mod render_module;
|
||||
|
||||
use flax::{entity_ids, BoxedSystem, Query, QueryBorrow, Schedule, System, World};
|
||||
use glam::{
|
||||
f32::{Mat3, Vec3},
|
||||
|
@ -45,7 +48,8 @@ use vulkano_util::{
|
|||
};
|
||||
|
||||
use egui_vulkano::Gui;
|
||||
use khors_core::{debug_gui::DebugGuiStack, module::RenderModule as ThreadLocalModule};
|
||||
use crate::debug_gui::DebugGuiStack;
|
||||
use crate::render_module::RenderModule as ThreadLocalModule;
|
||||
|
||||
use self::{
|
||||
model::{INDICES, NORMALS, POSITIONS},
|
||||
|
|
75
modules/khors-graphics/src/render_module.rs
Normal file
75
modules/khors-graphics/src/render_module.rs
Normal file
|
@ -0,0 +1,75 @@
|
|||
use crate::debug_gui::DebugGuiStack;
|
||||
use anyhow::Result;
|
||||
use flax::World;
|
||||
use khors_core::events::Events;
|
||||
use std::time::Duration;
|
||||
|
||||
// THREAD LOCAL STUFF
|
||||
|
||||
pub trait RenderModule {
|
||||
fn on_update(
|
||||
&mut self,
|
||||
gui_stack: &mut DebugGuiStack,
|
||||
vk_context: &mut vulkano_util::context::VulkanoContext,
|
||||
vk_windows: &mut vulkano_util::window::VulkanoWindows,
|
||||
world: &mut World,
|
||||
events: &mut Events,
|
||||
frame_time: Duration,
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
pub struct RenderModulesStack {
|
||||
modules: Vec<Box<dyn RenderModule>>,
|
||||
}
|
||||
|
||||
impl RenderModulesStack {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
modules: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> std::slice::Iter<Box<dyn RenderModule>> {
|
||||
self.modules.iter()
|
||||
}
|
||||
|
||||
pub fn iter_mut(&mut self) -> std::slice::IterMut<Box<dyn RenderModule>> {
|
||||
self.modules.iter_mut()
|
||||
}
|
||||
|
||||
pub fn push<T: 'static + RenderModule>(&mut self, layer: T) {
|
||||
let layer = Box::new(layer);
|
||||
self.modules.push(layer);
|
||||
}
|
||||
|
||||
pub fn insert<T: 'static + RenderModule>(&mut self, index: usize, layer: T) {
|
||||
let layer = Box::new(layer);
|
||||
self.modules.insert(index, layer);
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for RenderModulesStack {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a RenderModulesStack {
|
||||
type Item = &'a Box<dyn RenderModule>;
|
||||
|
||||
type IntoIter = std::slice::Iter<'a, Box<dyn RenderModule>>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a mut RenderModulesStack {
|
||||
type Item = &'a mut Box<dyn RenderModule>;
|
||||
|
||||
type IntoIter = std::slice::IterMut<'a, Box<dyn RenderModule>>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter_mut()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue