pub struct AppCreator<T: 'static> { /* private fields */ }Expand description
builder for App
Implementations§
Source§impl<T: 'static> AppCreator<T>
impl<T: 'static> AppCreator<T>
Sourcepub fn new(state: T) -> AppCreator<T>
pub fn new(state: T) -> AppCreator<T>
creates AppCreator
§Arguments
Examples found in repository?
More 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}Sourcepub fn window_event(self, input: WindowEventFn<T>) -> Self
pub fn window_event(self, input: WindowEventFn<T>) -> Self
gets called on every WindowEvent
e.g. mouse | keyboard input
Sourcepub fn resize(self, resize: ResizeFn<T>) -> Self
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}Sourcepub fn update(self, update: UpdateFn<T>) -> Self
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}Sourcepub fn render(self, render: RenderFn<T>) -> Self
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?
More 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}Sourcepub fn init(self, init: InitFn<T>) -> Self
pub fn init(self, init: InitFn<T>) -> Self
gets called before opening the window
mainly used to create your RenderPipelines
Examples found in repository?
More 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}Sourcepub fn present_mode(self, present_mode: PresentMode) -> Self
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}pub fn get_window(&mut self) -> &mut Window
pub fn add_view_formats(self, texture_format: TextureFormat) -> Self
Sourcepub fn power_preference(self, power_preference: PowerPreference) -> Self
pub fn power_preference(self, power_preference: PowerPreference) -> Self
sets the PowerPreference of the Adapter
default: PresentMode::Fifo
Sourcepub fn device_limits(self, limits: Limits) -> Self
pub fn device_limits(self, limits: Limits) -> Self
default: Limits::default
Sourcepub fn run(self)
pub fn run(self)
opens the window and starts the AppCreator::update | AppCreator::render loop
Examples found in repository?
More 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> 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
Mutably borrows from an owned value. Read more