[][src]Struct nannou::app::Builder

pub struct Builder<M = (), E = Event> { /* fields omitted */ }

A nannou App builder.

Methods

impl<M> Builder<M, Event> where
    M: 'static, 
[src]

pub fn new(model: ModelFn<M>) -> Self[src]

Begin building the App.

The model argument is the function that the App will call to initialise your Model.

The Model can be thought of as the state that you would like to track throughout the lifetime of your nannou program from start to exit.

The given function is called before any event processing begins within the application.

The Model that is returned by the function is the same model that will be passed to the given event and view functions.

pub fn event<E>(self, event: EventFn<M, E>) -> Builder<M, E> where
    E: LoopEvent
[src]

The function that the app will call to allow you to update your Model on events.

The event function allows you to expect any event type that implements LoopEvent, however nannou also provides a default Event type that should cover most use cases. This event type is an enum that describes all the different kinds of I/O events that might occur during the life of the program. These include things like Updates and WindowEvents such as KeyPressed, MouseMoved, and so on.

impl<M, E> Builder<M, E> where
    M: 'static,
    E: LoopEvent
[src]

pub fn view(self, view: ViewFn<M>) -> Self[src]

The default view function that the app will call to allow you to present your Model to the surface of a window on your display.

This function will be used in the case that a window-specific view function has not been provided, e.g. via window::Builder::view or window::Builder::sketch.

Note that when working with more than one window, you can use frame.window_id() to determine which window the current call is associated with.

pub fn update(self, update: UpdateFn<M>) -> Self[src]

A function for updating the model within the application loop.

See the LoopMode documentation for more information about the different kinds of application loop modes available in nannou and how they behave.

Update events are also emitted as a variant of the event function. Note that if you specify both an event function and an update function, the event function will always be called with an update event prior to this update function.

pub fn simple_window(self, view: ViewFn<M>) -> Self[src]

Tell the app that you would like it to create a single, simple, default window just before it calls your model function.

The given view function will play the same role as if passed to the view builder method. Note that the view function passed to this method will overwrite any pre-existing view function specified by any preceding call to the view

Note that calling this multiple times will not give you multiple windows, but instead will simply overwrite pre-existing calls to the method. If you would like to create multiple windows or would like more flexibility in your window creation process, please see the App::new_window method. The role of this simple_window method is to provide a quick-and-easy way to start with a simple window. This can be very useful for quick ideas, small single-window applications and examples.

pub fn exit(self, exit: ExitFn<M>) -> Self[src]

Specify an exit function to be called when the application exits.

The exit function gives ownership of the model back to you for any cleanup that might be necessary.

pub fn vk_instance(self, vk_instance: Arc<Instance>) -> Self[src]

The vulkan instance to use for interfacing with the system vulkan API.

If unspecified, nannou will create one via the following:

# use nannou::prelude::*;
# fn main() {
vk::InstanceBuilder::new()
    .build()
    .expect("failed to creat vulkan instance")
# ;
# }

If a vk_debug_callback was specified but the vk_instance is unspecified, nannou will do the following:

# use nannou::prelude::*;
# fn main() {
vk::InstanceBuilder::new()
    .extensions(vk::InstanceExtensions {
        ext_debug_report: true,
        ..vk::required_windowing_extensions()
    })
    .layers(vec!["VK_LAYER_LUNARG_standard_validation"])
    .build()
    .expect("failed to creat vulkan instance")
# ;
# }

pub fn vk_debug_callback(self, debug_cb: DebugCallbackBuilder) -> Self[src]

Specify a debug callback to be used with the vulkan instance.

If you just want to print messages from the standard validation layers to stdout, you can call this method with Default::default() as the argument.

Note that if you have specified a custom vk_instance, that instance must have the ext_debug_report extension enabled and must have been constructed with a debug layer.

pub fn run(self)[src]

Build and run an App with the specified parameters.

This function will not return until the application has exited.

If you wish to remain cross-platform frienly, we recommend that you call this on the main thread as some platforms require that their application event loop and windows are initialised on the main thread.

impl Builder<(), Event>[src]

pub fn sketch(view: SketchViewFn)[src]

Shorthand for building a simple app that has no model, handles no events and simply draws to a single window.

This is useful for late night hack sessions where you just don't care about all that other stuff, you just want to play around with some ideas or make something pretty.

Auto Trait Implementations

impl<M, E> Send for Builder<M, E>

impl<M = (), E = Event> !Sync for Builder<M, E>

Blanket Implementations

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

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

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.

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

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

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

impl<T> Content for T[src]

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

impl<T> Erased for T

impl<S> FromSample<S> for S[src]

impl<T, U> ToSample<U> for T where
    U: FromSample<T>, 
[src]

impl<S, T> Duplex<S> for T where
    T: FromSample<S> + ToSample<S>, 
[src]

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.