pub struct Engine {
pub renderer: Renderer,
pub objects: ObjectStorage,
pub camera: CameraContainer,
pub signals: SignalStorage,
pub update_loop: Option<Box<dyn FnMut(&mut Engine)>>,
}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};
fn main() {
let engine = Engine::new().expect("Couldn't create the engine");
}The EngineSettings 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.
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 Engine)>>holds the update_loop function
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: EngineSettings) -> Result<Engine, Error>
pub fn new_config(settings: EngineSettings) -> Result<Engine, Error>
Creates a new window in current thread using provided settings.
Sourcepub fn update_loop(
&mut self,
update_function: impl FnMut(&mut Engine) + 'static,
) -> Result<(), Error>
pub fn update_loop( &mut self, update_function: impl FnMut(&mut Engine) + '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§
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> 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