Struct nannou::window::Builder[][src]

pub struct Builder<'app> { /* fields omitted */ }
Expand description

A context for building a window.

Implementations

The default power preference used to request the WGPU adapter.

Begin building a new window.

Build the window with some custom window parameters.

Specify a set of parameters for building the window surface swap chain.

Specify the power preference desired for the WGPU adapter.

By default, this is wgpu::PowerPreference::HighPerformance.

Specify a device descriptor to use when requesting the logical device from the adapter. This allows for specifying custom wgpu device extensions.

Specify the number of samples per pixel for the multisample anti-aliasing render pass.

If msaa_samples is unspecified, the first default value that nannou will attempt to use can be found via the Frame::DEFAULT_MSAA_SAMPLES constant.

Note: This parameter has no meaning if the window uses a raw_view function for rendering graphics to the window rather than a view function. This is because the raw_view function provides a RawFrame with direct access to the swap chain image itself and thus must manage their own MSAA pass.

On the other hand, the view function provides the Frame type which allows the user to render to a multisampled intermediary image allowing Nannou to take care of resolving the multisampled image to the swap chain image. In order to avoid confusion, The Window::build method will panic! if the user tries to specify msaa_samples as well as a raw_view method.

TODO: Perhaps it would be worth adding two separate methods for specifying msaa samples. One for forcing a certain number of samples and returning an error otherwise, and another for attempting to use the given number of samples but falling back to a supported value in the case that the specified number is not supported.

Provide a simple function for drawing to the window.

This is similar to view but does not provide access to user data via a Model type. This is useful for sketches where you don’t require tracking any state.

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

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

Unlike the ViewFn, the RawViewFn provides a RawFrame that is designed for drawing directly to a window’s swap chain images, rather than to a convenient intermediary image.

A function for updating your model on WindowEvents associated with this window.

These include events such as key presses, mouse movement, clicks, resizing, etc.

Event Function Call Order

In nannou, if multiple functions require being called for a single kind of event, the more general event function will always be called before the more specific event function.

If an event function was also submitted to the App, that function will always be called immediately before window-specific event functions. Similarly, if a function associated with a more specific event type (e.g. key_pressed) was given, that function will be called after this function will be called.

Specific Events Variants

Note that if you only care about a certain kind of event, you can submit a function that only gets called for that specific event instead. For example, if you only care about key presses, you may wish to use the key_pressed method instead.

The same as the event method, but allows for processing raw winit::event::WindowEvents rather than Nannou’s simplified event::WindowEvents.

Event Function Call Order

If both raw_event and event functions have been provided, the given raw_event function will always be called immediately before the given event function.

A function for processing key press events associated with this window.

A function for processing key release events associated with this window.

A function for processing mouse moved events associated with this window.

A function for processing mouse pressed events associated with this window.

A function for processing mouse released events associated with this window.

A function for processing mouse wheel events associated with this window.

A function for processing mouse entered events associated with this window.

A function for processing mouse exited events associated with this window.

A function for processing touch events associated with this window.

A function for processing touchpad pressure events associated with this window.

A function for processing window moved events associated with this window.

A function for processing window resized events associated with this window.

A function for processing hovered file events associated with this window.

A function for processing hovered file cancelled events associated with this window.

A function for processing dropped file events associated with this window.

A function for processing the focused event associated with this window.

A function for processing the unfocused event associated with this window.

A function for processing the window closed event associated with this window.

The maximum number of simultaneous capture frame jobs that can be run for this window before we block and wait for the existing jobs to complete.

A “capture frame job” refers to the combind process of waiting to read a frame from the GPU and then writing that frame to an image file on the disk. Each call to window.capture_frame(path) spawns a new “capture frame job” on an internal thread pool.

By default, this value is equal to the number of physical cpu threads available on the system. However, keep in mind that this means there must be room in both RAM and VRAM for this number of textures to exist at any moment in time. If you run into an “out of memory” error, try reducing the number of max jobs to a lower value, though never lower than 1.

Panics if the specified value is less than 1.

In the case that max_capture_frame_jobs is reached and the main thread must block, this specifies how long to wait for a running capture job to complete. See the max_capture_frame_jobs docs for more details.

By default, the timeout used is equal to app::Builder::DEFAULT_CAPTURE_FRAME_TIMEOUT.

If None is specified, the capture process will never time out. This may be necessary on extremely low-powered machines that take a long time to write each frame to disk.

Builds the window, inserts it into the App’s display map and returns the unique ID.

Requests the window to be a specific size in points.

This describes to the “inner” part of the window, not including desktop decorations like the title bar.

Set the minimum size in points for the window.

Set the maximum size in points for the window.

Requests the window to be a specific size in points.

This describes to the “inner” part of the window, not including desktop decorations like the title bar.

Whether or not the window should be resizable after creation.

Requests a specific title for the window.

Create the window fullscreened on the current monitor.

Set the window fullscreen state with the given settings.

  • None indicates a normal window. This is the default case.
  • Some(Fullscreen) means fullscreen with the desired settings.

Requests maximized mode.

Sets whether the window will be initially hidden or visible.

Sets whether the background of the window should be transparent.

Sets whether the window should have a border, a title bar, etc.

Sets whether or not the window will always be on top of other windows.

Sets the window icon.

Auto Trait Implementations

Blanket Implementations

Convert the source color to the destination color using the specified method Read more

Convert the source color to the destination color using the bradford method by default Read more

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert into T with values clamped to the color defined bounds Read more

Convert into T. The resulting color might be invalid in its color space Read more

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.