Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:58:15

0001 ////////////////////////////////////////////////////////////
0002 //
0003 // SFML - Simple and Fast Multimedia Library
0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
0005 //
0006 // This software is provided 'as-is', without any express or implied warranty.
0007 // In no event will the authors be held liable for any damages arising from the use of this software.
0008 //
0009 // Permission is granted to anyone to use this software for any purpose,
0010 // including commercial applications, and to alter it and redistribute it freely,
0011 // subject to the following restrictions:
0012 //
0013 // 1. The origin of this software must not be misrepresented;
0014 //    you must not claim that you wrote the original software.
0015 //    If you use this software in a product, an acknowledgment
0016 //    in the product documentation would be appreciated but is not required.
0017 //
0018 // 2. Altered source versions must be plainly marked as such,
0019 //    and must not be misrepresented as being the original software.
0020 //
0021 // 3. This notice may not be removed or altered from any source distribution.
0022 //
0023 ////////////////////////////////////////////////////////////
0024 
0025 #ifndef SFML_VIDEOMODE_HPP
0026 #define SFML_VIDEOMODE_HPP
0027 
0028 ////////////////////////////////////////////////////////////
0029 // Headers
0030 ////////////////////////////////////////////////////////////
0031 #include <SFML/Window/Export.hpp>
0032 #include <vector>
0033 
0034 
0035 namespace sf
0036 {
0037 ////////////////////////////////////////////////////////////
0038 /// \brief VideoMode defines a video mode (width, height, bpp)
0039 ///
0040 ////////////////////////////////////////////////////////////
0041 class SFML_WINDOW_API VideoMode
0042 {
0043 public:
0044 
0045     ////////////////////////////////////////////////////////////
0046     /// \brief Default constructor
0047     ///
0048     /// This constructors initializes all members to 0.
0049     ///
0050     ////////////////////////////////////////////////////////////
0051     VideoMode();
0052 
0053     ////////////////////////////////////////////////////////////
0054     /// \brief Construct the video mode with its attributes
0055     ///
0056     /// \param modeWidth        Width in pixels
0057     /// \param modeHeight       Height in pixels
0058     /// \param modeBitsPerPixel Pixel depths in bits per pixel
0059     ///
0060     ////////////////////////////////////////////////////////////
0061     VideoMode(unsigned int modeWidth, unsigned int modeHeight, unsigned int modeBitsPerPixel = 32);
0062 
0063     ////////////////////////////////////////////////////////////
0064     /// \brief Get the current desktop video mode
0065     ///
0066     /// \return Current desktop video mode
0067     ///
0068     ////////////////////////////////////////////////////////////
0069     static VideoMode getDesktopMode();
0070 
0071     ////////////////////////////////////////////////////////////
0072     /// \brief Retrieve all the video modes supported in fullscreen mode
0073     ///
0074     /// When creating a fullscreen window, the video mode is restricted
0075     /// to be compatible with what the graphics driver and monitor
0076     /// support. This function returns the complete list of all video
0077     /// modes that can be used in fullscreen mode.
0078     /// The returned array is sorted from best to worst, so that
0079     /// the first element will always give the best mode (higher
0080     /// width, height and bits-per-pixel).
0081     ///
0082     /// \return Array containing all the supported fullscreen modes
0083     ///
0084     ////////////////////////////////////////////////////////////
0085     static const std::vector<VideoMode>& getFullscreenModes();
0086 
0087     ////////////////////////////////////////////////////////////
0088     /// \brief Tell whether or not the video mode is valid
0089     ///
0090     /// The validity of video modes is only relevant when using
0091     /// fullscreen windows; otherwise any video mode can be used
0092     /// with no restriction.
0093     ///
0094     /// \return True if the video mode is valid for fullscreen mode
0095     ///
0096     ////////////////////////////////////////////////////////////
0097     bool isValid() const;
0098 
0099     ////////////////////////////////////////////////////////////
0100     // Member data
0101     ////////////////////////////////////////////////////////////
0102     unsigned int width;        //!< Video mode width, in pixels
0103     unsigned int height;       //!< Video mode height, in pixels
0104     unsigned int bitsPerPixel; //!< Video mode pixel depth, in bits per pixels
0105 };
0106 
0107 ////////////////////////////////////////////////////////////
0108 /// \relates VideoMode
0109 /// \brief Overload of == operator to compare two video modes
0110 ///
0111 /// \param left  Left operand (a video mode)
0112 /// \param right Right operand (a video mode)
0113 ///
0114 /// \return True if modes are equal
0115 ///
0116 ////////////////////////////////////////////////////////////
0117 SFML_WINDOW_API bool operator ==(const VideoMode& left, const VideoMode& right);
0118 
0119 ////////////////////////////////////////////////////////////
0120 /// \relates VideoMode
0121 /// \brief Overload of != operator to compare two video modes
0122 ///
0123 /// \param left  Left operand (a video mode)
0124 /// \param right Right operand (a video mode)
0125 ///
0126 /// \return True if modes are different
0127 ///
0128 ////////////////////////////////////////////////////////////
0129 SFML_WINDOW_API bool operator !=(const VideoMode& left, const VideoMode& right);
0130 
0131 ////////////////////////////////////////////////////////////
0132 /// \relates VideoMode
0133 /// \brief Overload of < operator to compare video modes
0134 ///
0135 /// \param left  Left operand (a video mode)
0136 /// \param right Right operand (a video mode)
0137 ///
0138 /// \return True if \a left is lesser than \a right
0139 ///
0140 ////////////////////////////////////////////////////////////
0141 SFML_WINDOW_API bool operator <(const VideoMode& left, const VideoMode& right);
0142 
0143 ////////////////////////////////////////////////////////////
0144 /// \relates VideoMode
0145 /// \brief Overload of > operator to compare video modes
0146 ///
0147 /// \param left  Left operand (a video mode)
0148 /// \param right Right operand (a video mode)
0149 ///
0150 /// \return True if \a left is greater than \a right
0151 ///
0152 ////////////////////////////////////////////////////////////
0153 SFML_WINDOW_API bool operator >(const VideoMode& left, const VideoMode& right);
0154 
0155 ////////////////////////////////////////////////////////////
0156 /// \relates VideoMode
0157 /// \brief Overload of <= operator to compare video modes
0158 ///
0159 /// \param left  Left operand (a video mode)
0160 /// \param right Right operand (a video mode)
0161 ///
0162 /// \return True if \a left is lesser or equal than \a right
0163 ///
0164 ////////////////////////////////////////////////////////////
0165 SFML_WINDOW_API bool operator <=(const VideoMode& left, const VideoMode& right);
0166 
0167 ////////////////////////////////////////////////////////////
0168 /// \relates VideoMode
0169 /// \brief Overload of >= operator to compare video modes
0170 ///
0171 /// \param left  Left operand (a video mode)
0172 /// \param right Right operand (a video mode)
0173 ///
0174 /// \return True if \a left is greater or equal than \a right
0175 ///
0176 ////////////////////////////////////////////////////////////
0177 SFML_WINDOW_API bool operator >=(const VideoMode& left, const VideoMode& right);
0178 
0179 } // namespace sf
0180 
0181 
0182 #endif // SFML_VIDEOMODE_HPP
0183 
0184 
0185 ////////////////////////////////////////////////////////////
0186 /// \class sf::VideoMode
0187 /// \ingroup window
0188 ///
0189 /// A video mode is defined by a width and a height (in pixels)
0190 /// and a depth (in bits per pixel). Video modes are used to
0191 /// setup windows (sf::Window) at creation time.
0192 ///
0193 /// The main usage of video modes is for fullscreen mode:
0194 /// indeed you must use one of the valid video modes
0195 /// allowed by the OS (which are defined by what the monitor
0196 /// and the graphics card support), otherwise your window
0197 /// creation will just fail.
0198 ///
0199 /// sf::VideoMode provides a static function for retrieving
0200 /// the list of all the video modes supported by the system:
0201 /// getFullscreenModes().
0202 ///
0203 /// A custom video mode can also be checked directly for
0204 /// fullscreen compatibility with its isValid() function.
0205 ///
0206 /// Additionally, sf::VideoMode provides a static function
0207 /// to get the mode currently used by the desktop: getDesktopMode().
0208 /// This allows to build windows with the same size or pixel
0209 /// depth as the current resolution.
0210 ///
0211 /// Usage example:
0212 /// \code
0213 /// // Display the list of all the video modes available for fullscreen
0214 /// std::vector<sf::VideoMode> modes = sf::VideoMode::getFullscreenModes();
0215 /// for (std::size_t i = 0; i < modes.size(); ++i)
0216 /// {
0217 ///     sf::VideoMode mode = modes[i];
0218 ///     std::cout << "Mode #" << i << ": "
0219 ///               << mode.width << "x" << mode.height << " - "
0220 ///               << mode.bitsPerPixel << " bpp" << std::endl;
0221 /// }
0222 ///
0223 /// // Create a window with the same pixel depth as the desktop
0224 /// sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
0225 /// window.create(sf::VideoMode(1024, 768, desktop.bitsPerPixel), "SFML window");
0226 /// \endcode
0227 ///
0228 ////////////////////////////////////////////////////////////