Skip to content

Commit

Permalink
chore: changed the naming of plugins to more appropriate: live_events
Browse files Browse the repository at this point in the history
  • Loading branch information
ElhamAryanpur committed Feb 17, 2024
1 parent 60513a5 commit 87280c1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file.

## [0.5.7] - 2024-02-17

### Bug Fixes

- Surface error for non zero size on windows ([8426db3](https://github.com/AryanpurTech/BlueEngine/commit/8426db3e46bd709f0df98cf890ffdd73c87ecaef))

### Features

- Added `control_flow`, `present_mode`, `alpha_mode`, and `desired_maximum_frame_latency` options ([60513a5](https://github.com/AryanpurTech/BlueEngine/commit/60513a547b30284cc2bf0e977d462c69f9a8fb36))
- Fixed scissor bounds bug, added examples ([9a89185](https://github.com/AryanpurTech/BlueEngine/commit/9a89185451f55be11d2821c8c33d8eb1650aee88))
- Added scissor and clear color finally ([ee77156](https://github.com/AryanpurTech/BlueEngine/commit/ee771568340f74374023212e20c6845c5c14b253))

### Miscellaneous Tasks

- Clear color example and updates ([6e2f434](https://github.com/AryanpurTech/BlueEngine/commit/6e2f4343e501ce860f4154ddca38f2ad01e11076))

## [0.5.0] - 2023-09-14

### Documentation
Expand Down
18 changes: 12 additions & 6 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub struct Engine {
/// The camera handles the way the scene looks when rendered. You can modify everything there is to camera through this.
pub camera: Camera,
/// Handles all engine plugins
pub plugins: Vec<Box<dyn crate::EnginePlugin>>,
pub live_events: Vec<Box<dyn crate::EngineLiveEvent>>,
}
unsafe impl Send for Engine {}
unsafe impl Sync for Engine {}
Expand Down Expand Up @@ -470,9 +470,9 @@ pub struct Instance {
}

/// Allows all events to be fetched directly, making it easier to add custom additions to the engine.
pub trait EnginePlugin: Any {
pub trait EngineLiveEvent: Any {
/// This is ran before any of the render events, it's generally used to capture raw input.
fn update_events(
fn events(
&mut self,
_renderer: &mut crate::Renderer,
_window: &crate::Window,
Expand All @@ -482,8 +482,8 @@ pub trait EnginePlugin: Any {
_camera: &mut crate::Camera,
);

/// ran after an update loop code is done on each frame
fn update(
/// ran before the frame is rendered
fn frame(
&mut self,
_renderer: &mut crate::Renderer,
_window: &crate::Window,
Expand All @@ -494,7 +494,7 @@ pub trait EnginePlugin: Any {
_view: &crate::TextureView,
);
}
downcast!(dyn EnginePlugin);
downcast!(dyn EngineLiveEvent);

/// Defines how the rotation axis is
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -599,3 +599,9 @@ impl_deref!(ObjectStorage, std::collections::HashMap<String, Object>);

/// Depth format
pub const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float;

/// Handles the order in which a functionality in the engine should be executed
pub enum ExecuteOrder {
/// The main function that is the update_loop
UpdateLoopFunction,
}
16 changes: 8 additions & 8 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Engine {
renderer,
objects: ObjectStorage::new(),
camera,
plugins: vec![],
live_events: vec![],
})
}

Expand All @@ -93,7 +93,7 @@ impl Engine {
&mut ObjectStorage,
&winit_input_helper::WinitInputHelper,
&mut Camera,
&mut Vec<Box<dyn crate::EnginePlugin>>,
&mut Vec<Box<dyn crate::EngineLiveEvent>>,
),
>(
self,
Expand All @@ -105,7 +105,7 @@ impl Engine {
mut window,
mut objects,
mut camera,
mut plugins,
mut live_events,
} = self;

// and get input events to handle them later
Expand All @@ -117,8 +117,8 @@ impl Engine {
event_loop.run(move |events, window_target| {
input.update(&events);

plugins.iter_mut().for_each(|i| {
i.update_events(
live_events.iter_mut().for_each(|i| {
i.events(
&mut renderer,
&window,
&mut objects,
Expand Down Expand Up @@ -159,11 +159,11 @@ impl Engine {
&mut objects,
&input,
&mut camera,
&mut plugins,
&mut live_events,
);

plugins.iter_mut().for_each(|i| {
i.update(
live_events.iter_mut().for_each(|i| {
i.frame(
&mut renderer,
&window,
&mut objects,
Expand Down

0 comments on commit 87280c1

Please sign in to comment.