Merged VideoMode::GetMode and VideoMode::GetModesCount into a single new function VideoMode::GetFullscreenModes

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1453 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-03-12 14:07:28 +00:00
parent e924c9cf39
commit 809b09292f
21 changed files with 256 additions and 446 deletions

View file

@ -52,24 +52,15 @@ typedef struct
CSFML_API sfVideoMode sfVideoMode_GetDesktopMode();
////////////////////////////////////////////////////////////
/// Get a valid video mode
/// Index must be in range [0, GetModesCount()[
/// Modes are sorted from best to worst
/// Get all the supported video modes for fullscreen mode.
/// Modes are sorted from best to worst.
///
/// \param index : Index of video mode to get
/// \param Count : Variable that will be filled with the number of modes
///
/// \return Corresponding video mode (invalid mode if index is out of range)
/// \return Pointer to an array of \a count video modes
///
////////////////////////////////////////////////////////////
CSFML_API sfVideoMode sfVideoMode_GetMode(size_t index);
////////////////////////////////////////////////////////////
/// Get valid video modes count
///
/// \return Number of valid video modes available
///
////////////////////////////////////////////////////////////
CSFML_API size_t sfVideoMode_GetModesCount();
CSFML_API const sfVideoMode* sfVideoMode_GetFullscreenModes(size_t* Count);
////////////////////////////////////////////////////////////
/// Tell whether or not a video mode is supported

View file

@ -30,7 +30,6 @@
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Get the current desktop video mode
////////////////////////////////////////////////////////////
@ -47,28 +46,31 @@ sfVideoMode sfVideoMode_GetDesktopMode()
////////////////////////////////////////////////////////////
/// Get a valid video mode
/// Index must be in range [0, GetModesCount()[
/// Modes are sorted from best to worst
/// Get all the supported video modes for fullscreen mode.
/// Modes are sorted from best to worst.
////////////////////////////////////////////////////////////
sfVideoMode sfVideoMode_GetMode(size_t index)
const sfVideoMode* sfVideoMode_GetFullscreenModes(size_t* Count)
{
sf::VideoMode mode = sf::VideoMode::GetMode(index);
sfVideoMode ret;
ret.Width = mode.Width;
ret.Height = mode.Height;
ret.BitsPerPixel = mode.BitsPerPixel;
static std::vector<sfVideoMode> modes;
return ret;
}
// Populate the array on first call
if (modes.empty())
{
const std::vector<sf::VideoMode>& SFMLModes = sf::VideoMode::GetFullscreenModes();
for (std::vector<sf::VideoMode>::const_iterator it = SFMLModes.begin(); it != SFMLModes.end(); ++it)
{
sfVideoMode mode;
mode.Width = it->Width;
mode.Height = it->Height;
mode.BitsPerPixel = it->BitsPerPixel;
modes.push_back(mode);
}
}
if (Count)
*Count = modes.size();
////////////////////////////////////////////////////////////
/// Get valid video modes count
////////////////////////////////////////////////////////////
size_t sfVideoMode_GetModesCount()
{
return sf::VideoMode::GetModesCount();
return !modes.empty() ? &modes[0] : NULL;
}

View file

@ -7,8 +7,7 @@ EXPORTS
sfInput_GetMouseY
sfInput_GetJoystickAxis
sfVideoMode_GetDesktopMode
sfVideoMode_GetMode
sfVideoMode_GetModesCount
sfVideoMode_GetFullscreenModes
sfVideoMode_IsValid
sfWindow_Create
sfWindow_CreateFromHandle

View file

@ -7,8 +7,7 @@ EXPORTS
sfInput_GetMouseY
sfInput_GetJoystickAxis
sfVideoMode_GetDesktopMode
sfVideoMode_GetMode
sfVideoMode_GetModesCount
sfVideoMode_GetFullscreenModes
sfVideoMode_IsValid
sfWindow_Create
sfWindow_CreateFromHandle