diff --git a/include/SFML/Graphics/BlendMode.hpp b/include/SFML/Graphics/BlendMode.hpp index f5deca84c..4e4a167ed 100644 --- a/include/SFML/Graphics/BlendMode.hpp +++ b/include/SFML/Graphics/BlendMode.hpp @@ -57,7 +57,7 @@ struct SFML_GRAPHICS_API BlendMode 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) + OneMinusDstAlpha ///< (1,1,1,1) - (dst.a,dst.a,dst.a,dst.a) }; //////////////////////////////////////////////////////// @@ -67,8 +67,8 @@ struct SFML_GRAPHICS_API BlendMode //////////////////////////////////////////////////////// enum BlendEquation { - Add, ///< Pixel = Source * SourceFactor + Dst * DstFactor - Subtract, ///< Pixel = Source * SourceFactor - Dst * DstFactor + Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor + Subtract ///< Pixel = Src * SrcFactor - Dst * DstFactor }; //////////////////////////////////////////////////////////// @@ -82,18 +82,17 @@ struct SFML_GRAPHICS_API BlendMode //////////////////////////////////////////////////////////// /// \brief Construct the blend mode given the factors and equation. /// - /// \param colorSourceFactor Specifies how to compute the source factor for the color channels. - /// \param colorDstFactor 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 alphaDstFactor Specifies how to compute the destination factor. - /// \param alphaBlendEquation Specifies how to combine the source and destination alphas. - /// + /// \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. /// //////////////////////////////////////////////////////////// - BlendMode(BlendFactor colorSourceFactor, BlendFactor colorDstFactor, + BlendMode(BlendFactor colorSourceFactor, BlendFactor colorDestinationFactor, BlendEquation colorBlendEquation, BlendFactor alphaSourceFactor, - BlendFactor alphaDstFactor, BlendEquation alphaBlendEquation); + BlendFactor alphaDestinationFactor, BlendEquation alphaBlendEquation); //////////////////////////////////////////////////////////// // Member Data @@ -110,8 +109,6 @@ struct SFML_GRAPHICS_API BlendMode /// \relates BlendMode /// \brief Overload of the == operator /// -/// This operator compares two blending modes and checks if they are equal. -/// /// \param left Left operand /// \param right Right operand /// @@ -124,8 +121,6 @@ SFML_GRAPHICS_API bool operator ==(const BlendMode& left, const BlendMode& right /// \relates BlendMode /// \brief Overload of the != operator /// -/// This operator compares two blending modes and checks if they are different. -/// /// \param left Left operand /// \param right Right operand /// @@ -162,7 +157,7 @@ SFML_GRAPHICS_API extern const BlendMode BlendNone; /// \li Alpha Destination Factor (alphaDstFactor) /// \li Alpha Blend Equation (alphaEquation) /// -/// Each component has its own setter function. These make +/// Each component has its own public member variable. These make /// modifying a blending mode rather easy: /// /// \code @@ -171,9 +166,9 @@ SFML_GRAPHICS_API extern const BlendMode BlendNone; /// blendMode.colorEquation = sf::BlendMode::Subtract; // An exotic subtraction blending mode /// \endcode /// -/// The most common blending modes are defined as const -/// variables for convenience and compatibility with older -/// code: +/// The most common blending modes are defined as constants +/// in the sf namespace, for convenience and compatibility with +/// older code: /// /// \code /// sf::BlendMode alphaBlending = sf::BlendAlpha; diff --git a/include/SFML/Graphics/RenderTarget.hpp b/include/SFML/Graphics/RenderTarget.hpp index 8995d12c5..033e2c78c 100644 --- a/include/SFML/Graphics/RenderTarget.hpp +++ b/include/SFML/Graphics/RenderTarget.hpp @@ -354,7 +354,7 @@ private: /// \param mode Blending mode to apply /// //////////////////////////////////////////////////////////// - void applyBlendMode(BlendMode mode); + void applyBlendMode(const BlendMode& mode); //////////////////////////////////////////////////////////// /// \brief Apply a new transform diff --git a/src/SFML/Graphics/BlendMode.cpp b/src/SFML/Graphics/BlendMode.cpp index 4145a228d..9a7ab2279 100644 --- a/src/SFML/Graphics/BlendMode.cpp +++ b/src/SFML/Graphics/BlendMode.cpp @@ -1,7 +1,7 @@ //////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com) +// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com) // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the use of this software. @@ -26,7 +26,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include namespace sf @@ -58,14 +57,14 @@ alphaEquation (BlendMode::Add) //////////////////////////////////////////////////////////// -BlendMode::BlendMode(BlendFactor colorSourceFactor, BlendFactor colorDstFactor, +BlendMode::BlendMode(BlendFactor colorSourceFactor, BlendFactor colorDestinationFactor, BlendEquation colorBlendEquation, BlendFactor alphaSourceFactor, - BlendFactor alphaDstFactor, BlendEquation alphaBlendEquation) : + BlendFactor alphaDestinationFactor, BlendEquation alphaBlendEquation) : colorSrcFactor(colorSourceFactor), -colorDstFactor(colorDstFactor), +colorDstFactor(colorDestinationFactor), colorEquation (colorBlendEquation), alphaSrcFactor(alphaSourceFactor), -alphaDstFactor(alphaDstFactor), +alphaDstFactor(alphaDestinationFactor), alphaEquation (alphaBlendEquation) { diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index 3e756c8cf..4209ce7be 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -388,22 +388,32 @@ void RenderTarget::applyCurrentView() //////////////////////////////////////////////////////////// -void RenderTarget::applyBlendMode(BlendMode mode) +void RenderTarget::applyBlendMode(const BlendMode& mode) { // Apply the blend mode, falling back to the non-separate versions if necessary if (GLEW_EXT_blend_func_separate) - glCheck(glBlendFuncSeparateEXT(factorToGlConstant(mode.colorSrcFactor), - factorToGlConstant(mode.colorDstFactor), factorToGlConstant(mode.alphaSrcFactor), - factorToGlConstant(mode.alphaDstFactor))); + { + glCheck(glBlendFuncSeparateEXT( + factorToGlConstant(mode.colorSrcFactor), factorToGlConstant(mode.colorDstFactor), + factorToGlConstant(mode.alphaSrcFactor), factorToGlConstant(mode.alphaDstFactor))); + } else - glCheck(glBlendFunc(factorToGlConstant(mode.colorSrcFactor), + { + glCheck(glBlendFunc( + factorToGlConstant(mode.colorSrcFactor), factorToGlConstant(mode.colorDstFactor))); + } if (GLEW_EXT_blend_equation_separate) - glCheck(glBlendEquationSeparateEXT(equationToGlConstant(mode.colorEquation), + { + glCheck(glBlendEquationSeparateEXT( + equationToGlConstant(mode.colorEquation), equationToGlConstant(mode.alphaEquation))); + } else + { glCheck(glBlendEquation(equationToGlConstant(mode.colorEquation))); + } m_cache.lastBlendMode = mode; }