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

Builds a Engine instance by providing several configration functions.

Example

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

Implementations§

source§

impl EngineBuilder

source

pub fn new() -> Self

Constructs a EngineBuilder.

source

pub fn title<S>(&mut self, title: S) -> &mut Self
where S: Into<String>,

Set a window title.

source

pub fn font(&mut self, font: Font) -> &mut Self

Set font for text rendering.

source

pub fn font_size(&mut self, size: u32) -> &mut Self

Set font size for text rendering.

source

pub fn theme(&mut self, theme: Theme) -> &mut Self

Set theme for UI rendering.

source

pub fn icon<I>(&mut self, icon: I) -> &mut Self
where I: Into<Icon>,

Set a window icon.

source

pub fn position(&mut self, x: i32, y: i32) -> &mut Self

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

source

pub fn position_centered(&mut self) -> &mut Self

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

source

pub fn dimensions(&mut self, width: u32, height: u32) -> &mut Self

Set window dimensions.

source

pub fn scale(&mut self, x: f32, y: f32) -> &mut Self

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

source

pub fn audio_sample_rate(&mut self, sample_rate: i32) -> &mut Self

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

source

pub fn audio_channels(&mut self, channels: u8) -> &mut Self

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

source

pub fn audio_buffer_size(&mut self, buffer_size: u16) -> &mut Self

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

source

pub fn fullscreen(&mut self) -> &mut Self

Start window in fullscreen mode.

source

pub fn vsync_enabled(&mut self) -> &mut Self

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

source

pub fn resizable(&mut self) -> &mut Self

Allow window resizing.

source

pub fn borderless(&mut self) -> &mut Self

Removes the window decoration.

source

pub fn deadzone(&mut self, value: i32) -> &mut Self

Alter the joystick axis deadzone.

source

pub fn allow_highdpi(&mut self) -> &mut Self

Enables high-DPI on displays that support it.

source

pub fn hidden(&mut self) -> &mut Self

Starts engine with window hidden.

source

pub fn show_frame_rate(&mut self) -> &mut Self

Enable average frame rate (FPS) in title.

source

pub fn target_frame_rate(&mut self, rate: usize) -> &mut Self

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

source

pub fn texture_cache(&mut self, size: NonZeroUsize) -> &mut Self

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

source

pub fn text_cache(&mut self, size: NonZeroUsize) -> &mut Self

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

source

pub fn build(&self) -> PixResult<Engine>

Convert EngineBuilder to a Engine 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§

source§

impl Debug for EngineBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for EngineBuilder

source§

fn default() -> Self

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

Auto Trait Implementations§

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

§

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

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V