Compare commits
1 commit
733c66ba0e
...
0c35ee6f17
Author | SHA1 | Date | |
---|---|---|---|
0c35ee6f17 |
6 changed files with 29 additions and 54 deletions
|
@ -72,7 +72,6 @@ impl Context {
|
||||||
) {
|
) {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
if !res {
|
if !res {
|
||||||
self.device().wait_idle()?;
|
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,10 +119,6 @@ impl Context {
|
||||||
pub fn controllers(&self) -> impl Iterator<Item = &Controller> {
|
pub fn controllers(&self) -> impl Iterator<Item = &Controller> {
|
||||||
self.presentation.event_system().controllers()
|
self.presentation.event_system().controllers()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn joysticks(&self) -> impl Iterator<Item = &Joystick> {
|
|
||||||
self.presentation.event_system().joysticks()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for Context {
|
impl std::fmt::Debug for Context {
|
||||||
|
|
|
@ -175,14 +175,18 @@ impl Engine {
|
||||||
let asset_manager = AssetManager::new(&engine_settings)?;
|
let asset_manager = AssetManager::new(&engine_settings)?;
|
||||||
let gui_handler = GuiHandler::new(create_info.gui_info, &context)?;
|
let gui_handler = GuiHandler::new(create_info.gui_info, &context)?;
|
||||||
|
|
||||||
|
let engine = Engine {
|
||||||
|
resource_base_path: create_info.resource_base_path,
|
||||||
|
};
|
||||||
|
|
||||||
context
|
context
|
||||||
.render_core_mut()
|
.render_core_mut()
|
||||||
.add_render_routine::<GuiHandlerRenderer>(10_000_000);
|
.add_render_routine::<GuiHandlerRenderer>(10_000_000);
|
||||||
context.render_core_mut().add_render_routine::<Scene>(100);
|
// context.render_core_mut().add_render_routine::<Scene>(100);
|
||||||
|
|
||||||
world.resources.insert(context);
|
world.resources.insert(context);
|
||||||
|
|
||||||
Scene::new(
|
let scene = Scene::new(
|
||||||
create_info.rasterizer_info,
|
create_info.rasterizer_info,
|
||||||
create_info.raytracing_info,
|
create_info.raytracing_info,
|
||||||
create_info.graphics_info,
|
create_info.graphics_info,
|
||||||
|
@ -200,10 +204,9 @@ impl Engine {
|
||||||
world.resources.insert(GuiHandlerRenderer);
|
world.resources.insert(GuiHandlerRenderer);
|
||||||
world.resources.insert(InputMap { direction_mapping });
|
world.resources.insert(InputMap { direction_mapping });
|
||||||
world.resources.insert(asset_manager);
|
world.resources.insert(asset_manager);
|
||||||
world.resources.insert(Engine {
|
world.resources.insert(engine);
|
||||||
resource_base_path: create_info.resource_base_path,
|
|
||||||
});
|
|
||||||
world.resources.insert(engine_settings);
|
world.resources.insert(engine_settings);
|
||||||
|
world.resources.insert(scene);
|
||||||
|
|
||||||
world.add_system(Self::main_system::<T>);
|
world.add_system(Self::main_system::<T>);
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,13 @@ pub enum EngineEvent<'a> {
|
||||||
KeyDown(Keycode),
|
KeyDown(Keycode),
|
||||||
KeyUp(Keycode),
|
KeyUp(Keycode),
|
||||||
|
|
||||||
ControllerButtonDown(&'a Controller, ControllerButton),
|
ButtonDown(ControllerButton),
|
||||||
ControllerButtonUp(&'a Controller, ControllerButton),
|
ButtonUp(ControllerButton),
|
||||||
ControllerAxis(&'a Controller, ControllerAxis),
|
ControllerAxis(ControllerAxis),
|
||||||
|
|
||||||
ControllerAdded(&'a Controller),
|
ControllerAdded(&'a Controller),
|
||||||
ControllerRemoved(&'a Controller),
|
ControllerRemoved(&'a Controller),
|
||||||
|
|
||||||
JoystickButtonDown(&'a Joystick),
|
|
||||||
JoystickButtonUp(&'a Joystick),
|
|
||||||
JoystickAxis(&'a Joystick),
|
|
||||||
JoystickAdded(&'a Joystick),
|
|
||||||
JoystickRemoved(&'a Joystick),
|
|
||||||
|
|
||||||
FileDrop(String),
|
FileDrop(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,11 +66,11 @@ impl Engine {
|
||||||
Event::TextInput(text) => {
|
Event::TextInput(text) => {
|
||||||
Self::text_input(gui_handler, text)?;
|
Self::text_input(gui_handler, text)?;
|
||||||
}
|
}
|
||||||
Event::ControllerButtonDown(controller, button) => {
|
Event::ControllerButtonDown(_controller, button) => {
|
||||||
Self::button_down_event(world, gui_handler, consumer, controller, button)?;
|
Self::button_down_event(world, gui_handler, consumer, button)?;
|
||||||
}
|
}
|
||||||
Event::ControllerButtonUp(controller, button) => {
|
Event::ControllerButtonUp(_controller, button) => {
|
||||||
Self::button_up_event(world, consumer, controller, button)?;
|
Self::button_up_event(world, consumer, button)?;
|
||||||
}
|
}
|
||||||
Event::ControllerAxis(controller) => {
|
Event::ControllerAxis(controller) => {
|
||||||
if !gui_handler.check_navigatable()? {
|
if !gui_handler.check_navigatable()? {
|
||||||
|
@ -91,21 +86,11 @@ impl Engine {
|
||||||
Self::controller_removed(world, consumer, controller)?
|
Self::controller_removed(world, consumer, controller)?
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::JoystickAxis(joystick) => {
|
Event::JoystickAxis(_joystick) => todo!(),
|
||||||
consumer.event(world, EngineEvent::JoystickAxis(joystick))?
|
Event::JoystickButtonDown(_joystick) => todo!(),
|
||||||
}
|
Event::JoystickButtonUp(_joystick) => todo!(),
|
||||||
Event::JoystickButtonDown(joystick) => {
|
Event::JoystickAdded(_joystick) => todo!(),
|
||||||
consumer.event(world, EngineEvent::JoystickButtonDown(joystick))?
|
Event::JoystickRemoved(_joystick) => todo!(),
|
||||||
}
|
|
||||||
Event::JoystickButtonUp(joystick) => {
|
|
||||||
consumer.event(world, EngineEvent::JoystickButtonUp(joystick))?
|
|
||||||
}
|
|
||||||
Event::JoystickAdded(joystick) => {
|
|
||||||
consumer.event(world, EngineEvent::JoystickAdded(joystick))?
|
|
||||||
}
|
|
||||||
Event::JoystickRemoved(joystick) => {
|
|
||||||
consumer.event(world, EngineEvent::JoystickRemoved(joystick))?
|
|
||||||
}
|
|
||||||
|
|
||||||
Event::FileDrop(filename) => consumer.event(world, EngineEvent::FileDrop(filename))?,
|
Event::FileDrop(filename) => consumer.event(world, EngineEvent::FileDrop(filename))?,
|
||||||
}
|
}
|
||||||
|
@ -207,10 +192,9 @@ impl Engine {
|
||||||
fn button_up_event<T: EventConsumer>(
|
fn button_up_event<T: EventConsumer>(
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
consumer: &mut T,
|
consumer: &mut T,
|
||||||
controller: &Controller,
|
|
||||||
button: ControllerButton,
|
button: ControllerButton,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
consumer.event(world, EngineEvent::ControllerButtonUp(controller, button))?;
|
consumer.event(world, EngineEvent::ButtonUp(button))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -220,13 +204,12 @@ impl Engine {
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
gui_handler: &GuiHandler,
|
gui_handler: &GuiHandler,
|
||||||
consumer: &mut T,
|
consumer: &mut T,
|
||||||
controller: &Controller,
|
|
||||||
button: ControllerButton,
|
button: ControllerButton,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
if gui_handler.check_navigatable()? {
|
if gui_handler.check_navigatable()? {
|
||||||
Self::check_button_down(world, gui_handler, consumer, controller, button)?;
|
Self::check_button_down(world, gui_handler, consumer, button)?;
|
||||||
} else {
|
} else {
|
||||||
consumer.event(world, EngineEvent::ControllerButtonDown(controller, button))?;
|
consumer.event(world, EngineEvent::ButtonDown(button))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -240,7 +223,7 @@ impl Engine {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
consumer.event(
|
consumer.event(
|
||||||
world,
|
world,
|
||||||
EngineEvent::ControllerAxis(controller, controller.controller_axis()),
|
EngineEvent::ControllerAxis(controller.controller_axis()),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -251,7 +234,6 @@ impl Engine {
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
gui_handler: &GuiHandler,
|
gui_handler: &GuiHandler,
|
||||||
consumer: &mut T,
|
consumer: &mut T,
|
||||||
controller: &Controller,
|
|
||||||
button: ControllerButton,
|
button: ControllerButton,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
match button {
|
match button {
|
||||||
|
@ -331,7 +313,7 @@ impl Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !gui_handler.accept_custom_selection(button)? {
|
if !gui_handler.accept_custom_selection(button)? {
|
||||||
consumer.event(world, EngineEvent::ControllerButtonDown(controller, button))?;
|
consumer.event(world, EngineEvent::ButtonDown(button))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -14,8 +14,8 @@ fn main() -> Result<()> {
|
||||||
world_builder.add_system(GameState::update);
|
world_builder.add_system(GameState::update);
|
||||||
world_builder.resources.insert(GameState::Startup);
|
world_builder.resources.insert(GameState::Startup);
|
||||||
|
|
||||||
// let dir = Path::new("C:/Users/M.Huebner/Downloads/Space Skybox Generator/Export");
|
let dir = Path::new("C:/Users/M.Huebner/Downloads/Space Skybox Generator/Export");
|
||||||
let dir = Path::new("/home/michaelh/Sync/skybox");
|
// let dir = Path::new("/home/michaelh/Sync/skybox");
|
||||||
SkyBox::new(
|
SkyBox::new(
|
||||||
&mut world_builder,
|
&mut world_builder,
|
||||||
[
|
[
|
||||||
|
|
|
@ -362,10 +362,6 @@ impl EventSystem {
|
||||||
pub fn controllers(&self) -> impl Iterator<Item = &Controller> {
|
pub fn controllers(&self) -> impl Iterator<Item = &Controller> {
|
||||||
self.connected_controllers.values()
|
self.connected_controllers.values()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn joysticks(&self) -> impl Iterator<Item = &Joystick> {
|
|
||||||
self.connected_joysticks.values()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for EventSystem {}
|
unsafe impl Send for EventSystem {}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pub use crate::traits::*;
|
pub use crate::traits::*;
|
||||||
|
|
||||||
pub use crate::{RenderCoreCreateInfo, create_render_core};
|
pub use crate::{create_render_core, RenderCoreCreateInfo};
|
||||||
|
|
||||||
pub use crate::presentationcore::{ApplicationInfo, PresentationBackend, PresentationCore, VRMode};
|
pub use crate::presentationcore::{ApplicationInfo, PresentationBackend, PresentationCore, VRMode};
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ pub use crate::renderbackend::{Eye, VRTransformations};
|
||||||
pub use crate::input::{
|
pub use crate::input::{
|
||||||
controller::{Controller, ControllerDeadzones},
|
controller::{Controller, ControllerDeadzones},
|
||||||
controlleraxis::ControllerAxis,
|
controlleraxis::ControllerAxis,
|
||||||
joystick::Joystick,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// wsi
|
// wsi
|
||||||
|
|
Loading…
Reference in a new issue