pub struct Engine {
pub renderer: Renderer,
pub event_loop_control_flow: ControlFlow,
pub window: Window,
pub objects: ObjectStorage,
pub camera: CameraContainer,
pub signals: SignalStorage,
pub update_loop: Option<Box<dyn FnMut(&mut Renderer, &mut Window, &mut ObjectStorage, &WinitInputHelper, &mut CameraContainer, &mut SignalStorage)>>,
pub input_events: WinitInputHelper,
}Expand description
The engine is the main starting point of using the Blue Engine. Everything that runs on Blue Engine will be under this struct. The structure of engine is monolithic, but the underlying data and the way it works is not. It gives a set of default data to work with, but also allow you to go beyond that and work as low level as you wish to.
You can also use the Engine to build you own custom structure the way you wish for it to be. Possibilities are endless!
To start using the Blue Engine, you can start by creating a new Engine like follows:
use blue_engine::prelude::{Engine, WindowDescriptor};
fn main() {
let engine = Engine::new().expect("Couldn't create the engine");
}The WindowDescriptor simply holds what features you would like for your window. If you are reading this on later version of the engine, you might be able to even run the engine in headless mode meaning there would not be a need for a window and the renders would come as image files.
If you so wish to have a window, you would need to start a window update loop. The update loop of window runs a frame every few millisecond, and gives you details of what is happening during this time, like input events. You can also modify existing parts of the engine during this update loop, such as changing camera to look differently, or creating a new object on the scene, or even changing window details!
The update loop is just a method of the Engine struct that have one argument which is a callback function.
[THE DATA HERE IS WORK IN PROGRESS!]
Fields§
§renderer: RendererThe renderer does exactly what it is called. It works with the GPU to render frames according to the data you gave it.
event_loop_control_flow: ControlFlowThe event_loop handles the events of the window and inputs.
§USED INTERNALLY
window: WindowThe window handles everything about window and inputs. This includes ability to modify window and listen toinput devices for changes.
§The window is not available before update_loop.
objects: ObjectStorageThe object system is a way to make it easier to work with the engine. Obviously you can work without it, but it’s for those who do not have the know-how, or wish to handle all the work of rendering data manually.
camera: CameraContainerThe camera handles the way the scene looks when rendered. You can modify everything there is to camera through this.
signals: SignalStorageHandles all engine plugins
update_loop: Option<Box<dyn FnMut(&mut Renderer, &mut Window, &mut ObjectStorage, &WinitInputHelper, &mut CameraContainer, &mut SignalStorage)>>holds the update_loop function
§USED INTERNALLY
input_events: WinitInputHelperinput events
§USED INTERNALLY
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new() -> Result<Engine, Error>
pub fn new() -> Result<Engine, Error>
Creates a new window in current thread using default settings.
Sourcepub fn new_config(settings: WindowDescriptor) -> Result<Engine, Error>
pub fn new_config(settings: WindowDescriptor) -> Result<Engine, Error>
Creates a new window in current thread using provided settings.
Sourcepub fn update_loop(
&mut self,
update_function: impl FnMut(&mut Renderer, &mut Window, &mut ObjectStorage, &WinitInputHelper, &mut CameraContainer, &mut SignalStorage) + 'static,
) -> Result<(), Error>
pub fn update_loop( &mut self, update_function: impl FnMut(&mut Renderer, &mut Window, &mut ObjectStorage, &WinitInputHelper, &mut CameraContainer, &mut SignalStorage) + 'static, ) -> Result<(), Error>
Runs the block of code that you pass to it every frame. The update code is used to modify the engine on the fly thus creating interactive graphics and making things happy in the engine!
Renderer, window, vec of objects, events, and camera are passed to the update code.
Trait Implementations§
Source§impl ApplicationHandler for Engine
impl ApplicationHandler for Engine
Source§fn resumed(&mut self, event_loop: &ActiveEventLoop)
fn resumed(&mut self, event_loop: &ActiveEventLoop)
Source§fn device_event(
&mut self,
_event_loop: &ActiveEventLoop,
_device_id: DeviceId,
event: DeviceEvent,
)
fn device_event( &mut self, _event_loop: &ActiveEventLoop, _device_id: DeviceId, event: DeviceEvent, )
Source§fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
_window_id: WindowId,
event: WindowEvent,
)
fn window_event( &mut self, event_loop: &ActiveEventLoop, _window_id: WindowId, event: WindowEvent, )
Source§fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause)
fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause)
Source§fn user_event(&mut self, event_loop: &ActiveEventLoop, event: T)
fn user_event(&mut self, event_loop: &ActiveEventLoop, event: T)
EventLoopProxy::send_event.Source§fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)
Source§fn suspended(&mut self, event_loop: &ActiveEventLoop)
fn suspended(&mut self, event_loop: &ActiveEventLoop)
Source§fn exiting(&mut self, event_loop: &ActiveEventLoop)
fn exiting(&mut self, event_loop: &ActiveEventLoop)
Source§fn memory_warning(&mut self, event_loop: &ActiveEventLoop)
fn memory_warning(&mut self, event_loop: &ActiveEventLoop)
impl Send for Engine
impl Sync for Engine
Auto Trait Implementations§
impl !Freeze for Engine
impl !RefUnwindSafe for Engine
impl Unpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more