Struct pix_engine::engine::EngineBuilder
source · pub struct EngineBuilder { /* private fields */ }
Expand description
Implementations§
source§impl EngineBuilder
impl EngineBuilder
sourcepub fn position(&mut self, x: i32, y: i32) -> &mut Self
pub fn position(&mut self, x: i32, y: i32) -> &mut Self
Position the window at the given (x, y)
coordinates of the display.
sourcepub fn position_centered(&mut self) -> &mut Self
pub fn position_centered(&mut self) -> &mut Self
Position the window in the center of the display. This is the default.
sourcepub fn dimensions(&mut self, width: u32, height: u32) -> &mut Self
pub fn dimensions(&mut self, width: u32, height: u32) -> &mut Self
Set window dimensions.
sourcepub fn scale(&mut self, x: f32, y: f32) -> &mut Self
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.
sourcepub fn audio_sample_rate(&mut self, sample_rate: i32) -> &mut Self
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.
sourcepub fn audio_channels(&mut self, channels: u8) -> &mut Self
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.
sourcepub fn audio_buffer_size(&mut self, buffer_size: u16) -> &mut Self
pub fn audio_buffer_size(&mut self, buffer_size: u16) -> &mut Self
Set audio buffer size in samples. Defaults to device fallback sample size.
sourcepub fn fullscreen(&mut self) -> &mut Self
pub fn fullscreen(&mut self) -> &mut Self
Start window in fullscreen mode.
sourcepub fn vsync_enabled(&mut self) -> &mut Self
pub fn vsync_enabled(&mut self) -> &mut Self
Set the window to synchronize frame rate to the screens refresh rate (VSync
).
sourcepub fn borderless(&mut self) -> &mut Self
pub fn borderless(&mut self) -> &mut Self
Removes the window decoration.
sourcepub fn allow_highdpi(&mut self) -> &mut Self
pub fn allow_highdpi(&mut self) -> &mut Self
Enables high-DPI on displays that support it.
Starts engine with window hidden.
sourcepub fn show_frame_rate(&mut self) -> &mut Self
pub fn show_frame_rate(&mut self) -> &mut Self
Enable average frame rate (FPS) in title.
sourcepub fn target_frame_rate(&mut self, rate: usize) -> &mut Self
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.
sourcepub fn texture_cache(&mut self, size: NonZeroUsize) -> &mut Self
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.
sourcepub fn text_cache(&mut self, size: NonZeroUsize) -> &mut Self
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.
sourcepub fn build(&self) -> PixResult<Engine>
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.