2011-12-02 06:24:58 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// SFML - Simple and Fast Multimedia Library
|
2014-02-07 02:35:47 +08:00
|
|
|
// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
|
2011-12-02 06:24:58 +08:00
|
|
|
//
|
|
|
|
// 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_BLENDMODE_HPP
|
|
|
|
#define SFML_BLENDMODE_HPP
|
|
|
|
|
2014-01-21 09:52:45 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Headers
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
#include <SFML/Graphics/Export.hpp>
|
|
|
|
|
|
|
|
|
2011-12-02 06:24:58 +08:00
|
|
|
namespace sf
|
|
|
|
{
|
2014-01-21 09:52:45 +08:00
|
|
|
|
2011-12-02 06:24:58 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \ingroup graphics
|
2014-01-21 09:52:45 +08:00
|
|
|
/// \brief Blending modes for drawing
|
2011-12-02 06:24:58 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2014-01-21 09:52:45 +08:00
|
|
|
struct SFML_GRAPHICS_API BlendMode
|
2011-12-02 06:24:58 +08:00
|
|
|
{
|
2014-01-21 09:52:45 +08:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
/// \ingroup graphics
|
|
|
|
/// \brief Enumeration of the blending factors
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////
|
2014-03-12 19:22:47 +08:00
|
|
|
enum Factor
|
2014-01-21 09:52:45 +08:00
|
|
|
{
|
2014-03-16 17:50:27 +08:00
|
|
|
Zero, ///< (0, 0, 0, 0)
|
|
|
|
One, ///< (1, 1, 1, 1)
|
|
|
|
SrcColor, ///< (src.r, src.g, src.b, src.a)
|
|
|
|
OneMinusSrcColor, ///< (1, 1, 1, 1) - (src.r, src.g, src.b, src.a)
|
|
|
|
DstColor, ///< (dst.r, dst.g, dst.b, dst.a)
|
|
|
|
OneMinusDstColor, ///< (1, 1, 1, 1) - (dst.r, dst.g, dst.b, dst.a)
|
|
|
|
SrcAlpha, ///< (src.a, src.a, src.a, src.a)
|
|
|
|
OneMinusSrcAlpha, ///< (1, 1, 1, 1) - (src.a, src.a, src.a, src.a)
|
|
|
|
DstAlpha, ///< (dst.a, dst.a, dst.a, dst.a)
|
|
|
|
OneMinusDstAlpha ///< (1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a)
|
2014-01-21 09:52:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
/// \ingroup graphics
|
|
|
|
/// \brief Enumeration of the blending equations
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////
|
2014-03-12 19:22:47 +08:00
|
|
|
enum Equation
|
2014-01-21 09:52:45 +08:00
|
|
|
{
|
2014-03-16 17:50:27 +08:00
|
|
|
Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor
|
|
|
|
Subtract ///< Pixel = Src * SrcFactor - Dst * DstFactor
|
2014-01-21 09:52:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Default constructor
|
|
|
|
///
|
|
|
|
/// Constructs a blending mode that does alpha blending.
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
BlendMode();
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \brief Construct the blend mode given the factors and equation.
|
|
|
|
///
|
2014-03-12 19:08:24 +08:00
|
|
|
/// \param colorSourceFactor Specifies how to compute the source factor for the color channels.
|
|
|
|
/// \param colorDestinationFactor Specifies how to compute the destination factor for the color channels.
|
|
|
|
/// \param colorBlendEquation Specifies how to combine the source and destination colors.
|
|
|
|
/// \param alphaSourceFactor Specifies how to compute the source factor.
|
|
|
|
/// \param alphaDestinationFactor Specifies how to compute the destination factor.
|
|
|
|
/// \param alphaBlendEquation Specifies how to combine the source and destination alphas.
|
2014-01-21 09:52:45 +08:00
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
2014-03-12 19:22:47 +08:00
|
|
|
BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
|
2014-03-16 17:50:27 +08:00
|
|
|
Equation colorBlendEquation, Factor alphaSourceFactor,
|
|
|
|
Factor alphaDestinationFactor, Equation alphaBlendEquation);
|
2014-01-21 09:52:45 +08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Member Data
|
|
|
|
////////////////////////////////////////////////////////////
|
2014-03-16 17:50:27 +08:00
|
|
|
Factor colorSrcFactor; ///< Source blending factor for the color channels
|
|
|
|
Factor colorDstFactor; ///< Destination blending factor for the color channels
|
|
|
|
Equation colorEquation; ///< Blending equation for the color channels
|
|
|
|
Factor alphaSrcFactor; ///< Source blending factor for the alpha channel
|
|
|
|
Factor alphaDstFactor; ///< Destination blending factor for the alpha channel
|
|
|
|
Equation alphaEquation; ///< Blending equation for the alpha channel
|
2011-12-02 06:24:58 +08:00
|
|
|
};
|
|
|
|
|
2014-01-21 09:52:45 +08:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \relates BlendMode
|
|
|
|
/// \brief Overload of the == operator
|
|
|
|
///
|
|
|
|
/// \param left Left operand
|
|
|
|
/// \param right Right operand
|
|
|
|
///
|
|
|
|
/// \return True if blending modes are equal, false if they are different
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
SFML_GRAPHICS_API bool operator ==(const BlendMode& left, const BlendMode& right);
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \relates BlendMode
|
|
|
|
/// \brief Overload of the != operator
|
|
|
|
///
|
|
|
|
/// \param left Left operand
|
|
|
|
/// \param right Right operand
|
|
|
|
///
|
|
|
|
/// \return True if blending modes are different, false if they are equal
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
SFML_GRAPHICS_API bool operator !=(const BlendMode& left, const BlendMode& right);
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Commonly used blending modes
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
SFML_GRAPHICS_API extern const BlendMode BlendAlpha;
|
|
|
|
SFML_GRAPHICS_API extern const BlendMode BlendAdd;
|
|
|
|
SFML_GRAPHICS_API extern const BlendMode BlendMultiply;
|
|
|
|
SFML_GRAPHICS_API extern const BlendMode BlendNone;
|
|
|
|
|
2011-12-02 06:24:58 +08:00
|
|
|
} // namespace sf
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SFML_BLENDMODE_HPP
|
2014-01-21 09:52:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
/// \class sf::BlendMode
|
|
|
|
/// \ingroup graphics
|
|
|
|
///
|
|
|
|
/// sf::BlendMode is a class that represents a blend mode. A
|
|
|
|
/// blend mode is composed of 6 components:
|
|
|
|
/// \li %Color Source Factor (colorSrcFactor)
|
|
|
|
/// \li %Color Destination Factor (colorDstFactor)
|
|
|
|
/// \li %Color Blend Equation (colorEquation)
|
|
|
|
/// \li Alpha Source Factor (alphaSrcFactor)
|
|
|
|
/// \li Alpha Destination Factor (alphaDstFactor)
|
|
|
|
/// \li Alpha Blend Equation (alphaEquation)
|
|
|
|
///
|
2014-03-12 19:08:24 +08:00
|
|
|
/// Each component has its own public member variable. These make
|
2014-01-21 09:52:45 +08:00
|
|
|
/// modifying a blending mode rather easy:
|
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// sf::BlendMode blendMode; // Standard alpha blending
|
|
|
|
/// blendMode.colorSrcFactor = sf::BlendMode::One; // Pre-multiplied alpha blending
|
|
|
|
/// blendMode.colorEquation = sf::BlendMode::Subtract; // An exotic subtraction blending mode
|
|
|
|
/// \endcode
|
|
|
|
///
|
2014-03-12 19:08:24 +08:00
|
|
|
/// The most common blending modes are defined as constants
|
|
|
|
/// in the sf namespace, for convenience and compatibility with
|
|
|
|
/// older code:
|
2014-01-21 09:52:45 +08:00
|
|
|
///
|
|
|
|
/// \code
|
|
|
|
/// sf::BlendMode alphaBlending = sf::BlendAlpha;
|
|
|
|
/// sf::BlendMode additiveBlending = sf::BlendAdd;
|
|
|
|
/// sf::BlendMode multiplicativeBlending = sf::BlendMultipy;
|
|
|
|
/// sf::BlendMode noBlending = sf::BlendNone;
|
|
|
|
/// \endcode
|
|
|
|
///
|
|
|
|
////////////////////////////////////////////////////////////
|