Struct covalent::Context[][src]

pub struct Context { /* fields omitted */ }

A context that encapsulates the behaviour of an application run with covalent. This contains all the functions that the graphics backend will execute when the given event occurs.

The render thread runs concurrently with the update threads. A single frame is calculated by the update threads while a single frame is rendered by the render thread. This allows code to ensure that certain outside things (e.g. the position of the mouse) will not change during calculation of a frame. The graphics backend is required to call certain functions at intervals in the event loop to tell covalent what it is allowed to do. This is the execution order:

Render thread       | Update threads
--------------------+--------------------
Event handling      |
Call begin_frame  ----> Run pre-frame actions,
                    |   then process frame asynchronously
Render frame        | (Still processing frame)
Call end_frame    ----> Wait until processing frame is done,
                    |   then run post-frame actions

Pre/post-frame actions are therefore run while the render thread is idle. This means that they should only be used sparingly, where it is absolutely necessary to synchronise certain actions with respect to their rendering. For example, moving large amounts of nodes as a contiguous unit may require a post-frame action to make sure that all nodes are actually moved the same amount per frame.

Implementations

impl Context[src]

pub fn begin_frame(&self)[src]

Should be called by the graphics backend as soon as event handling has been completed. This signals to covalent that it can start to process a frame.

pub fn end_frame(&self)[src]

Should be called by the graphics backend as soon as rendering the frame is complete.

pub fn render_phases(
    &self
) -> (Arc<RwLock<Scene>>, Values<'_, i32, (String, PipelinePhase)>)
[src]

Should be called by the graphics backend once every frame to retrieve the current graphics pipeline.

pub fn process_keyboard_event(&self, e: KeyboardEvent)[src]

Should be called by the graphics backend whenever a key is pressed/released. This will trigger an event handler in the current Scene.

pub fn process_mouse_delta_event(&self, e: MouseDeltaEvent)[src]

Should be called by the graphics backend whenever the mouse is moved. This will trigger an event handler in the current Scene.

pub fn process_window_resize_event(&self, e: WindowResizeEvent)[src]

Should be called by the graphics backend whenever the window is resized. This will trigger an event handler in the current Scene.

Auto Trait Implementations

impl !RefUnwindSafe for Context

impl Send for Context

impl !Sync for Context

impl Unpin for Context

impl UnwindSafe for Context

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.