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 VideoMode GetMode (std::size_t index)
 Get a valid video mode.
static std::size_t GetModesCount ()
 Get the total number of valid video modes available.

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.

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 two static functions for retrieving the list of all the video modes supported by the system: GetModesCount() to get the number of video modes in the list, and GetMode() to retrieve a particular mode from the list.

A custom video mode can also be checked directly 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
 for (std::size_t i = 0; i < sf::VideoMode::GetModesCount(); ++i)
 {
     sf::VideoMode mode = sf::VideoMode::GetMode(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.

Definition at line 75 of file VideoMode.cpp.

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

Construct the video mode with its attributes.

Parameters:
width Width in pixels
height Height in pixels
bitsPerPixel Pixel depths in bits per pixel

Definition at line 85 of file VideoMode.cpp.


Member Function Documentation

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

Get the current desktop video mode.

Returns:
Current desktop video mode

Definition at line 95 of file VideoMode.cpp.

VideoMode sf::VideoMode::GetMode ( std::size_t  index  )  [static]

Get a valid video mode.

The parameter index must be in the range [0, GetModesCount()[. Modes are sorted from best to worst, so that sf::VideoMode::GetMode(0) will always give the best.

Parameters:
index Index of video mode to get
Returns:
Corresponding video mode (invalid mode if index is out of range)

Definition at line 103 of file VideoMode.cpp.

std::size_t sf::VideoMode::GetModesCount (  )  [static]

Get the total number of valid video modes available.

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

Returns:
Number of valid video modes available for fullscreen mode

Definition at line 117 of file VideoMode.cpp.

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

Definition at line 128 of file VideoMode.cpp.


Member Data Documentation

Video mode pixel depth, in bits per pixels.

Definition at line 114 of file VideoMode.hpp.

unsigned int sf::VideoMode::Height

Video mode height, in pixels.

Definition at line 113 of file VideoMode.hpp.

unsigned int sf::VideoMode::Width

Video mode width, in pixels.

Definition at line 112 of file VideoMode.hpp.


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