Engine

Struct Engine 

Source
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: Renderer

The renderer does exactly what it is called. It works with the GPU to render frames according to the data you gave it.

§objects: ObjectStorage

The 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: CameraContainer

The camera handles the way the scene looks when rendered. You can modify everything there is to camera through this.

§signals: SignalStorage

Handles all engine plugins

§update_loop: Option<Box<dyn FnMut(&mut Engine)>>

holds the update_loop function

Implementations§

Source§

impl Engine

Source

pub fn new() -> Result<Engine, Error>

Creates a new window in current thread using default settings.

Source

pub fn new_config(settings: EngineSettings) -> Result<Engine, Error>

Creates a new window in current thread using provided settings.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,