AppCreator

Struct AppCreator 

Source
pub struct AppCreator<T: 'static> { /* private fields */ }
Expand description

builder for App

Implementations§

Source§

impl<T: 'static> AppCreator<T>

Source

pub fn new(state: T) -> AppCreator<T>

creates AppCreator

§Arguments
  • state: data which describes your App can be changes on update and used to render
Examples found in repository?
examples/display_rect.rs (line 23)
22fn main() {
23    AppCreator::new(())
24        .init(init)
25        .render(render)
26        .title("Rect")
27        .resizable(false)
28        .run();
29}
More examples
Hide additional examples
examples/moving_triangle.rs (lines 30-34)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}
Source

pub fn window_event(self, input: WindowEventFn<T>) -> Self

gets called on every WindowEvent

e.g. mouse | keyboard input

Source

pub fn resize(self, resize: ResizeFn<T>) -> Self

gets called on every ResizeEvent

Examples found in repository?
examples/moving_triangle.rs (line 38)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}
Source

pub fn update(self, update: UpdateFn<T>) -> Self

gets called on every frame just before AppCreator::render

here you can change your State

Examples found in repository?
examples/moving_triangle.rs (line 37)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}
Source

pub fn render(self, render: RenderFn<T>) -> Self

gets called on every frame just after AppCreator::update

here you can render your frame

Examples found in repository?
examples/display_rect.rs (line 25)
22fn main() {
23    AppCreator::new(())
24        .init(init)
25        .render(render)
26        .title("Rect")
27        .resizable(false)
28        .run();
29}
More examples
Hide additional examples
examples/moving_triangle.rs (line 36)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}
Source

pub fn init(self, init: InitFn<T>) -> Self

gets called before opening the window

mainly used to create your RenderPipelines

Examples found in repository?
examples/display_rect.rs (line 24)
22fn main() {
23    AppCreator::new(())
24        .init(init)
25        .render(render)
26        .title("Rect")
27        .resizable(false)
28        .run();
29}
More examples
Hide additional examples
examples/moving_triangle.rs (line 35)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}
Source

pub fn present_mode(self, present_mode: PresentMode) -> Self

sets the PresentMode of the Surface

default: PresentMode::Fifo

Examples found in repository?
examples/moving_triangle.rs (line 39)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}
Source

pub fn title(self, title: &str) -> Self

Examples found in repository?
examples/display_rect.rs (line 26)
22fn main() {
23    AppCreator::new(())
24        .init(init)
25        .render(render)
26        .title("Rect")
27        .resizable(false)
28        .run();
29}
Source

pub fn resizable(self, resizable: bool) -> Self

Examples found in repository?
examples/display_rect.rs (line 27)
22fn main() {
23    AppCreator::new(())
24        .init(init)
25        .render(render)
26        .title("Rect")
27        .resizable(false)
28        .run();
29}
Source

pub fn get_window(&mut self) -> &mut Window

Source

pub fn add_view_formats(self, texture_format: TextureFormat) -> Self

Source

pub fn power_preference(self, power_preference: PowerPreference) -> Self

sets the PowerPreference of the Adapter

default: PresentMode::Fifo

Source

pub fn device_limits(self, limits: Limits) -> Self

sets the Limits of the Device

default: Limits::default

Source

pub fn run(self)

opens the window and starts the AppCreator::update | AppCreator::render loop

Examples found in repository?
examples/display_rect.rs (line 28)
22fn main() {
23    AppCreator::new(())
24        .init(init)
25        .render(render)
26        .title("Rect")
27        .resizable(false)
28        .run();
29}
More examples
Hide additional examples
examples/moving_triangle.rs (line 40)
29fn main() {
30    AppCreator::new(State {
31        pos: (0.5, 0.0),
32        vel: (0.707, 0.707),
33        x_scale: 9.0 / 16.0,
34    })
35        .init(init)
36        .render(render)
37        .update(update)
38        .resize(resize)
39        .present_mode(PresentMode::Immediate)
40        .run()
41}

Auto Trait Implementations§

§

impl<T> !Freeze for AppCreator<T>

§

impl<T> !RefUnwindSafe for AppCreator<T>

§

impl<T> !Send for AppCreator<T>

§

impl<T> !Sync for AppCreator<T>

§

impl<T> Unpin for AppCreator<T>
where T: Unpin,

§

impl<T> !UnwindSafe for AppCreator<T>

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