blue_engine_core

Struct Engine

Source
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) + 'static>>,
    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::header::{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: Renderer

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

The event_loop handles the events of the window and inputs.

§USED INTERNALLY
§window: Window

The 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: 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 Renderer, &mut Window, &mut ObjectStorage, &WinitInputHelper, &mut CameraContainer, &mut SignalStorage) + 'static>>

holds the update_loop function

§USED INTERNALLY
§input_events: WinitInputHelper

input events

§USED INTERNALLY

Implementations§

Source§

impl Engine

Source

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

Creates a new window in current thread using default settings.

Source

pub fn new_config(settings: WindowDescriptor) -> Result<Self, Error>

Creates a new window in current thread using provided settings.

Source

pub fn update_loop( &mut self, update_function: impl 'static + FnMut(&mut Renderer, &mut Window, &mut ObjectStorage, &WinitInputHelper, &mut CameraContainer, &mut SignalStorage), ) -> 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

Source§

fn resumed(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has been resumed. Read more
Source§

fn device_event( &mut self, _event_loop: &ActiveEventLoop, _device_id: DeviceId, event: DeviceEvent, )

Emitted when the OS sends an event to a device.
Source§

fn window_event( &mut self, event_loop: &ActiveEventLoop, _window_id: WindowId, event: WindowEvent, )

Emitted when the OS sends an event to a winit window.
Source§

fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause)

Emitted when new events arrive from the OS to be processed. Read more
Source§

fn user_event(&mut self, event_loop: &ActiveEventLoop, event: T)

Emitted when an event is sent from EventLoopProxy::send_event.
Source§

fn about_to_wait(&mut self, event_loop: &ActiveEventLoop)

Emitted when the event loop is about to block and wait for new events. Read more
Source§

fn suspended(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has been suspended. Read more
Source§

fn exiting(&mut self, event_loop: &ActiveEventLoop)

Emitted when the event loop is being shut down. Read more
Source§

fn memory_warning(&mut self, event_loop: &ActiveEventLoop)

Emitted when the application has received a memory warning. Read more
Source§

impl Send for Engine

Source§

impl Sync for Engine

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> Downcast for T
where T: Any,

Source§

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

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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