SFML 3.0.1
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Related Symbols | List of all members
sf::VideoMode Class Reference
Window module

VideoMode defines a video mode (size, bpp) More...

`#include <SFML/Window/VideoMode.hpp>`

## Public Member Functions
| VideoMode ()=default
| Default constructor.
| VideoMode (Vector2u modeSize, unsigned int modeBitsPerPixel=32)
| Construct the video mode with its attributes.
bool | isValid () const
| Tell whether or not the video mode is valid.

## Static Public Member Functions
static VideoMode | getDesktopMode ()
| Get the current desktop video mode.
static const std::vector< VideoMode > & | getFullscreenModes ()
| Retrieve all the video modes supported in fullscreen mode.

## Public Attributes
Vector2u | size
| Video mode width and height, in pixels.
unsigned int | bitsPerPixel {}
| Video mode pixel depth, in bits per pixels.

## Related Symbols
(Note that these are not member symbols.)
bool | operator== (const VideoMode &left, const VideoMode &right)
| Overload of operator== to compare two video modes.
bool | operator!= (const VideoMode &left, const VideoMode &right)
| Overload of operator!= to compare two video modes.
bool | operator< (const VideoMode &left, const VideoMode &right)
| Overload of operator< to compare video modes.
bool | operator> (const VideoMode &left, const VideoMode &right)
| Overload of operator> to compare video modes.
bool | operator<= (const VideoMode &left, const VideoMode &right)
| Overload of operator<= to compare video modes.
bool | operator>= (const VideoMode &left, const VideoMode &right)
| Overload of operator>= to compare video modes.

## Detailed Description

VideoMode defines a video mode (size, 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 (sf::Window) 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.

sf::VideoMode provides a static function for retrieving the list of all the video modes supported by the system: getFullscreenModes().

A custom video mode can also be checked directly for fullscreen compatibility with its isValid() function.

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

Usage example:

// Display the list of all the video modes available for fullscreen
std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
for (std::size_t i = 0; i < modes.size(); ++i)
{
sf::VideoMode mode = modes[i];
std::cout << "Mode #" << i << ": "
<< mode.size.x << "x" << mode.size.y << " - "
<< mode.bitsPerPixel << " bpp" << std::endl;
}
// Create a window with the same pixel depth as the desktop
sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
window.create(sf::VideoMode({1024, 768}, desktop.bitsPerPixel), "SFML window");
sf::Vector2::x
T x
X coordinate of the vector.
Definition Vector2.hpp:203
sf::Vector2::y
T y
Y coordinate of the vector.
Definition Vector2.hpp:204
sf::VideoMode
VideoMode defines a video mode (size, bpp)
Definition VideoMode.hpp:44
sf::VideoMode::getFullscreenModes
static const std::vector< VideoMode > & getFullscreenModes()
Retrieve all the video modes supported in fullscreen mode.
sf::VideoMode::bitsPerPixel
unsigned int bitsPerPixel
Video mode pixel depth, in bits per pixels.
Definition VideoMode.hpp:103
sf::VideoMode::getDesktopMode
static VideoMode getDesktopMode()
Get the current desktop video mode.
sf::VideoMode::size
Vector2u size
Video mode width and height, in pixels.
Definition VideoMode.hpp:102

Definition at line 43 of file VideoMode.hpp.

## Constructor & Destructor Documentation

## ◆ VideoMode() [1/2]

sf::VideoMode::VideoMode | ( |  | ) |
| default

Default constructor.

This constructors initializes all members to 0.

## ◆ VideoMode() [2/2]

sf::VideoMode::VideoMode | ( | Vector2u | modeSize,
|  | unsigned int | modeBitsPerPixel = 32 )
| explicit

Construct the video mode with its attributes.

Parameters

  modeSize | Width and height in pixels
  modeBitsPerPixel | Pixel depths in bits per pixel

## Member Function Documentation

## ◆ getDesktopMode()

VideoMode sf::VideoMode::getDesktopMode | ( |  | ) |
| static nodiscard

Get the current desktop video mode.

Returns
  Current desktop video mode

## ◆ getFullscreenModes()

const std::vector< VideoMode > & sf::VideoMode::getFullscreenModes | ( |  | ) |
| static nodiscard

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

Returns
  Array containing all the supported fullscreen modes

## ◆ isValid()

bool sf::VideoMode::isValid | ( |  | ) | const
| nodiscard

Tell whether or not the 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.

Returns
  true if the video mode is valid for fullscreen mode

## Friends And Related Symbol Documentation

## ◆ operator!=()

bool operator!= | ( | const VideoMode & | left,
|  | const VideoMode & | right )
| related

Overload of operator!= to compare two video modes.

Parameters

  left | Left operand (a video mode)
  right | Right operand (a video mode)

Returns
  true if modes are different

## ◆ operator<()

bool operator< | ( | const VideoMode & | left,
|  | const VideoMode & | right )
| related

Overload of operator< to compare video modes.

Parameters

  left | Left operand (a video mode)
  right | Right operand (a video mode)

Returns
  true if left is lesser than right

## ◆ operator<=()

bool operator<= | ( | const VideoMode & | left,
|  | const VideoMode & | right )
| related

Overload of operator<= to compare video modes.

Parameters

  left | Left operand (a video mode)
  right | Right operand (a video mode)

Returns
  true if left is lesser or equal than right

## ◆ operator==()

bool operator== | ( | const VideoMode & | left,
|  | const VideoMode & | right )
| related

Overload of operator== to compare two video modes.

Parameters

  left | Left operand (a video mode)
  right | Right operand (a video mode)

Returns
  true if modes are equal

## ◆ operator>()

bool operator> | ( | const VideoMode & | left,
|  | const VideoMode & | right )
| related

Overload of operator> to compare video modes.

Parameters

  left | Left operand (a video mode)
  right | Right operand (a video mode)

Returns
  true if left is greater than right

## ◆ operator>=()

bool operator>= | ( | const VideoMode & | left,
|  | const VideoMode & | right )
| related

Overload of operator>= to compare video modes.

Parameters

  left | Left operand (a video mode)
  right | Right operand (a video mode)

Returns
  true if left is greater or equal than right

## Member Data Documentation

## ◆ bitsPerPixel

unsigned int sf::VideoMode::bitsPerPixel {}

Video mode pixel depth, in bits per pixels.

Definition at line 103 of file VideoMode.hpp.

## ◆ size

Vector2u sf::VideoMode::size

Video mode width and height, in pixels.

Definition at line 102 of file VideoMode.hpp.

The documentation for this class was generated from the following file:

- VideoMode.hpp