Struct tetra::ContextBuilder[][src]

pub struct ContextBuilder { /* fields omitted */ }
Expand description

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

Create a new ContextBuilder, with a title and window size.

Sets the title of the window.

Defaults to "Tetra".

Sets the size of the window.

Defaults to 1280 by 720.

Enables or disables vsync.

Setting this flag does not guarantee that the requested vsync mode will be used - some platforms do not support vsync, and others enforce vsync. If you want to find out which vsync mode was actually chosen, you can call window::is_vsync_enabled.

Defaults to true.

Sets the game’s timestep.

Defaults to Timestep::Fixed(60.0).

Sets whether or not the window should start in fullscreen.

Defaults to false.

Sets whether or not the window should start maximized.

Defaults to false.

Sets whether or not the window should start minimized.

Defaults to false.

Sets whether or not the window should be resizable.

Defaults to false.

Sets whether or not the window should be borderless.

Defaults to false.

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::builder.

Defaults to 0.

Sets whether or not the window should have a stencil buffer.

If this is enabled, you can use the stencil functions in the graphics module when rendering to the main backbuffer.

Note that this setting only applies to the main backbuffer - to create a canvas with a stencil buffer, use Canvas::builder.

Defaults to false.

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 to true/pm and dpiAwareness to permonitorv2 in your application manifest. This should enable the best behaviour available, regardless of how old the user’s version of Windows is.
  • On Mac, set NSHighResolutionCapable to true in your Info.plist. This is the default on Catalina and higher.

Defaults to false.

Sets whether or not the user’s screen saver can be displayed while the game is running.

Defaults to false.

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.

Sets whether or not the mouse cursor should be visible when it is within the game window.

Defaults to false.

Sets whether or not the mouse cursor should be grabbed by the game window at startup.

Defaults to false.

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.

Sets whether or not the game should close when the Escape key is pressed.

Defaults to false.

Sets whether or not the game should print out debug info at startup. Please include this if you’re submitting a bug report!

Builds the context.

Errors

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. 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.