diff options
author | James Cowgill <jcowgill@debian.org> | 2016-08-09 15:20:03 +0000 |
---|---|---|
committer | James Cowgill <jcowgill@debian.org> | 2016-08-09 15:20:03 +0000 |
commit | df93e238e30e97850d76ad5585b8ab9ad9c03e67 (patch) | |
tree | 2ae5f3305e1ee1882f563d2803f94aa6446dc367 /include | |
parent | 301fd78b3ac87cf1fbce9d2c955db89094a304a5 (diff) |
Imported Upstream version 2.4.0+dfsg
Diffstat (limited to 'include')
103 files changed, 1409 insertions, 361 deletions
diff --git a/include/SFML/Audio.hpp b/include/SFML/Audio.hpp index 41737cf..43a4a75 100644 --- a/include/SFML/Audio.hpp +++ b/include/SFML/Audio.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/AlResource.hpp b/include/SFML/Audio/AlResource.hpp index ca5d2c0..d925314 100644 --- a/include/SFML/Audio/AlResource.hpp +++ b/include/SFML/Audio/AlResource.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/Export.hpp b/include/SFML/Audio/Export.hpp index 1ea6f42..3269041 100644 --- a/include/SFML/Audio/Export.hpp +++ b/include/SFML/Audio/Export.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/InputSoundFile.hpp b/include/SFML/Audio/InputSoundFile.hpp index 5e306ae..e59f2a2 100644 --- a/include/SFML/Audio/InputSoundFile.hpp +++ b/include/SFML/Audio/InputSoundFile.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -62,7 +62,8 @@ public: //////////////////////////////////////////////////////////// /// \brief Open a sound file from the disk for reading /// - /// The supported audio formats are: WAV, OGG/Vorbis, FLAC. + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. /// /// \param filename Path of the sound file to load /// @@ -74,7 +75,8 @@ public: //////////////////////////////////////////////////////////// /// \brief Open a sound file in memory for reading /// - /// The supported audio formats are: WAV, OGG/Vorbis, FLAC. + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. /// /// \param data Pointer to the file data in memory /// \param sizeInBytes Size of the data to load, in bytes @@ -87,7 +89,8 @@ public: //////////////////////////////////////////////////////////// /// \brief Open a sound file from a custom stream for reading /// - /// The supported audio formats are: WAV, OGG/Vorbis, FLAC. + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. /// /// \param stream Source stream to read from /// @@ -150,6 +153,9 @@ public: /// precision. If you need to jump to a given time, use the /// other overload. /// + /// The sample offset takes the channels into account. + /// Offsets can be calculated like this: + /// `sampleNumber * sampleRate * channelCount` /// If the given offset exceeds to total number of samples, /// this function jumps to the end of the sound file. /// diff --git a/include/SFML/Audio/Listener.hpp b/include/SFML/Audio/Listener.hpp index 04e4af3..a9b1817 100644 --- a/include/SFML/Audio/Listener.hpp +++ b/include/SFML/Audio/Listener.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/Music.hpp b/include/SFML/Audio/Music.hpp index 76b4254..1dc0e0c 100644 --- a/include/SFML/Audio/Music.hpp +++ b/include/SFML/Audio/Music.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/OutputSoundFile.hpp b/include/SFML/Audio/OutputSoundFile.hpp index 8f60498..8c50bd1 100644 --- a/include/SFML/Audio/OutputSoundFile.hpp +++ b/include/SFML/Audio/OutputSoundFile.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/Sound.hpp b/include/SFML/Audio/Sound.hpp index 8b0771d..fb78677 100644 --- a/include/SFML/Audio/Sound.hpp +++ b/include/SFML/Audio/Sound.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/SoundBuffer.hpp b/include/SFML/Audio/SoundBuffer.hpp index 42eda6f..0a155ab 100644 --- a/include/SFML/Audio/SoundBuffer.hpp +++ b/include/SFML/Audio/SoundBuffer.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/SoundBufferRecorder.hpp b/include/SFML/Audio/SoundBufferRecorder.hpp index 7715ac5..cb27afc 100644 --- a/include/SFML/Audio/SoundBufferRecorder.hpp +++ b/include/SFML/Audio/SoundBufferRecorder.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -46,6 +46,12 @@ class SFML_AUDIO_API SoundBufferRecorder : public SoundRecorder public: //////////////////////////////////////////////////////////// + /// \brief destructor + /// + //////////////////////////////////////////////////////////// + ~SoundBufferRecorder(); + + //////////////////////////////////////////////////////////// /// \brief Get the sound buffer containing the captured audio data /// /// The sound buffer is valid only after the capture has ended. diff --git a/include/SFML/Audio/SoundFileFactory.hpp b/include/SFML/Audio/SoundFileFactory.hpp index bd346cc..be8dd56 100644 --- a/include/SFML/Audio/SoundFileFactory.hpp +++ b/include/SFML/Audio/SoundFileFactory.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/SoundFileFactory.inl b/include/SFML/Audio/SoundFileFactory.inl index 19d334b..c5bba65 100644 --- a/include/SFML/Audio/SoundFileFactory.inl +++ b/include/SFML/Audio/SoundFileFactory.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/SoundFileReader.hpp b/include/SFML/Audio/SoundFileReader.hpp index 549f50b..84aa606 100644 --- a/include/SFML/Audio/SoundFileReader.hpp +++ b/include/SFML/Audio/SoundFileReader.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -79,6 +79,9 @@ public: //////////////////////////////////////////////////////////// /// \brief Change the current read position to the given sample offset /// + /// The sample offset takes the channels into account. + /// Offsets can be calculated like this: + /// `sampleNumber * sampleRate * channelCount` /// If the given offset exceeds to total number of samples, /// this function must jump to the end of the file. /// diff --git a/include/SFML/Audio/SoundFileWriter.hpp b/include/SFML/Audio/SoundFileWriter.hpp index 36a2678..72b99ea 100644 --- a/include/SFML/Audio/SoundFileWriter.hpp +++ b/include/SFML/Audio/SoundFileWriter.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Audio/SoundRecorder.hpp b/include/SFML/Audio/SoundRecorder.hpp index 964e4f3..d23e3e5 100644 --- a/include/SFML/Audio/SoundRecorder.hpp +++ b/include/SFML/Audio/SoundRecorder.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -145,6 +145,34 @@ public: const std::string& getDevice() const; //////////////////////////////////////////////////////////// + /// \brief Set the channel count of the audio capture device + /// + /// This method allows you to specify the number of channels + /// used for recording. Currently only 16-bit mono and + /// 16-bit stereo are supported. + /// + /// \param channelCount Number of channels. Currently only + /// mono (1) and stereo (2) are supported. + /// + /// \see getChannelCount + /// + //////////////////////////////////////////////////////////// + void setChannelCount(unsigned int channelCount); + + //////////////////////////////////////////////////////////// + /// \brief Get the number of channels used by this recorder + /// + /// Currently only mono and stereo are supported, so the + /// value is either 1 (for mono) or 2 (for stereo). + /// + /// \return Number of channels + /// + /// \see setChannelCount + /// + //////////////////////////////////////////////////////////// + unsigned int getChannelCount() const; + + //////////////////////////////////////////////////////////// /// \brief Check if the system supports audio capture /// /// This function should always be called before using @@ -263,6 +291,7 @@ private: Time m_processingInterval; ///< Time period between calls to onProcessSamples bool m_isCapturing; ///< Capturing state std::string m_deviceName; ///< Name of the audio capture device + unsigned int m_channelCount; ///< Number of recording channels }; } // namespace sf @@ -309,6 +338,12 @@ private: /// by calling setDevice() with the appropriate device. Otherwise /// the default capturing device will be used. /// +/// By default the recording is in 16-bit mono. Using the +/// setChannelCount method you can change the number of channels +/// used by the audio capture device to record. Note that you +/// have to decide whether you want to record in mono or stereo +/// before starting the recording. +/// /// It is important to note that the audio capture happens in a /// separate thread, so that it doesn't block the rest of the /// program. In particular, the onProcessSamples virtual function @@ -316,11 +351,20 @@ private: /// from this separate thread. It is important to keep this in /// mind, because you may have to take care of synchronization /// issues if you share data between threads. +/// Another thing to bear in mind is that you must call stop() +/// in the destructor of your derived class, so that the recording +/// thread finishes before your object is destroyed. /// /// Usage example: /// \code /// class CustomRecorder : public sf::SoundRecorder /// { +/// ~CustomRecorder() +/// { +/// // Make sure to stop the recording thread +/// stop(); +/// } +/// /// virtual bool onStart() // optional /// { /// // Initialize whatever has to be done before the capture starts diff --git a/include/SFML/Audio/SoundSource.hpp b/include/SFML/Audio/SoundSource.hpp index cde0a3b..83d5e8c 100644 --- a/include/SFML/Audio/SoundSource.hpp +++ b/include/SFML/Audio/SoundSource.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -240,6 +240,16 @@ public: //////////////////////////////////////////////////////////// float getAttenuation() const; + //////////////////////////////////////////////////////////// + /// \brief Overload of assignment operator + /// + /// \param right Instance to assign + /// + /// \return Reference to self + /// + //////////////////////////////////////////////////////////// + SoundSource& operator =(const SoundSource& right); + protected: //////////////////////////////////////////////////////////// diff --git a/include/SFML/Audio/SoundStream.hpp b/include/SFML/Audio/SoundStream.hpp index 22ae8cd..a2d7cb9 100644 --- a/include/SFML/Audio/SoundStream.hpp +++ b/include/SFML/Audio/SoundStream.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 05c7719..497ef67 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -30,8 +30,8 @@ // Define the SFML version //////////////////////////////////////////////////////////// #define SFML_VERSION_MAJOR 2 -#define SFML_VERSION_MINOR 3 -#define SFML_VERSION_PATCH 2 +#define SFML_VERSION_MINOR 4 +#define SFML_VERSION_PATCH 0 //////////////////////////////////////////////////////////// @@ -158,6 +158,44 @@ //////////////////////////////////////////////////////////// +// Cross-platform warning for deprecated functions and classes +// +// Usage: +// class SFML_DEPRECATED MyClass +// { +// SFML_DEPRECATED void memberFunc(); +// }; +// +// SFML_DEPRECATED void globalFunc(); +//////////////////////////////////////////////////////////// +#if defined(SFML_NO_DEPRECATED_WARNINGS) + + // User explicitly requests to disable deprecation warnings + #define SFML_DEPRECATED + +#elif defined(_MSC_VER) + + // Microsoft C++ compiler + // Note: On newer MSVC versions, using deprecated functions causes a compiler error. In order to + // trigger a warning instead of an error, the compiler flag /sdl- (instead of /sdl) must be specified. + #define SFML_DEPRECATED __declspec(deprecated) + +#elif defined(__GNUC__) + + // g++ and Clang + #define SFML_DEPRECATED __attribute__ ((deprecated)) + +#else + + // Other compilers are not supported, leave class or function as-is. + // With a bit of luck, the #pragma directive works, otherwise users get a warning (no error!) for unrecognized #pragma. + #pragma message("SFML_DEPRECATED is not supported for your compiler, please contact the SFML team") + #define SFML_DEPRECATED + +#endif + + +//////////////////////////////////////////////////////////// // Define portable fixed-size types //////////////////////////////////////////////////////////// namespace sf diff --git a/include/SFML/Graphics.hpp b/include/SFML/Graphics.hpp index 7a7f4da..6bcf299 100644 --- a/include/SFML/Graphics.hpp +++ b/include/SFML/Graphics.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/BlendMode.hpp b/include/SFML/Graphics/BlendMode.hpp index 7f5803b..76aa72c 100644 --- a/include/SFML/Graphics/BlendMode.hpp +++ b/include/SFML/Graphics/BlendMode.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -68,8 +68,9 @@ struct SFML_GRAPHICS_API BlendMode //////////////////////////////////////////////////////// enum Equation { - Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor - Subtract ///< Pixel = Src * SrcFactor - Dst * DstFactor + Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor + Subtract, ///< Pixel = Src * SrcFactor - Dst * DstFactor + ReverseSubtract ///< Pixel = Dst * DstFactor - Src * SrcFactor }; //////////////////////////////////////////////////////////// @@ -201,7 +202,7 @@ SFML_GRAPHICS_API extern const BlendMode BlendNone; ///< Overwrite dest with /// \code /// sf::BlendMode alphaBlending = sf::BlendAlpha; /// sf::BlendMode additiveBlending = sf::BlendAdd; -/// sf::BlendMode multiplicativeBlending = sf::BlendMultipy; +/// sf::BlendMode multiplicativeBlending = sf::BlendMultiply; /// sf::BlendMode noBlending = sf::BlendNone; /// \endcode /// diff --git a/include/SFML/Graphics/CircleShape.hpp b/include/SFML/Graphics/CircleShape.hpp index 2d5ac00..018a52a 100644 --- a/include/SFML/Graphics/CircleShape.hpp +++ b/include/SFML/Graphics/CircleShape.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Color.hpp b/include/SFML/Graphics/Color.hpp index 87a1598..ff35de5 100644 --- a/include/SFML/Graphics/Color.hpp +++ b/include/SFML/Graphics/Color.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/ConvexShape.hpp b/include/SFML/Graphics/ConvexShape.hpp index 82991a7..5c548a8 100644 --- a/include/SFML/Graphics/ConvexShape.hpp +++ b/include/SFML/Graphics/ConvexShape.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Drawable.hpp b/include/SFML/Graphics/Drawable.hpp index 5ddf2da..9ade3bc 100644 --- a/include/SFML/Graphics/Drawable.hpp +++ b/include/SFML/Graphics/Drawable.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Export.hpp b/include/SFML/Graphics/Export.hpp index 624f1eb..d11f419 100644 --- a/include/SFML/Graphics/Export.hpp +++ b/include/SFML/Graphics/Export.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Font.hpp b/include/SFML/Graphics/Font.hpp index ac6b00e..1420b70 100644 --- a/include/SFML/Graphics/Font.hpp +++ b/include/SFML/Graphics/Font.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -166,14 +166,18 @@ public: /// might be available. If the glyph is not available at the /// requested size, an empty glyph is returned. /// - /// \param codePoint Unicode code point of the character to get - /// \param characterSize Reference character size - /// \param bold Retrieve the bold version or the regular one? + /// Be aware that using a negative value for the outline + /// thickness will cause distorted rendering. + /// + /// \param codePoint Unicode code point of the character to get + /// \param characterSize Reference character size + /// \param bold Retrieve the bold version or the regular one? + /// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled) /// /// \return The glyph corresponding to \a codePoint and \a characterSize /// //////////////////////////////////////////////////////////// - const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const; + const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness = 0) const; //////////////////////////////////////////////////////////// /// \brief Get the kerning offset of two glyphs @@ -277,7 +281,7 @@ private: //////////////////////////////////////////////////////////// // Types //////////////////////////////////////////////////////////// - typedef std::map<Uint32, Glyph> GlyphTable; ///< Table mapping a codepoint to its glyph + typedef std::map<Uint64, Glyph> GlyphTable; ///< Table mapping a codepoint to its glyph //////////////////////////////////////////////////////////// /// \brief Structure defining a page of glyphs @@ -302,14 +306,15 @@ private: //////////////////////////////////////////////////////////// /// \brief Load a new glyph and store it in the cache /// - /// \param codePoint Unicode code point of the character to load - /// \param characterSize Reference character size - /// \param bold Retrieve the bold version or the regular one? + /// \param codePoint Unicode code point of the character to load + /// \param characterSize Reference character size + /// \param bold Retrieve the bold version or the regular one? + /// \param outlineThickness Thickness of outline (when != 0 the glyph will not be filled) /// /// \return The glyph corresponding to \a codePoint and \a characterSize /// //////////////////////////////////////////////////////////// - Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold) const; + Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const; //////////////////////////////////////////////////////////// /// \brief Find a suitable rectangle within the texture for a glyph @@ -344,6 +349,7 @@ private: void* m_library; ///< Pointer to the internal library interface (it is typeless to avoid exposing implementation details) void* m_face; ///< Pointer to the internal font face (it is typeless to avoid exposing implementation details) void* m_streamRec; ///< Pointer to the stream rec instance (it is typeless to avoid exposing implementation details) + void* m_stroker; ///< Pointer to the stroker (it is typeless to avoid exposing implementation details) int* m_refCount; ///< Reference counter used by implicit sharing Info m_info; ///< Information about the font mutable PageTable m_pages; ///< Table containing the glyphs pages by character size diff --git a/include/SFML/Graphics/Glsl.hpp b/include/SFML/Graphics/Glsl.hpp new file mode 100644 index 0000000..74b087f --- /dev/null +++ b/include/SFML/Graphics/Glsl.hpp @@ -0,0 +1,227 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) +// +// 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_GLSL_HPP +#define SFML_GLSL_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include <SFML/Graphics/Transform.hpp> +#include <SFML/Graphics/Color.hpp> +#include <SFML/System/Vector2.hpp> +#include <SFML/System/Vector3.hpp> + + +namespace sf +{ +namespace priv +{ + // Forward declarations + template <std::size_t Columns, std::size_t Rows> + struct Matrix; + + template <typename T> + struct Vector4; + +#include <SFML/Graphics/Glsl.inl> + +} // namespace priv + + +//////////////////////////////////////////////////////////// +/// \brief Namespace with GLSL types +/// +//////////////////////////////////////////////////////////// +namespace Glsl +{ + + //////////////////////////////////////////////////////////// + /// \brief 2D float vector (\p vec2 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef Vector2<float> Vec2; + + //////////////////////////////////////////////////////////// + /// \brief 2D int vector (\p ivec2 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef Vector2<int> Ivec2; + + //////////////////////////////////////////////////////////// + /// \brief 2D bool vector (\p bvec2 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef Vector2<bool> Bvec2; + + //////////////////////////////////////////////////////////// + /// \brief 3D float vector (\p vec3 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef Vector3<float> Vec3; + + //////////////////////////////////////////////////////////// + /// \brief 3D int vector (\p ivec3 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef Vector3<int> Ivec3; + + //////////////////////////////////////////////////////////// + /// \brief 3D bool vector (\p bvec3 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef Vector3<bool> Bvec3; + +#ifdef SFML_DOXYGEN + + //////////////////////////////////////////////////////////// + /// \brief 4D float vector (\p vec4 in GLSL) + /// + /// 4D float vectors can be implicitly converted from sf::Color + /// instances. Each color channel is normalized from integers + /// in [0, 255] to floating point values in [0, 1]. + /// \code + /// sf::Glsl::Vec4 zeroVector; + /// sf::Glsl::Vec4 vector(1.f, 2.f, 3.f, 4.f); + /// sf::Glsl::Vec4 color = sf::Color::Cyan; + /// \endcode + //////////////////////////////////////////////////////////// + typedef implementation-defined Vec4; + + //////////////////////////////////////////////////////////// + /// \brief 4D int vector (\p ivec4 in GLSL) + /// + /// 4D int vectors can be implicitly converted from sf::Color + /// instances. Each color channel remains unchanged inside + /// the integer interval [0, 255]. + /// \code + /// sf::Glsl::Ivec4 zeroVector; + /// sf::Glsl::Ivec4 vector(1, 2, 3, 4); + /// sf::Glsl::Ivec4 color = sf::Color::Cyan; + /// \endcode + //////////////////////////////////////////////////////////// + typedef implementation-defined Ivec4; + + //////////////////////////////////////////////////////////// + /// \brief 4D bool vector (\p bvec4 in GLSL) + /// + //////////////////////////////////////////////////////////// + typedef implementation-defined Bvec4; + + //////////////////////////////////////////////////////////// + /// \brief 3x3 float matrix (\p mat3 in GLSL) + /// + /// The matrix can be constructed from an array with 3x3 + /// elements, aligned in column-major order. For example, + /// a translation by (x, y) looks as follows: + /// \code + /// float array[9] = + /// { + /// 1, 0, 0, + /// 0, 1, 0, + /// x, y, 1 + /// }; + /// + /// sf::Glsl::Mat3 matrix(array); + /// \endcode + /// + /// Mat3 can also be implicitly converted from sf::Transform: + /// \code + /// sf::Transform transform; + /// sf::Glsl::Mat3 matrix = transform; + /// \endcode + //////////////////////////////////////////////////////////// + typedef implementation-defined Mat3; + + //////////////////////////////////////////////////////////// + /// \brief 4x4 float matrix (\p mat4 in GLSL) + /// + /// The matrix can be constructed from an array with 4x4 + /// elements, aligned in column-major order. For example, + /// a translation by (x, y, z) looks as follows: + /// \code + /// float array[16] = + /// { + /// 1, 0, 0, 0, + /// 0, 1, 0, 0, + /// 0, 0, 1, 0, + /// x, y, z, 1 + /// }; + /// + /// sf::Glsl::Mat4 matrix(array); + /// \endcode + /// + /// Mat4 can also be implicitly converted from sf::Transform: + /// \code + /// sf::Transform transform; + /// sf::Glsl::Mat4 matrix = transform; + /// \endcode + //////////////////////////////////////////////////////////// + typedef implementation-defined Mat4; + +#else // SFML_DOXYGEN + + typedef priv::Vector4<float> Vec4; + typedef priv::Vector4<int> Ivec4; + typedef priv::Vector4<bool> Bvec4; + typedef priv::Matrix<3, 3> Mat3; + typedef priv::Matrix<4, 4> Mat4; + +#endif // SFML_DOXYGEN + +} // namespace Glsl +} // namespace sf + +#endif // SFML_GLSL_HPP + + +//////////////////////////////////////////////////////////// +/// \namespace sf::Glsl +/// \ingroup graphics +/// +/// \details The sf::Glsl namespace contains types that match +/// their equivalents in GLSL, the OpenGL shading language. +/// These types are exclusively used by the sf::Shader class. +/// +/// Types that already exist in SFML, such as \ref sf::Vector2<T> +/// and \ref sf::Vector3<T>, are reused as typedefs, so you can use +/// the types in this namespace as well as the original ones. +/// Others are newly defined, such as Glsl::Vec4 or Glsl::Mat3. Their +/// actual type is an implementation detail and should not be used. +/// +/// All vector types support a default constructor that +/// initializes every component to zero, in addition to a +/// constructor with one parameter for each component. +/// The components are stored in member variables called +/// x, y, z, and w. +/// +/// All matrix types support a constructor with a float* +/// parameter that points to a float array of the appropriate +/// size (that is, 9 in a 3x3 matrix, 16 in a 4x4 matrix). +/// Furthermore, they can be converted from sf::Transform +/// objects. +/// +/// \see sf::Shader +/// +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/Glsl.inl b/include/SFML/Graphics/Glsl.inl new file mode 100644 index 0000000..3f2b027 --- /dev/null +++ b/include/SFML/Graphics/Glsl.inl @@ -0,0 +1,155 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) +// +// 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. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +/// \brief Helper functions to copy sf::Transform to sf::Glsl::Mat3/4 +/// +//////////////////////////////////////////////////////////// +void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<3, 3>& dest); +void SFML_GRAPHICS_API copyMatrix(const Transform& source, Matrix<4, 4>& dest); + +//////////////////////////////////////////////////////////// +/// \brief Copy array-based matrix with given number of elements +/// +/// Indirection to std::copy() to avoid inclusion of +/// <algorithm> and MSVC's annoying 4996 warning in header +/// +//////////////////////////////////////////////////////////// +void SFML_GRAPHICS_API copyMatrix(const float* source, std::size_t elements, float* dest); + +//////////////////////////////////////////////////////////// +/// \brief Helper functions to copy sf::Color to sf::Glsl::Vec4/Ivec4 +/// +//////////////////////////////////////////////////////////// +void SFML_GRAPHICS_API copyVector(const Color& source, Vector4<float>& dest); +void SFML_GRAPHICS_API copyVector(const Color& source, Vector4<int>& dest); + + +//////////////////////////////////////////////////////////// +/// \brief Matrix type, used to set uniforms in GLSL +/// +//////////////////////////////////////////////////////////// +template <std::size_t Columns, std::size_t Rows> +struct Matrix +{ + //////////////////////////////////////////////////////////// + /// \brief Construct from raw data + /// + /// \param pointer Points to the beginning of an array that + /// has the size of the matrix. The elements + /// are copied to the instance. + /// + //////////////////////////////////////////////////////////// + explicit Matrix(const float* pointer) + { + copyMatrix(pointer, Columns * Rows, array); + } + + //////////////////////////////////////////////////////////// + /// \brief Construct implicitly from SFML transform + /// + /// This constructor is only supported for 3x3 and 4x4 + /// matrices. + /// + /// \param transform Object containing a transform. + /// + //////////////////////////////////////////////////////////// + Matrix(const Transform& transform) + { + copyMatrix(transform, *this); + } + + float array[Columns * Rows]; ///< Array holding matrix data +}; + +//////////////////////////////////////////////////////////// +/// \brief 4D vector type, used to set uniforms in GLSL +/// +//////////////////////////////////////////////////////////// +template <typename T> +struct Vector4 +{ + //////////////////////////////////////////////////////////// + /// \brief Default constructor, creates a zero vector + /// + //////////////////////////////////////////////////////////// + Vector4() : + x(0), + y(0), + z(0), + w(0) + { + } + + //////////////////////////////////////////////////////////// + /// \brief Construct from 4 vector components + /// + /// \param X Component of the 4D vector + /// \param Y Component of the 4D vector + /// \param Z Component of the 4D vector + /// \param W Component of the 4D vector + /// + //////////////////////////////////////////////////////////// + Vector4(T X, T Y, T Z, T W) : + x(X), + y(Y), + z(Z), + w(W) + { + } + + //////////////////////////////////////////////////////////// + /// \brief Conversion constructor + /// + /// \param other 4D vector of different type + /// + //////////////////////////////////////////////////////////// + template <typename U> + explicit Vector4(const Vector4<U>& other) : + x(static_cast<T>(other.x)), + y(static_cast<T>(other.y)), + z(static_cast<T>(other.z)), + w(static_cast<T>(other.w)) + { + } + + //////////////////////////////////////////////////////////// + /// \brief Construct float vector implicitly from color + /// + /// \param color Color instance. Is normalized to [0, 1] + /// for floats, and left as-is for ints. + /// + //////////////////////////////////////////////////////////// + Vector4(const Color& color) + // uninitialized + { + copyVector(color, *this); + } + + T x; ///< 1st component (X) of the 4D vector + T y; ///< 2nd component (Y) of the 4D vector + T z; ///< 3rd component (Z) of the 4D vector + T w; ///< 4th component (W) of the 4D vector +}; diff --git a/include/SFML/Graphics/Glyph.hpp b/include/SFML/Graphics/Glyph.hpp index 0068872..174eb84 100644 --- a/include/SFML/Graphics/Glyph.hpp +++ b/include/SFML/Graphics/Glyph.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Image.hpp b/include/SFML/Graphics/Image.hpp index 11dc8f7..6eaa1f7 100644 --- a/include/SFML/Graphics/Image.hpp +++ b/include/SFML/Graphics/Image.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/PrimitiveType.hpp b/include/SFML/Graphics/PrimitiveType.hpp index 9dae947..931530b 100644 --- a/include/SFML/Graphics/PrimitiveType.hpp +++ b/include/SFML/Graphics/PrimitiveType.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -38,13 +38,18 @@ namespace sf //////////////////////////////////////////////////////////// enum PrimitiveType { - Points, ///< List of individual points - Lines, ///< List of individual lines - LinesStrip, ///< List of connected lines, a point uses the previous point to form a line - Triangles, ///< List of individual triangles - TrianglesStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle - TrianglesFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle - Quads ///< List of individual quads (deprecated, don't work with OpenGL ES) + Points, ///< List of individual points + Lines, ///< List of individual lines + LineStrip, ///< List of connected lines, a point uses the previous point to form a line + Triangles, ///< List of individual triangles + TriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle + TriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle + Quads, ///< List of individual quads (deprecated, don't work with OpenGL ES) + + // Deprecated names + LinesStrip = LineStrip, ///< \deprecated Use LineStrip instead + TrianglesStrip = TriangleStrip, ///< \deprecated Use TriangleStrip instead + TrianglesFan = TriangleFan ///< \deprecated Use TriangleFan instead }; } // namespace sf diff --git a/include/SFML/Graphics/Rect.hpp b/include/SFML/Graphics/Rect.hpp index f11a920..1b09388 100644 --- a/include/SFML/Graphics/Rect.hpp +++ b/include/SFML/Graphics/Rect.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Rect.inl b/include/SFML/Graphics/Rect.inl index 9ac4870..036fb47 100644 --- a/include/SFML/Graphics/Rect.inl +++ b/include/SFML/Graphics/Rect.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/RectangleShape.hpp b/include/SFML/Graphics/RectangleShape.hpp index 3195dc3..35dcc67 100644 --- a/include/SFML/Graphics/RectangleShape.hpp +++ b/include/SFML/Graphics/RectangleShape.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/RenderStates.hpp b/include/SFML/Graphics/RenderStates.hpp index 3ab3271..94f1197 100644 --- a/include/SFML/Graphics/RenderStates.hpp +++ b/include/SFML/Graphics/RenderStates.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/RenderTarget.hpp b/include/SFML/Graphics/RenderTarget.hpp index eb02355..adfa9ad 100644 --- a/include/SFML/Graphics/RenderTarget.hpp +++ b/include/SFML/Graphics/RenderTarget.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/RenderTexture.hpp b/include/SFML/Graphics/RenderTexture.hpp index 5d38562..4c6a833 100644 --- a/include/SFML/Graphics/RenderTexture.hpp +++ b/include/SFML/Graphics/RenderTexture.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -132,7 +132,23 @@ public: bool isRepeated() const; //////////////////////////////////////////////////////////// - /// \brief Activate of deactivate the render-texture for rendering + /// \brief Generate a mipmap using the current texture data + /// + /// This function is similar to Texture::generateMipmap and operates + /// on the texture used as the target for drawing. + /// Be aware that any draw operation may modify the base level image data. + /// For this reason, calling this function only makes sense after all + /// drawing is completed and display has been called. Not calling display + /// after subsequent drawing will lead to undefined behavior if a mipmap + /// had been previously generated. + /// + /// \return True if mipmap generation was successful, false if unsuccessful + /// + //////////////////////////////////////////////////////////// + bool generateMipmap(); + + //////////////////////////////////////////////////////////// + /// \brief Activate or deactivate the render-texture for rendering /// /// This function makes the render-texture's context current for /// future OpenGL rendering operations (so you shouldn't care diff --git a/include/SFML/Graphics/RenderWindow.hpp b/include/SFML/Graphics/RenderWindow.hpp index 98e5b9a..fc55af4 100644 --- a/include/SFML/Graphics/RenderWindow.hpp +++ b/include/SFML/Graphics/RenderWindow.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -115,6 +115,17 @@ public: //////////////////////////////////////////////////////////// /// \brief Copy the current contents of the window to an image /// + /// \deprecated + /// Use a sf::Texture and its sf::Texture::update(const Window&) + /// function and copy its contents into an sf::Image instead. + /// \code + /// sf::Vector2u windowSize = window.getSize(); + /// sf::Texture texture; + /// texture.create(windowSize.x, windowSize.y); + /// texture.update(window); + /// sf::Image screenshot = texture.copyToImage(); + /// \endcode + /// /// This is a slow operation, whose main purpose is to make /// screenshots of the application. If you want to update an /// image with the contents of the window and then use it for @@ -126,7 +137,7 @@ public: /// \return Image containing the captured contents /// //////////////////////////////////////////////////////////// - Image capture() const; + SFML_DEPRECATED Image capture() const; protected: diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp index 55cc3bb..9597fcb 100644 --- a/include/SFML/Graphics/Shader.hpp +++ b/include/SFML/Graphics/Shader.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -29,8 +29,7 @@ // Headers //////////////////////////////////////////////////////////// #include <SFML/Graphics/Export.hpp> -#include <SFML/Graphics/Transform.hpp> -#include <SFML/Graphics/Color.hpp> +#include <SFML/Graphics/Glsl.hpp> #include <SFML/Window/GlResource.hpp> #include <SFML/System/NonCopyable.hpp> #include <SFML/System/Vector2.hpp> @@ -41,11 +40,13 @@ namespace sf { +class Color; class InputStream; class Texture; +class Transform; //////////////////////////////////////////////////////////// -/// \brief Shader class (vertex and fragment) +/// \brief Shader class (vertex, geometry and fragment) /// //////////////////////////////////////////////////////////// class SFML_GRAPHICS_API Shader : GlResource, NonCopyable @@ -58,15 +59,16 @@ public: //////////////////////////////////////////////////////////// enum Type { - Vertex, ///< Vertex shader - Fragment ///< Fragment (pixel) shader + Vertex, ///< %Vertex shader + Geometry, ///< Geometry shader + Fragment ///< Fragment (pixel) shader }; //////////////////////////////////////////////////////////// - /// \brief Special type that can be passed to setParameter, + /// \brief Special type that can be passed to setUniform(), /// and that represents the texture of the object being drawn /// - /// \see setParameter(const std::string&, CurrentTextureType) + /// \see setUniform(const std::string&, CurrentTextureType) /// //////////////////////////////////////////////////////////// struct CurrentTextureType {}; @@ -74,7 +76,7 @@ public: //////////////////////////////////////////////////////////// /// \brief Represents the texture of the object being drawn /// - /// \see setParameter(const std::string&, CurrentTextureType) + /// \see setUniform(const std::string&, CurrentTextureType) /// //////////////////////////////////////////////////////////// static CurrentTextureType CurrentTexture; @@ -96,9 +98,9 @@ public: ~Shader(); //////////////////////////////////////////////////////////// - /// \brief Load either the vertex or fragment shader from a file + /// \brief Load the vertex, geometry or fragment shader from a file /// - /// This function loads a single shader, either vertex or + /// This function loads a single shader, vertex, geometry or /// fragment, identified by the second argument. /// The source must be a text file containing a valid /// shader in GLSL language. GLSL is a C-like language @@ -106,8 +108,8 @@ public: /// read a good documentation for it before writing your /// own shaders. /// - /// \param filename Path of the vertex or fragment shader file to load - /// \param type Type of shader (vertex or fragment) + /// \param filename Path of the vertex, geometry or fragment shader file to load + /// \param type Type of shader (vertex, geometry or fragment) /// /// \return True if loading succeeded, false if it failed /// @@ -138,17 +140,39 @@ public: bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename); //////////////////////////////////////////////////////////// - /// \brief Load either the vertex or fragment shader from a source code in memory + /// \brief Load the vertex, geometry and fragment shaders from files /// - /// This function loads a single shader, either vertex or - /// fragment, identified by the second argument. + /// This function loads the vertex, geometry and fragment + /// shaders. If one of them fails to load, the shader is left + /// empty (the valid shader is unloaded). + /// The sources must be text files containing valid shaders + /// in GLSL language. GLSL is a C-like language dedicated to + /// OpenGL shaders; you'll probably need to read a good documentation + /// for it before writing your own shaders. + /// + /// \param vertexShaderFilename Path of the vertex shader file to load + /// \param geometryShaderFilename Path of the geometry shader file to load + /// \param fragmentShaderFilename Path of the fragment shader file to load + /// + /// \return True if loading succeeded, false if it failed + /// + /// \see loadFromMemory, loadFromStream + /// + //////////////////////////////////////////////////////////// + bool loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename); + + //////////////////////////////////////////////////////////// + /// \brief Load the vertex, geometry or fragment shader from a source code in memory + /// + /// This function loads a single shader, vertex, geometry + /// or fragment, identified by the second argument. /// The source code must be a valid shader in GLSL language. /// GLSL is a C-like language dedicated to OpenGL shaders; /// you'll probably need to read a good documentation for /// it before writing your own shaders. /// /// \param shader String containing the source code of the shader - /// \param type Type of shader (vertex or fragment) + /// \param type Type of shader (vertex, geometry or fragment) /// /// \return True if loading succeeded, false if it failed /// @@ -179,17 +203,39 @@ public: bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader); //////////////////////////////////////////////////////////// - /// \brief Load either the vertex or fragment shader from a custom stream + /// \brief Load the vertex, geometry and fragment shaders from source codes in memory /// - /// This function loads a single shader, either vertex or - /// fragment, identified by the second argument. + /// This function loads the vertex, geometry and fragment + /// shaders. If one of them fails to load, the shader is left + /// empty (the valid shader is unloaded). + /// The sources must be valid shaders in GLSL language. GLSL is + /// a C-like language dedicated to OpenGL shaders; you'll + /// probably need to read a good documentation for it before + /// writing your own shaders. + /// + /// \param vertexShader String containing the source code of the vertex shader + /// \param geometryShader String containing the source code of the geometry shader + /// \param fragmentShader String containing the source code of the fragment shader + /// + /// \return True if loading succeeded, false if it failed + /// + /// \see loadFromFile, loadFromStream + /// + //////////////////////////////////////////////////////////// + bool loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader); + + //////////////////////////////////////////////////////////// + /// \brief Load the vertex, geometry or fragment shader from a custom stream + /// + /// This function loads a single shader, vertex, geometry + /// or fragment, identified by the second argument. /// The source code must be a valid shader in GLSL language. /// GLSL is a C-like language dedicated to OpenGL shaders; /// you'll probably need to read a good documentation for it /// before writing your own shaders. /// /// \param stream Source stream to read from - /// \param type Type of shader (vertex or fragment) + /// \param type Type of shader (vertex, geometry or fragment) /// /// \return True if loading succeeded, false if it failed /// @@ -220,193 +266,176 @@ public: bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream); //////////////////////////////////////////////////////////// - /// \brief Change a float parameter of the shader + /// \brief Load the vertex, geometry and fragment shaders from custom streams /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a float - /// (float GLSL type). + /// This function loads the vertex, geometry and fragment + /// shaders. If one of them fails to load, the shader is left + /// empty (the valid shader is unloaded). + /// The source codes must be valid shaders in GLSL language. + /// GLSL is a C-like language dedicated to OpenGL shaders; + /// you'll probably need to read a good documentation for + /// it before writing your own shaders. /// - /// Example: - /// \code - /// uniform float myparam; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("myparam", 5.2f); - /// \endcode + /// \param vertexShaderStream Source stream to read the vertex shader from + /// \param geometryShaderStream Source stream to read the geometry shader from + /// \param fragmentShaderStream Source stream to read the fragment shader from + /// + /// \return True if loading succeeded, false if it failed /// - /// \param name Name of the parameter in the shader - /// \param x Value to assign + /// \see loadFromFile, loadFromMemory /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, float x); + bool loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream); //////////////////////////////////////////////////////////// - /// \brief Change a 2-components vector parameter of the shader + /// \brief Specify value for \p float uniform /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 2x1 vector - /// (vec2 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param x Value of the float scalar /// - /// Example: - /// \code - /// uniform vec2 myparam; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("myparam", 5.2f, 6.0f); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, float x); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p vec2 uniform /// - /// \param name Name of the parameter in the shader - /// \param x First component of the value to assign - /// \param y Second component of the value to assign + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the vec2 vector /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, float x, float y); + void setUniform(const std::string& name, const Glsl::Vec2& vector); //////////////////////////////////////////////////////////// - /// \brief Change a 3-components vector parameter of the shader + /// \brief Specify value for \p vec3 uniform /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 3x1 vector - /// (vec3 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the vec3 vector /// - /// Example: - /// \code - /// uniform vec3 myparam; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("myparam", 5.2f, 6.0f, -8.1f); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, const Glsl::Vec3& vector); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p vec4 uniform + /// + /// This overload can also be called with sf::Color objects + /// that are converted to sf::Glsl::Vec4. + /// + /// It is important to note that the components of the color are + /// normalized before being passed to the shader. Therefore, + /// they are converted from range [0 .. 255] to range [0 .. 1]. + /// For example, a sf::Color(255, 127, 0, 255) will be transformed + /// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader. /// - /// \param name Name of the parameter in the shader - /// \param x First component of the value to assign - /// \param y Second component of the value to assign - /// \param z Third component of the value to assign + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the vec4 vector /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, float x, float y, float z); + void setUniform(const std::string& name, const Glsl::Vec4& vector); //////////////////////////////////////////////////////////// - /// \brief Change a 4-components vector parameter of the shader + /// \brief Specify value for \p int uniform /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 4x1 vector - /// (vec4 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param x Value of the int scalar /// - /// Example: - /// \code - /// uniform vec4 myparam; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("myparam", 5.2f, 6.0f, -8.1f, 0.4f); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, int x); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p ivec2 uniform /// - /// \param name Name of the parameter in the shader - /// \param x First component of the value to assign - /// \param y Second component of the value to assign - /// \param z Third component of the value to assign - /// \param w Fourth component of the value to assign + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the ivec2 vector /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, float x, float y, float z, float w); + void setUniform(const std::string& name, const Glsl::Ivec2& vector); //////////////////////////////////////////////////////////// - /// \brief Change a 2-components vector parameter of the shader + /// \brief Specify value for \p ivec3 uniform /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 2x1 vector - /// (vec2 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the ivec3 vector /// - /// Example: - /// \code - /// uniform vec2 myparam; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("myparam", sf::Vector2f(5.2f, 6.0f)); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, const Glsl::Ivec3& vector); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p ivec4 uniform + /// + /// This overload can also be called with sf::Color objects + /// that are converted to sf::Glsl::Ivec4. + /// + /// If color conversions are used, the ivec4 uniform in GLSL + /// will hold the same values as the original sf::Color + /// instance. For example, sf::Color(255, 127, 0, 255) is + /// mapped to ivec4(255, 127, 0, 255). /// - /// \param name Name of the parameter in the shader - /// \param vector Vector to assign + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the ivec4 vector /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, const Vector2f& vector); + void setUniform(const std::string& name, const Glsl::Ivec4& vector); //////////////////////////////////////////////////////////// - /// \brief Change a 3-components vector parameter of the shader + /// \brief Specify value for \p bool uniform /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 3x1 vector - /// (vec3 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param x Value of the bool scalar /// - /// Example: - /// \code - /// uniform vec3 myparam; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("myparam", sf::Vector3f(5.2f, 6.0f, -8.1f)); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, bool x); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p bvec2 uniform /// - /// \param name Name of the parameter in the shader - /// \param vector Vector to assign + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the bvec2 vector /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, const Vector3f& vector); + void setUniform(const std::string& name, const Glsl::Bvec2& vector); //////////////////////////////////////////////////////////// - /// \brief Change a color parameter of the shader + /// \brief Specify value for \p bvec3 uniform /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 4x1 vector - /// (vec4 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the bvec3 vector /// - /// It is important to note that the components of the color are - /// normalized before being passed to the shader. Therefore, - /// they are converted from range [0 .. 255] to range [0 .. 1]. - /// For example, a sf::Color(255, 125, 0, 255) will be transformed - /// to a vec4(1.0, 0.5, 0.0, 1.0) in the shader. - /// - /// Example: - /// \code - /// uniform vec4 color; // this is the variable in the shader - /// \endcode - /// \code - /// shader.setParameter("color", sf::Color(255, 128, 0, 255)); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, const Glsl::Bvec3& vector); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p bvec4 uniform /// - /// \param name Name of the parameter in the shader - /// \param color Color to assign + /// \param name Name of the uniform variable in GLSL + /// \param vector Value of the bvec4 vector /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, const Color& color); + void setUniform(const std::string& name, const Glsl::Bvec4& vector); //////////////////////////////////////////////////////////// - /// \brief Change a matrix parameter of the shader + /// \brief Specify value for \p mat3 matrix /// - /// \a name is the name of the variable to change in the shader. - /// The corresponding parameter in the shader must be a 4x4 matrix - /// (mat4 GLSL type). + /// \param name Name of the uniform variable in GLSL + /// \param matrix Value of the mat3 matrix /// - /// Example: - /// \code - /// uniform mat4 matrix; // this is the variable in the shader - /// \endcode - /// \code - /// sf::Transform transform; - /// transform.translate(5, 10); - /// shader.setParameter("matrix", transform); - /// \endcode + //////////////////////////////////////////////////////////// + void setUniform(const std::string& name, const Glsl::Mat3& matrix); + + //////////////////////////////////////////////////////////// + /// \brief Specify value for \p mat4 matrix /// - /// \param name Name of the parameter in the shader - /// \param transform Transform to assign + /// \param name Name of the uniform variable in GLSL + /// \param matrix Value of the mat4 matrix /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, const Transform& transform); + void setUniform(const std::string& name, const Glsl::Mat4& matrix); //////////////////////////////////////////////////////////// - /// \brief Change a texture parameter of the shader + /// \brief Specify a texture as \p sampler2D uniform /// /// \a name is the name of the variable to change in the shader. /// The corresponding parameter in the shader must be a 2D texture - /// (sampler2D GLSL type). + /// (\p sampler2D GLSL type). /// /// Example: /// \code @@ -415,46 +444,186 @@ public: /// \code /// sf::Texture texture; /// ... - /// shader.setParameter("the_texture", texture); + /// shader.setUniform("the_texture", texture); /// \endcode /// It is important to note that \a texture must remain alive as long /// as the shader uses it, no copy is made internally. /// - /// To use the texture of the object being draw, which cannot be + /// To use the texture of the object being drawn, which cannot be /// known in advance, you can pass the special value /// sf::Shader::CurrentTexture: /// \code - /// shader.setParameter("the_texture", sf::Shader::CurrentTexture). + /// shader.setUniform("the_texture", sf::Shader::CurrentTexture). /// \endcode /// /// \param name Name of the texture in the shader /// \param texture Texture to assign /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, const Texture& texture); + void setUniform(const std::string& name, const Texture& texture); //////////////////////////////////////////////////////////// - /// \brief Change a texture parameter of the shader + /// \brief Specify current texture as \p sampler2D uniform /// /// This overload maps a shader texture variable to the /// texture of the object being drawn, which cannot be /// known in advance. The second argument must be /// sf::Shader::CurrentTexture. /// The corresponding parameter in the shader must be a 2D texture - /// (sampler2D GLSL type). + /// (\p sampler2D GLSL type). /// /// Example: /// \code /// uniform sampler2D current; // this is the variable in the shader /// \endcode /// \code - /// shader.setParameter("current", sf::Shader::CurrentTexture); + /// shader.setUniform("current", sf::Shader::CurrentTexture); /// \endcode /// /// \param name Name of the texture in the shader /// //////////////////////////////////////////////////////////// - void setParameter(const std::string& name, CurrentTextureType); + void setUniform(const std::string& name, CurrentTextureType); + + //////////////////////////////////////////////////////////// + /// \brief Specify values for \p float[] array uniform + /// + /// \param name Name of the uniform variable in GLSL + /// \param scalarArray pointer to array of \p float values + /// \param length Number of elements in the array + /// + //////////////////////////////////////////////////////////// + void setUniformArray(const std::string& name, const float* scalarArray, std::size_t length); + + //////////////////////////////////////////////////////////// + /// \brief Specify values for \p vec2[] array uniform + /// + /// \param name Name of the uniform variable in GLSL + /// \param vectorArray pointer to array of \p vec2 values + /// \param length Number of elements in the array + /// + //////////////////////////////////////////////////////////// + void setUniformArray(const std::string& name, const Glsl::Vec2* vectorArray, std::size_t length); + + //////////////////////////////////////////////////////////// + /// \brief Specify values for \p vec3[] array uniform + /// + /// \param name Name of the uniform variable in GLSL + /// \param vectorArray pointer to array of \p vec3 values + /// \param length Number of elements in the array + /// + //////////////////////////////////////////////////////////// + void setUniformArray(const std::string& name, const Glsl::Vec3* vectorArray, std::size_t length); + + //////////////////////////////////////////////////////////// + /// \brief Specify values for \p vec4[] array uniform + /// + /// \param name Name of the uniform variable in GLSL + /// \param vectorArray pointer to array of \p vec4 values + /// \param length Number of elements in the array + /// + //////////////////////////////////////////////////////////// + void setUniformArray(const std::string& name, const Glsl::Vec4* vectorArray, std::size_t length); + + //////////////////////////////////////////////////////////// + /// \brief Specify values for \p mat3[] array uniform + /// + /// \param name Name of the uniform variable in GLSL + /// \param matrixArray pointer to array of \p mat3 values + /// \param length Number of elements in the array + /// + //////////////////////////////////////////////////////////// + void setUniformArray(const std::string& name, const Glsl::Mat3* matrixArray, std::size_t length); + + //////////////////////////////////////////////////////////// + /// \brief Specify values for \p mat4[] array uniform + /// + /// \param name Name of the uniform variable in GLSL + /// \param matrixArray pointer to array of \p mat4 values + /// \param length Number of elements in the array + /// + //////////////////////////////////////////////////////////// + void setUniformArray(const std::string& name, const Glsl::Mat4* matrixArray, std::size_t length); + + //////////////////////////////////////////////////////////// + /// \brief Change a float parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, float) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, float x); + + //////////////////////////////////////////////////////////// + /// \brief Change a 2-components vector parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Vec2&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, float x, float y); + + //////////////////////////////////////////////////////////// + /// \brief Change a 3-components vector parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Vec3&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Change a 4-components vector parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Vec4&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, float x, float y, float z, float w); + + //////////////////////////////////////////////////////////// + /// \brief Change a 2-components vector parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Vec2&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, const Vector2f& vector); + + //////////////////////////////////////////////////////////// + /// \brief Change a 3-components vector parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Vec3&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, const Vector3f& vector); + + //////////////////////////////////////////////////////////// + /// \brief Change a color parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Vec4&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, const Color& color); + + //////////////////////////////////////////////////////////// + /// \brief Change a matrix parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Glsl::Mat4&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, const Transform& transform); + + //////////////////////////////////////////////////////////// + /// \brief Change a texture parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, const Texture&) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, const Texture& texture); + + //////////////////////////////////////////////////////////// + /// \brief Change a texture parameter of the shader + /// + /// \deprecated Use setUniform(const std::string&, CurrentTextureType) instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setParameter(const std::string& name, CurrentTextureType); //////////////////////////////////////////////////////////// /// \brief Get the underlying OpenGL handle of the shader. @@ -498,13 +667,29 @@ public: /// the shader features. If it returns false, then /// any attempt to use sf::Shader will fail. /// + /// \return True if shaders are supported, false otherwise + /// + //////////////////////////////////////////////////////////// + static bool isAvailable(); + + //////////////////////////////////////////////////////////// + /// \brief Tell whether or not the system supports geometry shaders + /// + /// This function should always be called before using + /// the geometry shader features. If it returns false, then + /// any attempt to use sf::Shader geometry shader features will fail. + /// + /// This function can only return true if isAvailable() would also + /// return true, since shaders in general have to be supported in + /// order for geometry shaders to be supported as well. + /// /// Note: The first call to this function, whether by your /// code or SFML will result in a context switch. /// - /// \return True if shaders are supported, false otherwise + /// \return True if geometry shaders are supported, false otherwise /// //////////////////////////////////////////////////////////// - static bool isAvailable(); + static bool isGeometryAvailable(); private: @@ -515,12 +700,13 @@ private: /// is not created. /// /// \param vertexShaderCode Source code of the vertex shader + /// \param geometryShaderCode Source code of the geometry shader /// \param fragmentShaderCode Source code of the fragment shader /// /// \return True on success, false if any error happened /// //////////////////////////////////////////////////////////// - bool compile(const char* vertexShaderCode, const char* fragmentShaderCode); + bool compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode); //////////////////////////////////////////////////////////// /// \brief Bind all the textures used by the shader @@ -532,20 +718,29 @@ private: void bindTextures() const; //////////////////////////////////////////////////////////// - /// \brief Get the location ID of a shader parameter + /// \brief Get the location ID of a shader uniform /// - /// \param name Name of the parameter to search + /// \param name Name of the uniform variable to search /// - /// \return Location ID of the parameter, or -1 if not found + /// \return Location ID of the uniform, or -1 if not found /// //////////////////////////////////////////////////////////// - int getParamLocation(const std::string& name); + int getUniformLocation(const std::string& name); + + //////////////////////////////////////////////////////////// + /// \brief RAII object to save and restore the program + /// binding while uniforms are being set + /// + /// Implementation is private in the .cpp file. + /// + //////////////////////////////////////////////////////////// + struct UniformBinder; //////////////////////////////////////////////////////////// // Types //////////////////////////////////////////////////////////// typedef std::map<int, const Texture*> TextureTable; - typedef std::map<std::string, int> ParamTable; + typedef std::map<std::string, int> UniformTable; //////////////////////////////////////////////////////////// // Member data @@ -553,7 +748,7 @@ private: unsigned int m_shaderProgram; ///< OpenGL identifier for the program int m_currentTexture; ///< Location of the current texture in the shader TextureTable m_textures; ///< Texture variables in the shader, mapped to their location - ParamTable m_params; ///< Parameters location cache + UniformTable m_uniforms; ///< Parameters location cache }; } // namespace sf @@ -570,45 +765,64 @@ private: /// executed directly by the graphics card and allowing /// to apply real-time operations to the rendered entities. /// -/// There are two kinds of shaders: -/// \li Vertex shaders, that process vertices +/// There are three kinds of shaders: +/// \li %Vertex shaders, that process vertices +/// \li Geometry shaders, that process primitives /// \li Fragment (pixel) shaders, that process pixels /// /// A sf::Shader can be composed of either a vertex shader -/// alone, a fragment shader alone, or both combined -/// (see the variants of the load functions). +/// alone, a geometry shader alone, a fragment shader alone, +/// or any combination of them. (see the variants of the +/// load functions). /// /// Shaders are written in GLSL, which is a C-like /// language dedicated to OpenGL shaders. You'll probably /// need to learn its basics before writing your own shaders /// for SFML. /// -/// Like any C/C++ program, a shader has its own variables -/// that you can set from your C++ application. sf::Shader -/// handles 5 different types of variables: -/// \li floats +/// Like any C/C++ program, a GLSL shader has its own variables +/// called \a uniforms that you can set from your C++ application. +/// sf::Shader handles different types of uniforms: +/// \li scalars: \p float, \p int, \p bool /// \li vectors (2, 3 or 4 components) -/// \li colors -/// \li textures -/// \li transforms (matrices) +/// \li matrices (3x3 or 4x4) +/// \li samplers (textures) /// -/// The value of the variables can be changed at any time -/// with the various overloads of the setParameter function: +/// Some SFML-specific types can be converted: +/// \li sf::Color as a 4D vector (\p vec4) +/// \li sf::Transform as matrices (\p mat3 or \p mat4) +/// +/// Every uniform variable in a shader can be set through one of the +/// setUniform() or setUniformArray() overloads. For example, if you +/// have a shader with the following uniforms: /// \code -/// shader.setParameter("offset", 2.f); -/// shader.setParameter("point", 0.5f, 0.8f, 0.3f); -/// shader.setParameter("color", sf::Color(128, 50, 255)); -/// shader.setParameter("matrix", transform); // transform is a sf::Transform -/// shader.setParameter("overlay", texture); // texture is a sf::Texture -/// shader.setParameter("texture", sf::Shader::CurrentTexture); +/// uniform float offset; +/// uniform vec3 point; +/// uniform vec4 color; +/// uniform mat4 matrix; +/// uniform sampler2D overlay; +/// uniform sampler2D current; /// \endcode +/// You can set their values from C++ code as follows, using the types +/// defined in the sf::Glsl namespace: +/// \code +/// shader.setUniform("offset", 2.f); +/// shader.setUniform("point", sf::Vector3f(0.5f, 0.8f, 0.3f)); +/// shader.setUniform("color", sf::Glsl::Vec4(color)); // color is a sf::Color +/// shader.setUniform("matrix", sf::Glsl::Mat4(transform)); // transform is a sf::Transform +/// shader.setUniform("overlay", texture); // texture is a sf::Texture +/// shader.setUniform("current", sf::Shader::CurrentTexture); +/// \endcode +/// +/// The old setParameter() overloads are deprecated and will be removed in a +/// future version. You should use their setUniform() equivalents instead. /// /// The special Shader::CurrentTexture argument maps the -/// given texture variable to the current texture of the +/// given \p sampler2D uniform to the current texture of the /// object being drawn (which cannot be known in advance). /// /// To apply a shader to a drawable, you must pass it as an -/// additional parameter to the Draw function: +/// additional parameter to the \ref Window::draw() draw() function: /// \code /// window.draw(sprite, &shader); /// \endcode @@ -656,4 +870,6 @@ private: /// sf::Shader::bind(NULL); /// \endcode /// +/// \see sf::Glsl +/// //////////////////////////////////////////////////////////// diff --git a/include/SFML/Graphics/Shape.hpp b/include/SFML/Graphics/Shape.hpp index 5983a9d..2878cc5 100644 --- a/include/SFML/Graphics/Shape.hpp +++ b/include/SFML/Graphics/Shape.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Sprite.hpp b/include/SFML/Graphics/Sprite.hpp index c7447df..712fa15 100644 --- a/include/SFML/Graphics/Sprite.hpp +++ b/include/SFML/Graphics/Sprite.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index c31ec61..9d54d97 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -159,16 +159,63 @@ public: void setStyle(Uint32 style); //////////////////////////////////////////////////////////// - /// \brief Set the global color of the text + /// \brief Set the fill color of the text /// - /// By default, the text's color is opaque white. + /// By default, the text's fill color is opaque white. + /// Setting the fill color to a transparent color with an outline + /// will cause the outline to be displayed in the fill area of the text. /// - /// \param color New color of the text + /// \param color New fill color of the text /// - /// \see getColor + /// \see getFillColor + /// + /// \deprecated There is now fill and outline colors instead + /// of a single global color. + /// Use setFillColor() or setOutlineColor() instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED void setColor(const Color& color); + + //////////////////////////////////////////////////////////// + /// \brief Set the fill color of the text + /// + /// By default, the text's fill color is opaque white. + /// Setting the fill color to a transparent color with an outline + /// will cause the outline to be displayed in the fill area of the text. + /// + /// \param color New fill color of the text + /// + /// \see getFillColor + /// + //////////////////////////////////////////////////////////// + void setFillColor(const Color& color); + + //////////////////////////////////////////////////////////// + /// \brief Set the outline color of the text + /// + /// By default, the text's outline color is opaque black. + /// + /// \param color New outline color of the text + /// + /// \see getOutlineColor + /// + //////////////////////////////////////////////////////////// + void setOutlineColor(const Color& color); + + //////////////////////////////////////////////////////////// + /// \brief Set the thickness of the text's outline + /// + /// By default, the outline thickness is 0. + /// + /// Be aware that using a negative value for the outline + /// thickness will cause distorted rendering. + /// + /// \param thickness New outline thickness, in pixels + /// + /// \see getOutlineThickness /// //////////////////////////////////////////////////////////// - void setColor(const Color& color); + void setOutlineThickness(float thickness); //////////////////////////////////////////////////////////// /// \brief Get the text's string @@ -224,14 +271,48 @@ public: Uint32 getStyle() const; //////////////////////////////////////////////////////////// - /// \brief Get the global color of the text + /// \brief Get the fill color of the text + /// + /// \return Fill color of the text + /// + /// \see setFillColor + /// + /// \deprecated There is now fill and outline colors instead + /// of a single global color. + /// Use getFillColor() or getOutlineColor() instead. + /// + //////////////////////////////////////////////////////////// + SFML_DEPRECATED const Color& getColor() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the fill color of the text + /// + /// \return Fill color of the text + /// + /// \see setFillColor + /// + //////////////////////////////////////////////////////////// + const Color& getFillColor() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the outline color of the text + /// + /// \return Outline color of the text + /// + /// \see setOutlineColor + /// + //////////////////////////////////////////////////////////// + const Color& getOutlineColor() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the outline thickness of the text /// - /// \return Global color of the text + /// \return Outline thickness of the text, in pixels /// - /// \see setColor + /// \see setOutlineThickness /// //////////////////////////////////////////////////////////// - const Color& getColor() const; + float getOutlineThickness() const; //////////////////////////////////////////////////////////// /// \brief Return the position of the \a index-th character @@ -305,8 +386,11 @@ private: const Font* m_font; ///< Font used to display the string unsigned int m_characterSize; ///< Base size of characters, in pixels Uint32 m_style; ///< Text style (see Style enum) - Color m_color; ///< Text color - mutable VertexArray m_vertices; ///< Vertex array containing the text's geometry + Color m_fillColor; ///< Text fill color + Color m_outlineColor; ///< Text outline color + float m_outlineThickness; ///< Thickness of the text's outline + mutable VertexArray m_vertices; ///< Vertex array containing the fill geometry + mutable VertexArray m_outlineVertices; ///< Vertex array containing the outline geometry mutable FloatRect m_bounds; ///< Bounding rectangle of the text (in local coordinates) mutable bool m_geometryNeedUpdate; ///< Does the geometry need to be recomputed? }; diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index 2471531..6434ab0 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -377,6 +377,41 @@ public: bool isSmooth() const; //////////////////////////////////////////////////////////// + /// \brief Enable or disable conversion from sRGB + /// + /// When providing texture data from an image file or memory, it can + /// either be stored in a linear color space or an sRGB color space. + /// Most digital images account for gamma correction already, so they + /// would need to be "uncorrected" back to linear color space before + /// being processed by the hardware. The hardware can automatically + /// convert it from the sRGB color space to a linear color space when + /// it gets sampled. When the rendered image gets output to the final + /// framebuffer, it gets converted back to sRGB. + /// + /// After enabling or disabling sRGB conversion, make sure to reload + /// the texture data in order for the setting to take effect. + /// + /// This option is only useful in conjunction with an sRGB capable + /// framebuffer. This can be requested during window creation. + /// + /// \param sRgb True to enable sRGB conversion, false to disable it + /// + /// \see isSrgb + /// + //////////////////////////////////////////////////////////// + void setSrgb(bool sRgb); + + //////////////////////////////////////////////////////////// + /// \brief Tell whether the texture source is converted from sRGB or not + /// + /// \return True if the texture source is converted from sRGB, false if not + /// + /// \see setSrgb + /// + //////////////////////////////////////////////////////////// + bool isSrgb() const; + + //////////////////////////////////////////////////////////// /// \brief Enable or disable repeating /// /// Repeating is involved when using texture coordinates @@ -411,6 +446,31 @@ public: bool isRepeated() const; //////////////////////////////////////////////////////////// + /// \brief Generate a mipmap using the current texture data + /// + /// Mipmaps are pre-computed chains of optimized textures. Each + /// level of texture in a mipmap is generated by halving each of + /// the previous level's dimensions. This is done until the final + /// level has the size of 1x1. The textures generated in this process may + /// make use of more advanced filters which might improve the visual quality + /// of textures when they are applied to objects much smaller than they are. + /// This is known as minification. Because fewer texels (texture elements) + /// have to be sampled from when heavily minified, usage of mipmaps + /// can also improve rendering performance in certain scenarios. + /// + /// Mipmap generation relies on the necessary OpenGL extension being + /// available. If it is unavailable or generation fails due to another + /// reason, this function will return false. Mipmap data is only valid from + /// the time it is generated until the next time the base level image is + /// modified, at which point this function will have to be called again to + /// regenerate it. + /// + /// \return True if mipmap generation was successful, false if unsuccessful + /// + //////////////////////////////////////////////////////////// + bool generateMipmap(); + + //////////////////////////////////////////////////////////// /// \brief Overload of assignment operator /// /// \param right Instance to assign @@ -472,9 +532,6 @@ public: /// You can expect a value of 512 pixels for low-end graphics /// card, and up to 8192 pixels or more for newer hardware. /// - /// Note: The first call to this function, whether by your - /// code or SFML will result in a context switch. - /// /// \return Maximum size allowed for textures, in pixels /// //////////////////////////////////////////////////////////// @@ -501,15 +558,26 @@ private: static unsigned int getValidSize(unsigned int size); //////////////////////////////////////////////////////////// + /// \brief Invalidate the mipmap if one exists + /// + /// This also resets the texture's minifying function. + /// This function is mainly for internal use by RenderTexture. + /// + //////////////////////////////////////////////////////////// + void invalidateMipmap(); + + //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// Vector2u m_size; ///< Public texture size Vector2u m_actualSize; ///< Actual texture size (can be greater than public size because of padding) unsigned int m_texture; ///< Internal texture identifier bool m_isSmooth; ///< Status of the smooth filter + bool m_sRgb; ///< Should the texture source be converted from sRGB? bool m_isRepeated; ///< Is the texture in repeat mode? mutable bool m_pixelsFlipped; ///< To work around the inconsistency in Y orientation bool m_fboAttachment; ///< Is this texture owned by a framebuffer object? + bool m_hasMipmap; ///< Has the mipmap been generated? Uint64 m_cacheId; ///< Unique number that identifies the texture to the render target's cache }; diff --git a/include/SFML/Graphics/Transform.hpp b/include/SFML/Graphics/Transform.hpp index a555a33..f1094ce 100644 --- a/include/SFML/Graphics/Transform.hpp +++ b/include/SFML/Graphics/Transform.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Transformable.hpp b/include/SFML/Graphics/Transformable.hpp index e4b86cf..d73cca4 100644 --- a/include/SFML/Graphics/Transformable.hpp +++ b/include/SFML/Graphics/Transformable.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/Vertex.hpp b/include/SFML/Graphics/Vertex.hpp index 2509976..d2693f9 100644 --- a/include/SFML/Graphics/Vertex.hpp +++ b/include/SFML/Graphics/Vertex.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Graphics/VertexArray.hpp b/include/SFML/Graphics/VertexArray.hpp index f0820a5..33dfe95 100644 --- a/include/SFML/Graphics/VertexArray.hpp +++ b/include/SFML/Graphics/VertexArray.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -209,7 +209,7 @@ private: /// /// Example: /// \code -/// sf::VertexArray lines(sf::LinesStrip, 4); +/// sf::VertexArray lines(sf::LineStrip, 4); /// lines[0].position = sf::Vector2f(10, 0); /// lines[1].position = sf::Vector2f(20, 0); /// lines[2].position = sf::Vector2f(30, 5); diff --git a/include/SFML/Graphics/View.hpp b/include/SFML/Graphics/View.hpp index 4bd62d8..2e4f510 100644 --- a/include/SFML/Graphics/View.hpp +++ b/include/SFML/Graphics/View.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -302,11 +302,11 @@ private: /// The viewport allows to map the scene to a custom part /// of the render target, and can be used for split-screen /// or for displaying a minimap, for example. If the source -/// rectangle has not the same size as the viewport, its +/// rectangle doesn't have the same size as the viewport, its /// contents will be stretched to fit in. /// /// To apply a view, you have to assign it to the render target. -/// Then, every objects drawn in this render target will be +/// Then, objects drawn in this render target will be /// affected by the view until you use another view. /// /// Usage example: diff --git a/include/SFML/Main.hpp b/include/SFML/Main.hpp index 23973d0..d61b82e 100644 --- a/include/SFML/Main.hpp +++ b/include/SFML/Main.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network.hpp b/include/SFML/Network.hpp index 68507af..1deaa03 100644 --- a/include/SFML/Network.hpp +++ b/include/SFML/Network.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/Export.hpp b/include/SFML/Network/Export.hpp index 6c880f6..43adf18 100644 --- a/include/SFML/Network/Export.hpp +++ b/include/SFML/Network/Export.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/Ftp.hpp b/include/SFML/Network/Ftp.hpp index c62db7b..ad0cbc3 100644 --- a/include/SFML/Network/Ftp.hpp +++ b/include/SFML/Network/Ftp.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -529,7 +529,8 @@ private: //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - TcpSocket m_commandSocket; ///< Socket holding the control connection with the server + TcpSocket m_commandSocket; ///< Socket holding the control connection with the server + std::string m_receiveBuffer; ///< Received command data that is yet to be processed }; } // namespace sf diff --git a/include/SFML/Network/Http.hpp b/include/SFML/Network/Http.hpp index 057b86b..231da15 100644 --- a/include/SFML/Network/Http.hpp +++ b/include/SFML/Network/Http.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/IpAddress.hpp b/include/SFML/Network/IpAddress.hpp index 8205e9f..b6852a2 100644 --- a/include/SFML/Network/IpAddress.hpp +++ b/include/SFML/Network/IpAddress.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -99,7 +99,7 @@ public: /// This constructor uses the internal representation of /// the address directly. It should be used for optimization /// purposes, and only if you got that representation from - /// IpAddress::ToInteger(). + /// IpAddress::toInteger(). /// /// \param address 4 bytes of the address packed into a 32-bits integer /// @@ -182,15 +182,27 @@ public: // Static member data //////////////////////////////////////////////////////////// static const IpAddress None; ///< Value representing an empty/invalid address + static const IpAddress Any; ///< Value representing any address (0.0.0.0) static const IpAddress LocalHost; ///< The "localhost" address (for connecting a computer to itself locally) static const IpAddress Broadcast; ///< The "broadcast" address (for sending UDP messages to everyone on a local network) private: + friend SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right); + + //////////////////////////////////////////////////////////// + /// \brief Resolve the given address string + /// + /// \param address Address string + /// + //////////////////////////////////////////////////////////// + void resolve(const std::string& address); + //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// Uint32 m_address; ///< Address stored as an unsigned 32 bits integer + bool m_valid; ///< Is the address valid? }; //////////////////////////////////////////////////////////// diff --git a/include/SFML/Network/Packet.hpp b/include/SFML/Network/Packet.hpp index 0b7da9f..7810c2e 100644 --- a/include/SFML/Network/Packet.hpp +++ b/include/SFML/Network/Packet.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/Socket.hpp b/include/SFML/Network/Socket.hpp index d63f55e..57d58f7 100644 --- a/include/SFML/Network/Socket.hpp +++ b/include/SFML/Network/Socket.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/SocketHandle.hpp b/include/SFML/Network/SocketHandle.hpp index 7808ab5..5faef7a 100644 --- a/include/SFML/Network/SocketHandle.hpp +++ b/include/SFML/Network/SocketHandle.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/SocketSelector.hpp b/include/SFML/Network/SocketSelector.hpp index 4d334c6..13f9665 100644 --- a/include/SFML/Network/SocketSelector.hpp +++ b/include/SFML/Network/SocketSelector.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/TcpListener.hpp b/include/SFML/Network/TcpListener.hpp index a46ef29..1115eef 100644 --- a/include/SFML/Network/TcpListener.hpp +++ b/include/SFML/Network/TcpListener.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -30,6 +30,7 @@ //////////////////////////////////////////////////////////// #include <SFML/Network/Export.hpp> #include <SFML/Network/Socket.hpp> +#include <SFML/Network/IpAddress.hpp> namespace sf @@ -71,14 +72,15 @@ public: /// If the socket was previously listening to another port, /// it will be stopped first and bound to the new port. /// - /// \param port Port to listen for new connections + /// \param port Port to listen for new connections + /// \param address Address of the interface to listen on /// /// \return Status code /// /// \see accept, close /// //////////////////////////////////////////////////////////// - Status listen(unsigned short port); + Status listen(unsigned short port, const IpAddress& address = IpAddress::Any); //////////////////////////////////////////////////////////// /// \brief Stop listening and close the socket diff --git a/include/SFML/Network/TcpSocket.hpp b/include/SFML/Network/TcpSocket.hpp index a402506..012cca0 100644 --- a/include/SFML/Network/TcpSocket.hpp +++ b/include/SFML/Network/TcpSocket.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Network/UdpSocket.hpp b/include/SFML/Network/UdpSocket.hpp index f00c257..20cb7c6 100644 --- a/include/SFML/Network/UdpSocket.hpp +++ b/include/SFML/Network/UdpSocket.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -30,12 +30,12 @@ //////////////////////////////////////////////////////////// #include <SFML/Network/Export.hpp> #include <SFML/Network/Socket.hpp> +#include <SFML/Network/IpAddress.hpp> #include <vector> namespace sf { -class IpAddress; class Packet; //////////////////////////////////////////////////////////// @@ -82,14 +82,15 @@ public: /// system to automatically pick an available port, and then /// call getLocalPort to retrieve the chosen port. /// - /// \param port Port to bind the socket to + /// \param port Port to bind the socket to + /// \param address Address of the interface to bind to /// /// \return Status code /// /// \see unbind, getLocalPort /// //////////////////////////////////////////////////////////// - Status bind(unsigned short port); + Status bind(unsigned short port, const IpAddress& address = IpAddress::Any); //////////////////////////////////////////////////////////// /// \brief Unbind the socket from the local port to which it is bound diff --git a/include/SFML/OpenGL.hpp b/include/SFML/OpenGL.hpp index a5d964f..245d976 100644 --- a/include/SFML/OpenGL.hpp +++ b/include/SFML/OpenGL.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -67,6 +67,9 @@ #include <GLES/gl.h> #include <GLES/glext.h> + + // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension + #include <GLES2/gl2ext.h> #endif diff --git a/include/SFML/System.hpp b/include/SFML/System.hpp index 6af0652..499d423 100644 --- a/include/SFML/System.hpp +++ b/include/SFML/System.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Clock.hpp b/include/SFML/System/Clock.hpp index 684c616..1062b22 100644 --- a/include/SFML/System/Clock.hpp +++ b/include/SFML/System/Clock.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Err.hpp b/include/SFML/System/Err.hpp index 1c5b468..b2f0976 100644 --- a/include/SFML/System/Err.hpp +++ b/include/SFML/System/Err.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Export.hpp b/include/SFML/System/Export.hpp index f4adc10..df41668 100644 --- a/include/SFML/System/Export.hpp +++ b/include/SFML/System/Export.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/FileInputStream.hpp b/include/SFML/System/FileInputStream.hpp index 995351c..b4e4377 100644 --- a/include/SFML/System/FileInputStream.hpp +++ b/include/SFML/System/FileInputStream.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -136,7 +136,7 @@ private: //////////////////////////////////////////////////////////// -/// \class FileInputStream +/// \class sf::FileInputStream /// \ingroup system /// /// This class is a specialization of InputStream that @@ -153,17 +153,17 @@ private: /// /// SFML resource classes can usually be loaded directly from /// a filename, so this class shouldn't be useful to you unless -/// you create your own algorithms that operate on a InputStream. +/// you create your own algorithms that operate on an InputStream. /// /// Usage example: /// \code /// void process(InputStream& stream); /// -/// FileStream stream; +/// FileInputStream stream; /// if (stream.open("some_file.dat")) /// process(stream); /// \endcode /// -/// InputStream, MemoryStream +/// InputStream, MemoryInputStream /// //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/InputStream.hpp b/include/SFML/System/InputStream.hpp index e5694fa..ae60b2b 100644 --- a/include/SFML/System/InputStream.hpp +++ b/include/SFML/System/InputStream.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Lock.hpp b/include/SFML/System/Lock.hpp index 05dac10..d36fea6 100644 --- a/include/SFML/System/Lock.hpp +++ b/include/SFML/System/Lock.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/MemoryInputStream.hpp b/include/SFML/System/MemoryInputStream.hpp index 250466c..16e71f2 100644 --- a/include/SFML/System/MemoryInputStream.hpp +++ b/include/SFML/System/MemoryInputStream.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -116,7 +116,7 @@ private: //////////////////////////////////////////////////////////// -/// \class MemoryeInputStream +/// \class sf::MemoryInputStream /// \ingroup system /// /// This class is a specialization of InputStream that @@ -132,17 +132,17 @@ private: /// /// SFML resource classes can usually be loaded directly from /// memory, so this class shouldn't be useful to you unless -/// you create your own algorithms that operate on a InputStream. +/// you create your own algorithms that operate on an InputStream. /// /// Usage example: /// \code /// void process(InputStream& stream); /// -/// MemoryStream stream; +/// MemoryInputStream stream; /// stream.open(thePtr, theSize); /// process(stream); /// \endcode /// -/// InputStream, FileStream +/// InputStream, FileInputStream /// //////////////////////////////////////////////////////////// diff --git a/include/SFML/System/Mutex.hpp b/include/SFML/System/Mutex.hpp index 67a8473..f2abdb3 100644 --- a/include/SFML/System/Mutex.hpp +++ b/include/SFML/System/Mutex.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/NativeActivity.hpp b/include/SFML/System/NativeActivity.hpp new file mode 100644 index 0000000..59d32db --- /dev/null +++ b/include/SFML/System/NativeActivity.hpp @@ -0,0 +1,62 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) +// +// 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_NATIVEACTIVITY_HPP +#define SFML_NATIVEACTIVITY_HPP + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include <SFML/System/Export.hpp> + + +#if !defined(SFML_SYSTEM_ANDROID) +#error NativeActivity.hpp: This header is Android only. +#endif + + +struct ANativeActivity; + +namespace sf +{ +//////////////////////////////////////////////////////////// +/// \ingroup system +/// \brief Return a pointer to the Android native activity +/// +/// You shouldn't have to use this function, unless you want +/// to implement very specific details, that SFML doesn't +/// support, or to use a workaround for a known issue. +/// +/// \return Pointer to Android native activity structure +/// +/// \sfplatform{Android,SFML/System/NativeActivity.hpp} +/// +//////////////////////////////////////////////////////////// +SFML_SYSTEM_API ANativeActivity* getNativeActivity(); + +} // namespace sf + + +#endif // SFML_NATIVEACTIVITY_HPP diff --git a/include/SFML/System/NonCopyable.hpp b/include/SFML/System/NonCopyable.hpp index 9eb291c..4094376 100644 --- a/include/SFML/System/NonCopyable.hpp +++ b/include/SFML/System/NonCopyable.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Sleep.hpp b/include/SFML/System/Sleep.hpp index 3c0d04a..6da6860 100644 --- a/include/SFML/System/Sleep.hpp +++ b/include/SFML/System/Sleep.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/String.hpp b/include/SFML/System/String.hpp index 5a8c576..6001083 100644 --- a/include/SFML/System/String.hpp +++ b/include/SFML/System/String.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -30,6 +30,7 @@ //////////////////////////////////////////////////////////// #include <SFML/System/Export.hpp> #include <SFML/System/Utf.hpp> +#include <iterator> #include <locale> #include <string> diff --git a/include/SFML/System/String.inl b/include/SFML/System/String.inl index 2b22efa..9ce4017 100644 --- a/include/SFML/System/String.inl +++ b/include/SFML/System/String.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Thread.hpp b/include/SFML/System/Thread.hpp index 3321615..3a90ab6 100644 --- a/include/SFML/System/Thread.hpp +++ b/include/SFML/System/Thread.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Thread.inl b/include/SFML/System/Thread.inl index 8e0236f..180b20a 100644 --- a/include/SFML/System/Thread.inl +++ b/include/SFML/System/Thread.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/ThreadLocal.hpp b/include/SFML/System/ThreadLocal.hpp index d1f9e4f..7516702 100644 --- a/include/SFML/System/ThreadLocal.hpp +++ b/include/SFML/System/ThreadLocal.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/ThreadLocalPtr.hpp b/include/SFML/System/ThreadLocalPtr.hpp index 3ee7abf..c776b45 100644 --- a/include/SFML/System/ThreadLocalPtr.hpp +++ b/include/SFML/System/ThreadLocalPtr.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/ThreadLocalPtr.inl b/include/SFML/System/ThreadLocalPtr.inl index 1d735bf..149213d 100644 --- a/include/SFML/System/ThreadLocalPtr.inl +++ b/include/SFML/System/ThreadLocalPtr.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Time.hpp b/include/SFML/System/Time.hpp index 95a0a35..e3601fb 100644 --- a/include/SFML/System/Time.hpp +++ b/include/SFML/System/Time.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Utf.hpp b/include/SFML/System/Utf.hpp index 9e9d153..a0b0561 100644 --- a/include/SFML/System/Utf.hpp +++ b/include/SFML/System/Utf.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Utf.inl b/include/SFML/System/Utf.inl index a69ca07..b7a2ae4 100644 --- a/include/SFML/System/Utf.inl +++ b/include/SFML/System/Utf.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -322,7 +322,7 @@ In Utf<16>::decode(In begin, In end, Uint32& output, Uint32 replacement) template <typename Out> Out Utf<16>::encode(Uint32 input, Out output, Uint16 replacement) { - if (input < 0xFFFF) + if (input <= 0xFFFF) { // The character can be copied directly, we just need to check if it's in the valid range if ((input >= 0xD800) && (input <= 0xDFFF)) diff --git a/include/SFML/System/Vector2.hpp b/include/SFML/System/Vector2.hpp index 6284026..a88334d 100644 --- a/include/SFML/System/Vector2.hpp +++ b/include/SFML/System/Vector2.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Vector2.inl b/include/SFML/System/Vector2.inl index 5cc67ca..0e49e4e 100644 --- a/include/SFML/System/Vector2.inl +++ b/include/SFML/System/Vector2.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Vector3.hpp b/include/SFML/System/Vector3.hpp index 51704b8..dcde39b 100644 --- a/include/SFML/System/Vector3.hpp +++ b/include/SFML/System/Vector3.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/System/Vector3.inl b/include/SFML/System/Vector3.inl index 3c69f2c..29d3e56 100644 --- a/include/SFML/System/Vector3.inl +++ b/include/SFML/System/Vector3.inl @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window.hpp b/include/SFML/Window.hpp index 103f888..2a96efe 100644 --- a/include/SFML/Window.hpp +++ b/include/SFML/Window.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Context.hpp b/include/SFML/Window/Context.hpp index 29df67c..e59e772 100644 --- a/include/SFML/Window/Context.hpp +++ b/include/SFML/Window/Context.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -77,7 +77,28 @@ public: //////////////////////////////////////////////////////////// bool setActive(bool active); -public: + //////////////////////////////////////////////////////////// + /// \brief Get the settings of the context + /// + /// Note that these settings may be different than the ones + /// passed to the constructor; they are indeed adjusted if the + /// original settings are not directly supported by the system. + /// + /// \return Structure containing the settings + /// + //////////////////////////////////////////////////////////// + const ContextSettings& getSettings() const; + + //////////////////////////////////////////////////////////// + /// \brief Check whether a given OpenGL extension is available + /// + /// \param name Name of the extension to check for + /// + /// \return True if available, false if unavailable + /// + //////////////////////////////////////////////////////////// + static bool isExtensionAvailable(const char* name); + //////////////////////////////////////////////////////////// /// \brief Get the address of an OpenGL function /// @@ -89,6 +110,14 @@ public: static GlFunctionPointer getFunction(const char* name); //////////////////////////////////////////////////////////// + /// \brief Get the currently active context + /// + /// \return The currently active context or NULL if none is active + /// + //////////////////////////////////////////////////////////// + static const Context* getActiveContext(); + + //////////////////////////////////////////////////////////// /// \brief Construct a in-memory context /// /// This constructor is for internal use, you don't need diff --git a/include/SFML/Window/ContextSettings.hpp b/include/SFML/Window/ContextSettings.hpp index 26ea910..1dd52f2 100644 --- a/include/SFML/Window/ContextSettings.hpp +++ b/include/SFML/Window/ContextSettings.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -55,15 +55,17 @@ struct ContextSettings /// \param major Major number of the context version /// \param minor Minor number of the context version /// \param attributes Attribute flags of the context + /// \param sRgb sRGB capable framebuffer /// //////////////////////////////////////////////////////////// - explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 1, unsigned int minor = 1, unsigned int attributes = Default) : + explicit ContextSettings(unsigned int depth = 0, unsigned int stencil = 0, unsigned int antialiasing = 0, unsigned int major = 1, unsigned int minor = 1, unsigned int attributes = Default, bool sRgb = false) : depthBits (depth), stencilBits (stencil), antialiasingLevel(antialiasing), majorVersion (major), minorVersion (minor), - attributeFlags (attributes) + attributeFlags (attributes), + sRgbCapable (sRgb) { } @@ -76,6 +78,7 @@ struct ContextSettings unsigned int majorVersion; ///< Major number of the context version to create unsigned int minorVersion; ///< Minor number of the context version to create Uint32 attributeFlags; ///< The attribute flags to create the context with + bool sRgbCapable; ///< Whether the context framebuffer is sRGB capable }; } // namespace sf diff --git a/include/SFML/Window/Event.hpp b/include/SFML/Window/Event.hpp index 5fc9a10..0850adf 100644 --- a/include/SFML/Window/Event.hpp +++ b/include/SFML/Window/Event.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Export.hpp b/include/SFML/Window/Export.hpp index 4a708ec..e09f995 100644 --- a/include/SFML/Window/Export.hpp +++ b/include/SFML/Window/Export.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/GlResource.hpp b/include/SFML/Window/GlResource.hpp index a341f64..9deb35a 100644 --- a/include/SFML/Window/GlResource.hpp +++ b/include/SFML/Window/GlResource.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Joystick.hpp b/include/SFML/Window/Joystick.hpp index 27f6291..463daf0 100644 --- a/include/SFML/Window/Joystick.hpp +++ b/include/SFML/Window/Joystick.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Keyboard.hpp b/include/SFML/Window/Keyboard.hpp index b3186e9..2adad91 100644 --- a/include/SFML/Window/Keyboard.hpp +++ b/include/SFML/Window/Keyboard.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Mouse.hpp b/include/SFML/Window/Mouse.hpp index 0056f8c..c83d6fa 100644 --- a/include/SFML/Window/Mouse.hpp +++ b/include/SFML/Window/Mouse.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Sensor.hpp b/include/SFML/Window/Sensor.hpp index 6078881..1fd23b3 100644 --- a/include/SFML/Window/Sensor.hpp +++ b/include/SFML/Window/Sensor.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Touch.hpp b/include/SFML/Window/Touch.hpp index bf44f43..933523e 100644 --- a/include/SFML/Window/Touch.hpp +++ b/include/SFML/Window/Touch.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -71,7 +71,7 @@ public: /// \brief Get the current position of a touch in window coordinates /// /// This function returns the current touch position - /// in global (desktop) coordinates. + /// relative to the given window. /// /// \param finger Finger index /// \param relativeTo Reference window diff --git a/include/SFML/Window/VideoMode.hpp b/include/SFML/Window/VideoMode.hpp index 5eb268c..31c3a20 100644 --- a/include/SFML/Window/VideoMode.hpp +++ b/include/SFML/Window/VideoMode.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. diff --git a/include/SFML/Window/Window.hpp b/include/SFML/Window/Window.hpp index 44f0752..0839287 100644 --- a/include/SFML/Window/Window.hpp +++ b/include/SFML/Window/Window.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -98,8 +98,7 @@ public: /// advanced OpenGL context settings such as antialiasing, /// depth-buffer bits, etc. /// - /// \param handle Platform-specific handle of the control (\a HWND on - /// Windows, \a %Window on Linux/FreeBSD, \a NSWindow on OS X) + /// \param handle Platform-specific handle of the control /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// @@ -143,8 +142,7 @@ public: /// advanced OpenGL context settings such as antialiasing, /// depth-buffer bits, etc. /// - /// \param handle Platform-specific handle of the control (\a HWND on - /// Windows, \a %Window on Linux/FreeBSD, \a NSWindow on OS X) + /// \param handle Platform-specific handle of the control /// \param settings Additional settings for the underlying OpenGL context /// //////////////////////////////////////////////////////////// @@ -351,6 +349,21 @@ public: void setMouseCursorVisible(bool visible); //////////////////////////////////////////////////////////// + /// \brief Grab or release the mouse cursor + /// + /// If set, grabs the mouse cursor inside this window's client + /// area so it may no longer be moved outside its bounds. + /// Note that grabbing is only active while the window has + /// focus and calling this function for fullscreen windows + /// won't have any effect (fullscreen windows always grab the + /// cursor). + /// + /// \param grabbed True to enable, false to disable + /// + //////////////////////////////////////////////////////////// + void setMouseCursorGrabbed(bool grabbed); + + //////////////////////////////////////////////////////////// /// \brief Enable or disable automatic key-repeat /// /// If key repeat is enabled, you will receive repeated @@ -459,8 +472,6 @@ public: /// You shouldn't need to use this function, unless you have /// very specific stuff to implement that SFML doesn't support, /// or implement a temporary workaround until a bug is fixed. - /// The type is \a HWND on Windows, \a %Window on Linux/FreeBSD - /// and \a NSWindow on OS X. /// /// \return System handle of the window /// diff --git a/include/SFML/Window/WindowHandle.hpp b/include/SFML/Window/WindowHandle.hpp index 9da3042..c8b0149 100644 --- a/include/SFML/Window/WindowHandle.hpp +++ b/include/SFML/Window/WindowHandle.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. @@ -37,10 +37,6 @@ namespace sf { -//////////////////////////////////////////////////////////// -/// Define a low-level window handle type, specific to -/// each platform -//////////////////////////////////////////////////////////// #if defined(SFML_SYSTEM_WINDOWS) // Window handle is HWND (HWND__*) on Windows @@ -53,7 +49,7 @@ namespace sf #elif defined(SFML_SYSTEM_MACOS) - // Window handle is NSWindow (void*) on Mac OS X - Cocoa + // Window handle is NSWindow or NSView (void*) on Mac OS X - Cocoa typedef void* WindowHandle; #elif defined(SFML_SYSTEM_IOS) @@ -63,12 +59,43 @@ namespace sf #elif defined(SFML_SYSTEM_ANDROID) - // Window handle is ANativeWindow (void*) on Android + // Window handle is ANativeWindow* (void*) on Android typedef void* WindowHandle; +#elif defined(SFML_DOXYGEN) + + // Define typedef symbol so that Doxygen can attach some documentation to it + typedef "platform–specific" WindowHandle; + #endif } // namespace sf #endif // SFML_WINDOWHANDLE_HPP + +//////////////////////////////////////////////////////////// +/// \typedef sf::WindowHandle +/// \ingroup window +/// +/// Define a low-level window handle type, specific to +/// each platform. +/// +/// Platform | Type +/// ----------------|------------------------------------------------------------ +/// Windows | \p HWND +/// Linux/FreeBSD | \p %Window +/// Mac OS X | either \p NSWindow* or \p NSView*, disguised as \p void* +/// iOS | \p UIWindow* +/// Android | \p ANativeWindow* +/// +/// \par Mac OS X Specification +/// +/// On Mac OS X, a sf::Window can be created either from an +/// existing \p NSWindow* or an \p NSView*. When the window +/// is created from a window, SFML will use its content view +/// as the OpenGL area. sf::Window::getSystemHandle() will +/// return the handle that was used to create the window, +/// which is a \p NSWindow* by default. +/// +//////////////////////////////////////////////////////////// diff --git a/include/SFML/Window/WindowStyle.hpp b/include/SFML/Window/WindowStyle.hpp index b9253db..3b182a9 100644 --- a/include/SFML/Window/WindowStyle.hpp +++ b/include/SFML/Window/WindowStyle.hpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org) +// Copyright (C) 2007-2016 Laurent Gomila (laurent@sfml-dev.org) // // 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. |