diff --git a/CSFML/include/SFML/Window/VideoMode.h b/CSFML/include/SFML/Window/VideoMode.h index ebbd0dda5..43ac07024 100644 --- a/CSFML/include/SFML/Window/VideoMode.h +++ b/CSFML/include/SFML/Window/VideoMode.h @@ -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 diff --git a/CSFML/src/SFML/Window/VideoMode.cpp b/CSFML/src/SFML/Window/VideoMode.cpp index daba44b3e..ecec4e792 100644 --- a/CSFML/src/SFML/Window/VideoMode.cpp +++ b/CSFML/src/SFML/Window/VideoMode.cpp @@ -30,7 +30,6 @@ #include - //////////////////////////////////////////////////////////// /// 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 modes; - return ret; -} + // Populate the array on first call + if (modes.empty()) + { + const std::vector& SFMLModes = sf::VideoMode::GetFullscreenModes(); + for (std::vector::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; } diff --git a/CSFML/src/SFML/Window/csfml-window-d.def b/CSFML/src/SFML/Window/csfml-window-d.def index 8a32efd4d..2bb80c88b 100644 --- a/CSFML/src/SFML/Window/csfml-window-d.def +++ b/CSFML/src/SFML/Window/csfml-window-d.def @@ -7,8 +7,7 @@ EXPORTS sfInput_GetMouseY sfInput_GetJoystickAxis sfVideoMode_GetDesktopMode - sfVideoMode_GetMode - sfVideoMode_GetModesCount + sfVideoMode_GetFullscreenModes sfVideoMode_IsValid sfWindow_Create sfWindow_CreateFromHandle diff --git a/CSFML/src/SFML/Window/csfml-window.def b/CSFML/src/SFML/Window/csfml-window.def index 8b7f0b10b..2f6a2d573 100644 --- a/CSFML/src/SFML/Window/csfml-window.def +++ b/CSFML/src/SFML/Window/csfml-window.def @@ -7,8 +7,7 @@ EXPORTS sfInput_GetMouseY sfInput_GetJoystickAxis sfVideoMode_GetDesktopMode - sfVideoMode_GetMode - sfVideoMode_GetModesCount + sfVideoMode_GetFullscreenModes sfVideoMode_IsValid sfWindow_Create sfWindow_CreateFromHandle diff --git a/build/codeblocks/sfml-window.cbp b/build/codeblocks/sfml-window.cbp index 0d4e7dcb3..c7d0358cc 100644 --- a/build/codeblocks/sfml-window.cbp +++ b/build/codeblocks/sfml-window.cbp @@ -124,13 +124,12 @@ - + - - + diff --git a/build/vc2005/sfml-window.vcproj b/build/vc2005/sfml-window.vcproj index 37de6465d..b07ad2a13 100644 --- a/build/vc2005/sfml-window.vcproj +++ b/build/vc2005/sfml-window.vcproj @@ -400,11 +400,7 @@ > - - - - - /// Get the number of valid video modes + /// Get the list of all the supported fullscreen video modes /// //////////////////////////////////////////////////////////// - public static uint ModesCount + public static VideoMode[] FullscreenModes { - get {return sfVideoMode_GetModesCount();} - } + get + { + unsafe + { + uint Count; + VideoMode* ModesPtr = sfVideoMode_GetFullscreenModes(out Count); + VideoMode[] Modes = new VideoMode[Count]; + for (uint i = 0; i < Count; ++i) + Modes[i] = ModesPtr[i]; - //////////////////////////////////////////////////////////// - /// - /// Get a valid video mode. - /// Index must be in range [0, ModesCount[. - /// Modes are sorted from best to worst - /// - /// Index of the video mode to get - /// index-th video mode - //////////////////////////////////////////////////////////// - public static VideoMode GetMode(uint index) - { - return sfVideoMode_GetMode(index); + return Modes; + } + } } //////////////////////////////////////////////////////////// @@ -116,10 +114,7 @@ namespace SFML static extern VideoMode sfVideoMode_GetDesktopMode(); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] - static extern uint sfVideoMode_GetModesCount(); - - [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] - static extern VideoMode sfVideoMode_GetMode(uint Index); + unsafe static extern VideoMode* sfVideoMode_GetFullscreenModes(out uint Count); [DllImport("csfml-window"), SuppressUnmanagedCodeSecurity] static extern bool sfVideoMode_IsValid(VideoMode Mode); diff --git a/include/SFML/Window/VideoMode.hpp b/include/SFML/Window/VideoMode.hpp index d855d5847..183bf90f7 100644 --- a/include/SFML/Window/VideoMode.hpp +++ b/include/SFML/Window/VideoMode.hpp @@ -29,7 +29,7 @@ // Headers //////////////////////////////////////////////////////////// #include -#include +#include namespace sf @@ -69,30 +69,20 @@ public : static VideoMode GetDesktopMode(); //////////////////////////////////////////////////////////// - /// \brief Get a valid video mode + /// \brief Retrieve all the video modes supported in fullscreen mode /// - /// The parameter \a 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. + /// 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). /// - /// \param index Index of video mode to get - /// - /// \return Corresponding video mode (invalid mode if index is out of range) + /// \return Array containing all the supported fullscreen modes /// //////////////////////////////////////////////////////////// - static VideoMode GetMode(std::size_t index); - - //////////////////////////////////////////////////////////// - /// \brief 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. - /// - /// \return Number of valid video modes available for fullscreen mode - /// - //////////////////////////////////////////////////////////// - static std::size_t GetModesCount(); + static const std::vector& GetFullscreenModes(); //////////////////////////////////////////////////////////// /// \brief Tell whether or not the video mode is valid @@ -115,13 +105,10 @@ public : }; //////////////////////////////////////////////////////////// -/// \brief Overload of binary == operator +/// \brief Overload of == operator to compare two video modes /// -/// This operator compares strict equality between two modes, -/// i.e. it checks if all their members are equal. -/// -/// \param left Left operand -/// \param right Right operand +/// \param left Left operand (a video mode) +/// \param right Right operand (a video mode) /// /// \return True if modes are equal /// @@ -129,19 +116,60 @@ public : SFML_API bool operator ==(const VideoMode& left, const VideoMode& right); //////////////////////////////////////////////////////////// -/// \brief Overload of binary != operator +/// \brief Overload of != operator to compare two video modes /// -/// This operator compares strict difference between two modes, -/// i.e. it checks if not all their members are equal. -/// -/// \param left Left operand -/// \param right Right operand +/// \param left Left operand (a video mode) +/// \param right Right operand (a video mode) /// /// \return True if modes are different /// //////////////////////////////////////////////////////////// SFML_API bool operator !=(const VideoMode& left, const VideoMode& right); +//////////////////////////////////////////////////////////// +/// \brief Overload of < operator to compare video modes +/// +/// \param left Left operand (a video mode) +/// \param right Right operand (a video mode) +/// +/// \return True if \a left is lesser than \a right +/// +//////////////////////////////////////////////////////////// +SFML_API bool operator <(const VideoMode& left, const VideoMode& right); + +//////////////////////////////////////////////////////////// +/// \brief Overload of > operator to compare video modes +/// +/// \param left Left operand (a video mode) +/// \param right Right operand (a video mode) +/// +/// \return True if \a left is greater than \a right +/// +//////////////////////////////////////////////////////////// +SFML_API bool operator >(const VideoMode& left, const VideoMode& right); + +//////////////////////////////////////////////////////////// +/// \brief Overload of <= operator to compare video modes +/// +/// \param left Left operand (a video mode) +/// \param right Right operand (a video mode) +/// +/// \return True if \a left is lesser or equal than \a right +/// +//////////////////////////////////////////////////////////// +SFML_API bool operator <=(const VideoMode& left, const VideoMode& right); + +//////////////////////////////////////////////////////////// +/// \brief Overload of >= operator to compare video modes +/// +/// \param left Left operand (a video mode) +/// \param right Right operand (a video mode) +/// +/// \return True if \a left is greater or equal than \a right +/// +//////////////////////////////////////////////////////////// +SFML_API bool operator >=(const VideoMode& left, const VideoMode& right); + } // namespace sf @@ -161,14 +189,12 @@ SFML_API bool operator !=(const VideoMode& left, const VideoMode& right); /// and the graphics card support), otherwise your window /// creation will just fail. /// -/// sf::VideoMode provides two static functions for retrieving +/// sf::VideoMode provides a static function 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. +/// GetFullscreenModes(). /// -/// A custom video mode can also be checked directly with -/// its IsValid() function. +/// 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(). @@ -178,9 +204,10 @@ SFML_API bool operator !=(const VideoMode& left, const VideoMode& right); /// Usage example: /// \code /// // Display the list of all the video modes available for fullscreen -/// for (std::size_t i = 0; i < sf::VideoMode::GetModesCount(); ++i) +/// std::vector modes = sf::VideoMode::GetFullscreenModes(); +/// for (std::size_t i = 0; i < modes.size(); ++i) /// { -/// sf::VideoMode mode = sf::VideoMode::GetMode(i); +/// sf::VideoMode mode = modes[i]; /// std::cout << "Mode #" << i << ": " /// << mode.Width << "x" << mode.Height << " - " /// << mode.BitsPerPixel << " bpp" << std::endl; diff --git a/src/SFML/Window/Cocoa/VideoModeSupport.cpp b/src/SFML/Window/Cocoa/VideoModeImpl.cpp similarity index 98% rename from src/SFML/Window/Cocoa/VideoModeSupport.cpp rename to src/SFML/Window/Cocoa/VideoModeImpl.cpp index 9b5ebd016..747c9cae2 100644 --- a/src/SFML/Window/Cocoa/VideoModeSupport.cpp +++ b/src/SFML/Window/Cocoa/VideoModeImpl.cpp @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include +#include #include #include diff --git a/src/SFML/Window/Linux/VideoModeSupport.cpp b/src/SFML/Window/Linux/VideoModeImpl.cpp similarity index 96% rename from src/SFML/Window/Linux/VideoModeSupport.cpp rename to src/SFML/Window/Linux/VideoModeImpl.cpp index bb91c9078..32b5ad36d 100644 --- a/src/SFML/Window/Linux/VideoModeSupport.cpp +++ b/src/SFML/Window/Linux/VideoModeImpl.cpp @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include +#include #include #include #include @@ -37,10 +37,9 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) +std::vector VideoModeImpl::GetFullscreenModes() { - // First, clear array to fill - modes.clear(); + std::vector modes; // Open a connection with the X server Display* disp = XOpenDisplay(NULL); @@ -106,11 +105,13 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) // We couldn't connect to the X server Err() << "Failed to connect to the X server while trying to get the supported video modes" << std::endl; } + + return modes; } //////////////////////////////////////////////////////////// -VideoMode VideoModeSupport::GetDesktopVideoMode() +VideoMode VideoModeImpl::GetDesktopMode() { VideoMode desktopMode; diff --git a/src/SFML/Window/Linux/VideoModeSupport.hpp b/src/SFML/Window/Linux/VideoModeSupport.hpp deleted file mode 100644 index c0207c0df..000000000 --- a/src/SFML/Window/Linux/VideoModeSupport.hpp +++ /dev/null @@ -1,69 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef SFML_VIDEOMODESUPPORTLINUX_HPP -#define SFML_VIDEOMODESUPPORTLINUX_HPP - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include - - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// \brief Linux (X11) implementation of VideoModeSupport; -/// gives access to video mode related OS-specific functions -//////////////////////////////////////////////////////////// -class VideoModeSupport -{ -public : - - //////////////////////////////////////////////////////////// - /// \brief Get the list of all the supported video modes - /// - /// \param modes Array to fill with available video modes - /// - //////////////////////////////////////////////////////////// - static void GetSupportedVideoModes(std::vector& modes); - - //////////////////////////////////////////////////////////// - /// \brief Get the current desktop video mode - /// - /// \return Current desktop video mode - /// - //////////////////////////////////////////////////////////// - static VideoMode GetDesktopVideoMode(); -}; - -} // namespace priv - -} // namespace sf - - -#endif // SFML_VIDEOMODESUPPORTLINUX_HPP diff --git a/src/SFML/Window/VideoMode.cpp b/src/SFML/Window/VideoMode.cpp index 62fdf808f..71e6205c4 100644 --- a/src/SFML/Window/VideoMode.cpp +++ b/src/SFML/Window/VideoMode.cpp @@ -26,47 +26,9 @@ // Headers //////////////////////////////////////////////////////////// #include -#include +#include #include -#include - - -//////////////////////////////////////////////////////////// -/// Private data -//////////////////////////////////////////////////////////// -namespace -{ - // Global array of supported video modes - std::vector supportedModes; - - // Functor for sorting modes from highest to lowest - struct CompareModes - { - bool operator ()(const sf::VideoMode& left, const sf::VideoMode& right) const - { - if (left.BitsPerPixel > right.BitsPerPixel) - return true; - else if (left.BitsPerPixel < right.BitsPerPixel) - return false; - else if (left.Width > right.Width) - return true; - else if (left.Width < right.Width) - return false; - else - return (left.Height > right.Height); - } - }; - - // Get and sort valid video modes - static void InitializeModes() - { - // We request the array of valid modes - sf::priv::VideoModeSupport::GetSupportedVideoModes(supportedModes); - - // And we sort them from highest to lowest (so that number 0 is the best) - std::sort(supportedModes.begin(), supportedModes.end(), CompareModes()); - } -} +#include namespace sf @@ -94,44 +56,33 @@ BitsPerPixel(bitsPerPixel) //////////////////////////////////////////////////////////// VideoMode VideoMode::GetDesktopMode() { - // Directly forward to the video mode support - return priv::VideoModeSupport::GetDesktopVideoMode(); + // Directly forward to the OS-specific implementation + return priv::VideoModeImpl::GetDesktopMode(); } //////////////////////////////////////////////////////////// -VideoMode VideoMode::GetMode(std::size_t index) +const std::vector& VideoMode::GetFullscreenModes() { - // Build and cache the list of valid modes on first call - if (supportedModes.empty()) - InitializeModes(); + static std::vector modes; - if (index < GetModesCount()) - return supportedModes[index]; - else - return VideoMode(); -} + // Populate the array on first call + if (modes.empty()) + { + modes = priv::VideoModeImpl::GetFullscreenModes(); + std::sort(modes.begin(), modes.end(), std::greater()); + } - -//////////////////////////////////////////////////////////// -std::size_t VideoMode::GetModesCount() -{ - // Build and cache the list of valid modes on first call - if (supportedModes.empty()) - InitializeModes(); - - return supportedModes.size(); + return modes; } //////////////////////////////////////////////////////////// bool VideoMode::IsValid() const { - // Build and cache the list of valid modes on first call - if (supportedModes.empty()) - InitializeModes(); + const std::vector& modes = GetFullscreenModes(); - return std::find(supportedModes.begin(), supportedModes.end(), *this) != supportedModes.end(); + return std::find(modes.begin(), modes.end(), *this) != modes.end(); } @@ -150,4 +101,46 @@ bool operator !=(const VideoMode& left, const VideoMode& right) return !(left == right); } + +//////////////////////////////////////////////////////////// +bool operator <(const VideoMode& left, const VideoMode& right) +{ + if (left.BitsPerPixel == right.BitsPerPixel) + { + if (left.Width == right.Width) + { + return left.Height < right.Height; + } + else + { + return left.Width < right.Width; + } + } + else + { + return left.BitsPerPixel < right.BitsPerPixel; + } +} + + +//////////////////////////////////////////////////////////// +bool operator >(const VideoMode& left, const VideoMode& right) +{ + return right < left; +} + + +//////////////////////////////////////////////////////////// +bool operator <=(const VideoMode& left, const VideoMode& right) +{ + return !(right < left); +} + + +//////////////////////////////////////////////////////////// +bool operator >=(const VideoMode& left, const VideoMode& right) +{ + return !(left < right); +} + } // namespace sf diff --git a/src/SFML/Window/Cocoa/VideoModeSupport.hpp b/src/SFML/Window/VideoModeImpl.hpp similarity index 77% rename from src/SFML/Window/Cocoa/VideoModeSupport.hpp rename to src/SFML/Window/VideoModeImpl.hpp index 4892fe549..8075b5f08 100644 --- a/src/SFML/Window/Cocoa/VideoModeSupport.hpp +++ b/src/SFML/Window/VideoModeImpl.hpp @@ -1,69 +1,68 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef SFML_VIDEOMODESUPPORTCOCOA_HPP -#define SFML_VIDEOMODESUPPORTCOCOA_HPP - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include - - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// Cocoa implementation of VideoModeSupport -/// Give access to video mode related OS-specific functions -//////////////////////////////////////////////////////////// -class VideoModeSupport -{ -public : - - //////////////////////////////////////////////////////////// - /// Get supported video modes - /// - /// \param Modes : Array to fill with available video modes - /// - //////////////////////////////////////////////////////////// - static void GetSupportedVideoModes(std::vector& Modes); - - //////////////////////////////////////////////////////////// - /// Get current desktop video mode - /// - /// \return Current desktop video mode - /// - //////////////////////////////////////////////////////////// - static VideoMode GetDesktopVideoMode(); -}; - -} // namespace priv - -} // namespace sf - - -#endif // SFML_VIDEOMODESUPPORTCOCOA_HPP +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_VIDEOMODEIMPL_HPP +#define SFML_VIDEOMODEIMPL_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +/// \brief OS-specific implementation of video modes functions +/// +//////////////////////////////////////////////////////////// +class VideoModeImpl +{ +public : + + //////////////////////////////////////////////////////////// + /// \brief Get the list of all the supported fullscreen video modes + /// + /// \return Array filled with the fullscreen video modes + /// + //////////////////////////////////////////////////////////// + static std::vector GetFullscreenModes(); + + //////////////////////////////////////////////////////////// + /// \brief Get the current desktop video mode + /// + /// \return Current desktop video mode + /// + //////////////////////////////////////////////////////////// + static VideoMode GetDesktopMode(); +}; + +} // namespace priv + +} // namespace sf + + +#endif // SFML_VIDEOMODEIMPL_HPP diff --git a/src/SFML/Window/VideoModeSupport.hpp b/src/SFML/Window/VideoModeSupport.hpp deleted file mode 100644 index caa94aa93..000000000 --- a/src/SFML/Window/VideoModeSupport.hpp +++ /dev/null @@ -1,49 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef SFML_VIDEOMODESUPPORT_HPP -#define SFML_VIDEOMODESUPPORT_HPP - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - - -#if defined(SFML_SYSTEM_WINDOWS) - - #include - -#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) - - #include - -#elif defined(SFML_SYSTEM_MACOS) - - #include - -#endif - - -#endif // SFML_VIDEOMODESUPPORT_HPP diff --git a/src/SFML/Window/Win32/VideoModeSupport.cpp b/src/SFML/Window/Win32/VideoModeImpl.cpp similarity index 88% rename from src/SFML/Window/Win32/VideoModeSupport.cpp rename to src/SFML/Window/Win32/VideoModeImpl.cpp index c80eba603..1acc43406 100644 --- a/src/SFML/Window/Win32/VideoModeSupport.cpp +++ b/src/SFML/Window/Win32/VideoModeImpl.cpp @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// -#include +#include #include #include @@ -35,10 +35,9 @@ namespace sf namespace priv { //////////////////////////////////////////////////////////// -void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) +std::vector VideoModeImpl::GetFullscreenModes() { - // First, clear array to fill - modes.clear(); + std::vector modes; // Enumerate all available video modes for the primary display adapter DEVMODE win32Mode; @@ -52,11 +51,13 @@ void VideoModeSupport::GetSupportedVideoModes(std::vector& modes) if (std::find(modes.begin(), modes.end(), mode) == modes.end()) modes.push_back(mode); } + + return modes; } //////////////////////////////////////////////////////////// -VideoMode VideoModeSupport::GetDesktopVideoMode() +VideoMode VideoModeImpl::GetDesktopMode() { DEVMODE win32Mode; win32Mode.dmSize = sizeof(win32Mode); diff --git a/src/SFML/Window/Win32/VideoModeSupport.hpp b/src/SFML/Window/Win32/VideoModeSupport.hpp deleted file mode 100644 index d3e5fb560..000000000 --- a/src/SFML/Window/Win32/VideoModeSupport.hpp +++ /dev/null @@ -1,70 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2008 Laurent Gomila (laurent.gom@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef SFML_VIDEOMODESUPPORTWIN32_HPP -#define SFML_VIDEOMODESUPPORTWIN32_HPP - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include - - -namespace sf -{ -namespace priv -{ -//////////////////////////////////////////////////////////// -/// \brief Windows implementation of VideoModeSupport; -/// gives access to video mode related OS-specific functions -/// -//////////////////////////////////////////////////////////// -class VideoModeSupport -{ -public : - - //////////////////////////////////////////////////////////// - /// \brief Get the list of all the supported video modes - /// - /// \param modes Array to fill with available video modes - /// - //////////////////////////////////////////////////////////// - static void GetSupportedVideoModes(std::vector& modes); - - //////////////////////////////////////////////////////////// - /// \brief Get the current desktop video mode - /// - /// \return Current desktop video mode - /// - //////////////////////////////////////////////////////////// - static VideoMode GetDesktopVideoMode(); -}; - -} // namespace priv - -} // namespace sf - - -#endif // SFML_VIDEOMODESUPPORTWIN32_HPP diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 071a1326c..f2c286e80 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -109,11 +109,11 @@ void Window::Create(VideoMode mode, const std::string& title, unsigned long styl } else { - // Make sure the chosen video mode is compatible + // Make sure that the chosen video mode is compatible if (!mode.IsValid()) { Err() << "The requested video mode is not available, switching to a valid mode" << std::endl; - mode = VideoMode::GetMode(0); + mode = VideoMode::GetFullscreenModes()[0]; } // Update the fullscreen window