pub struct Builder { /* private fields */ }
Expand description

Builds a PixEngine instance by providing several configration functions.

Example

fn main() -> PixResult<()> {
    let mut engine = PixEngine::builder()
        .with_title("My App")
        .position(10, 10)
        .resizable()
        .with_frame_rate()
        .icon("myapp.png")
        .build()?;
    let mut app = MyApp;
    engine.run(&mut app)
}

Implementations

Constructs a Builder.

Set a window title.

Set font for text rendering.

Set font size for text rendering.

Set theme for UI rendering.

Set a window icon.

Position the window at the given (x, y) coordinates of the display.

Position the window in the center of the display. This is the default.

Set window dimensions.

Set the rendering scale of the current canvas. Drawing coordinates are scaled by x/y factors before being drawn to the canvas.

Set audio sample rate in Hz (samples per second). Defaults to device fallback sample rate.

Set number of audio channels (1 for Mono, 2 for Stereo, etc). Defaults to device fallback number of channels.

Set audio buffer size in samples. Defaults to device fallback sample size.

Start window in fullscreen mode.

Set the window to synchronize frame rate to the screens refresh rate (VSync).

Allow window resizing.

Removes the window decoration.

Alter the joystick axis deadzone.

Enables high-DPI on displays that support it.

Starts engine with window hidden.

Enable average frame rate (FPS) in title.

Set a target frame rate to render at, controls how often AppState::on_update is called.

Set a custom texture cache size other than the default of 20. Affects font family and image rendering caching operations.

Set a custom text cache size other than the default of 500. Affects text rendering caching operations.

Convert Builder to a PixEngine instance.

Errors

If the engine fails to create a new renderer, then an error is returned.

Possible errors include the title containing a nul character, the position or dimensions being invalid values or overlowing and an internal renderer error such as running out of memory or a software driver issue.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.