Struct sfml::window::VideoMode

source ·
pub struct VideoMode {
    pub width: u32,
    pub height: u32,
    pub bits_per_pixel: u32,
}
Expand description

VideoMode defines a video mode (width, height, bpp)

A video mode is defined by a width and a height (in pixels) and a depth (in bits per pixel).

Video modes are used to setup windows at creation time.

The main usage of video modes is for fullscreen mode: indeed you must use one of the valid video modes allowed by the OS (which are defined by what the monitor and the graphics card support), otherwise your window creation will just fail.

VideoMode provides an associated function for retrieving the list of all the video modes supported by the system: VideoMode::fullscreen_modes.

A custom video mode can also be checked directly for fullscreen compatibility with its VideoMode::is_valid function.

Additionally, VideoMode provides a static function to get the mode currently used by the desktop: VideoMode::desktop_mode. This allows to build windows with the same size or pixel depth as the current resolution.

Usage example

use sfml::window::{VideoMode, Window, Style};

// Display the list of all the video modes available for fullscreen
let modes = VideoMode::fullscreen_modes();

for mode in modes {
    println!("{:?}", mode);
}

// Create a window with the same pixel depth as the desktop
let desktop = VideoMode::desktop_mode();
let _window = Window::new(VideoMode::new(1024, 768, desktop.bits_per_pixel),
                          "SFML window",
                          Style::CLOSE,
                          &Default::default());

Fields§

§width: u32

Video mode width, in pixels.

§height: u32

Video mode height, in pixels.

§bits_per_pixel: u32

Video mode pixel depth, in bits per pixels.

Implementations§

Constructs a new VideoMode from the given parameters.

Tell whether or not a video mode is valid

The validity of video modes is only relevant when using fullscreen windows; otherwise any video mode can be used with no restriction.

return true if the video mode is valid for fullscreen mode

Static Method, get the current desktop video mode

return the urrent desktop video mode

Static Method, retrieve all the video modes supported in fullscreen mode

When creating a fullscreen window, the video mode is restricted to be compatible with what the graphics driver and monitor support. This function returns the complete list of all video modes that can be used in fullscreen mode. The returned array is sorted from best to worst, so that the first element will always give the best mode (higher width, height and bits_per_pixel).

Return a vector containing all the supported VideoModes

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

Constructs a VideoMode from (w, h). Bit depth is 32.

This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.