Struct tetra::ContextBuilder [−][src]
Settings that can be configured when starting up a game.
Serde
Serialization and deserialization of this type (via Serde)
can be enabled via the serde_support
feature.
Note that the available settings could change between releases of
Tetra (semver permitting). If you need a config file schema that will
be stable in the long term, consider making your own and then mapping
it to Tetra's API, rather than relying on ContextBuilder
to not
change.
Implementations
impl ContextBuilder
[src]
pub fn new<S>(title: S, window_width: i32, window_height: i32) -> ContextBuilder where
S: Into<String>,
[src]
S: Into<String>,
Create a new ContextBuilder
, with a title and window size.
pub fn title<S>(&mut self, title: S) -> &mut ContextBuilder where
S: Into<String>,
[src]
S: Into<String>,
Sets the title of the window.
Defaults to "Tetra"
.
pub fn size(&mut self, width: i32, height: i32) -> &mut ContextBuilder
[src]
Sets the size of the window.
Defaults to 1280
by 720
.
pub fn vsync(&mut self, vsync: bool) -> &mut ContextBuilder
[src]
Enables or disables vsync.
Defaults to true
.
pub fn timestep(&mut self, timestep: Timestep) -> &mut ContextBuilder
[src]
Sets the game's timestep.
Defaults to Timestep::Fixed(60.0)
.
pub fn fullscreen(&mut self, fullscreen: bool) -> &mut ContextBuilder
[src]
Sets whether or not the window should start in fullscreen.
Defaults to false
.
pub fn maximized(&mut self, maximized: bool) -> &mut ContextBuilder
[src]
Sets whether or not the window should start maximized.
Defaults to false
.
pub fn minimized(&mut self, minimized: bool) -> &mut ContextBuilder
[src]
Sets whether or not the window should start minimized.
Defaults to false
.
pub fn resizable(&mut self, resizable: bool) -> &mut ContextBuilder
[src]
Sets whether or not the window should be resizable.
Defaults to false
.
pub fn borderless(&mut self, borderless: bool) -> &mut ContextBuilder
[src]
Sets whether or not the window should be borderless.
Defaults to false
.
pub fn multisampling(&mut self, multisampling: u8) -> &mut ContextBuilder
[src]
Sets the number of samples that should be used for multisample anti-aliasing.
The number of samples that can be used varies between graphics cards - 2
, 4
and 8
are reasonably
well supported. Setting the number of samples to 0
will disable multisampling.
Note that this setting only applies to the main backbuffer - multisampled canvases can
be created via Canvas::multisampled
.
Defaults to 0
.
pub fn high_dpi(&mut self, high_dpi: bool) -> &mut ContextBuilder
[src]
Sets whether or not the window should use a high-DPI backbuffer, on platforms that support it (e.g. MacOS with a retina display).
Note that you may also need some platform-specific config to enable high-DPI rendering:
- On Windows, set
dpiAware
totrue/pm
anddpiAwareness
topermonitorv2
in your application manifest. This should enable the best behaviour available, regardless of how old the user's version of Windows is.- The
embed-resource
crate can be used to automate embedding an application manifest. - Alternatively, you can use the
SetProcessDPIAware
orSetProcessDpiAwareness
Windows API functions to change these settings programatically, but Microsoft recommend not to do this.
- The
- On Mac, set
NSHighResolutionCapable
totrue
in your Info.plist. This is the default on Catalina and higher.
Defaults to false
.
pub fn screen_saver_enabled(
&mut self,
screen_saver_enabled: bool
) -> &mut ContextBuilder
[src]
&mut self,
screen_saver_enabled: bool
) -> &mut ContextBuilder
Sets whether or not the user's screen saver can be displayed while the game is running.
Defaults to false
.
pub fn key_repeat(&mut self, key_repeat: bool) -> &mut ContextBuilder
[src]
Sets whether or not key repeat should be enabled.
Normally, a KeyPressed
event will only be fired once, when
the key is initially pressed. Enabling key repeat causes KeyPressed
events to be fired
continuously while the key is held down.
Defaults to false
.
pub fn show_mouse(&mut self, show_mouse: bool) -> &mut ContextBuilder
[src]
Sets whether or not the mouse cursor should be visible when it is within the game window.
Defaults to false
.
pub fn grab_mouse(&mut self, grab_mouse: bool) -> &mut ContextBuilder
[src]
Sets whether or not the mouse cursor should be grabbed by the game window at startup.
Defaults to false
.
pub fn relative_mouse_mode(
&mut self,
relative_mouse_mode: bool
) -> &mut ContextBuilder
[src]
&mut self,
relative_mouse_mode: bool
) -> &mut ContextBuilder
Sets whether or not relative mouse mode should be enabled.
While the mouse is in relative mode, the cursor is hidden and can move beyond the
bounds of the window. The delta
field of Event::MouseMoved
can then be used to track the cursor's changes in position. This is useful
when implementing control schemes that require the mouse to be able to
move infinitely in any direction (for example, FPS-style movement).
While this mode is enabled, the absolute position of the mouse may not be updated - as such, you should not rely on it.
Defaults to false
.
pub fn quit_on_escape(&mut self, quit_on_escape: bool) -> &mut ContextBuilder
[src]
Sets whether or not the game should close when the Escape key is pressed.
Defaults to false
.
pub fn debug_info(&mut self, debug_info: bool) -> &mut ContextBuilder
[src]
Sets whether or not the game should print out debug info at startup. Please include this if you're submitting a bug report!
pub fn build(&self) -> Result<Context>
[src]
Builds the context.
Errors
TetraError::PlatformError
will be returned if the context cannot be initialized.
Trait Implementations
impl Clone for ContextBuilder
[src]
fn clone(&self) -> ContextBuilder
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ContextBuilder
[src]
impl Default for ContextBuilder
[src]
fn default() -> ContextBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for ContextBuilder
[src]
impl Send for ContextBuilder
[src]
impl Sync for ContextBuilder
[src]
impl Unpin for ContextBuilder
[src]
impl UnwindSafe for ContextBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,