Public Member Functions | Static Public Member Functions | Public Attributes | Related Functions
sf::VideoMode Class Reference

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

#include <VideoMode.hpp>

List of all members.

Public Member Functions

 VideoMode ()
 Default constructor.
 VideoMode (unsigned int width, unsigned int height, unsigned int bitsPerPixel=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

unsigned int Width
 Video mode width, in pixels.
unsigned int Height
 Video mode height, in pixels.
unsigned int BitsPerPixel
 Video mode pixel depth, in bits per pixels.

Related Functions

(Note that these are not member functions.)

SFML_API bool operator== (const VideoMode &left, const VideoMode &right)
 Overload of == operator to compare two video modes.
SFML_API bool operator!= (const VideoMode &left, const VideoMode &right)
 Overload of != operator to compare two video modes.
SFML_API bool operator< (const VideoMode &left, const VideoMode &right)
 Overload of < operator to compare video modes.
SFML_API bool operator> (const VideoMode &left, const VideoMode &right)
 Overload of > operator to compare video modes.
SFML_API bool operator<= (const VideoMode &left, const VideoMode &right)
 Overload of <= operator to compare video modes.
SFML_API bool operator>= (const VideoMode &left, const VideoMode &right)
 Overload of >= operator to compare video modes.

Detailed 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 (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.

Additionnally, 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.Width << "x" << mode.Height << " - "
               << 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");

Definition at line 41 of file VideoMode.hpp.


Constructor & Destructor Documentation

sf::VideoMode::VideoMode ( )

Default constructor.

This constructors initializes all members to 0.

sf::VideoMode::VideoMode ( unsigned int  width,
unsigned int  height,
unsigned int  bitsPerPixel = 32 
)

Construct the video mode with its attributes.

Parameters:
widthWidth in pixels
heightHeight in pixels
bitsPerPixelPixel depths in bits per pixel

Member Function Documentation

static VideoMode sf::VideoMode::GetDesktopMode ( ) [static]

Get the current desktop video mode.

Returns:
Current desktop video mode
static const std::vector<VideoMode>& sf::VideoMode::GetFullscreenModes ( ) [static]

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
bool sf::VideoMode::IsValid ( ) const

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 Function Documentation

SFML_API bool operator!= ( const VideoMode left,
const VideoMode right 
) [related]

Overload of != operator to compare two video modes.

Parameters:
leftLeft operand (a video mode)
rightRight operand (a video mode)
Returns:
True if modes are different
SFML_API bool operator< ( const VideoMode left,
const VideoMode right 
) [related]

Overload of < operator to compare video modes.

Parameters:
leftLeft operand (a video mode)
rightRight operand (a video mode)
Returns:
True if left is lesser than right
SFML_API bool operator<= ( const VideoMode left,
const VideoMode right 
) [related]

Overload of <= operator to compare video modes.

Parameters:
leftLeft operand (a video mode)
rightRight operand (a video mode)
Returns:
True if left is lesser or equal than right
SFML_API bool operator== ( const VideoMode left,
const VideoMode right 
) [related]

Overload of == operator to compare two video modes.

Parameters:
leftLeft operand (a video mode)
rightRight operand (a video mode)
Returns:
True if modes are equal
SFML_API bool operator> ( const VideoMode left,
const VideoMode right 
) [related]

Overload of > operator to compare video modes.

Parameters:
leftLeft operand (a video mode)
rightRight operand (a video mode)
Returns:
True if left is greater than right
SFML_API bool operator>= ( const VideoMode left,
const VideoMode right 
) [related]

Overload of >= operator to compare video modes.

Parameters:
leftLeft operand (a video mode)
rightRight operand (a video mode)
Returns:
True if left is greater or equal than right

Member Data Documentation

Video mode pixel depth, in bits per pixels.

Definition at line 104 of file VideoMode.hpp.

unsigned int sf::VideoMode::Height

Video mode height, in pixels.

Definition at line 103 of file VideoMode.hpp.

unsigned int sf::VideoMode::Width

Video mode width, in pixels.

Definition at line 102 of file VideoMode.hpp.


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