Reviewed the sf::BlendMode class (added a constructor, made minor modifications in comments)
This commit is contained in:
parent
ec494babbe
commit
f99bbfc534
@ -35,14 +35,12 @@ namespace sf
|
|||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \ingroup graphics
|
|
||||||
/// \brief Blending modes for drawing
|
/// \brief Blending modes for drawing
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
struct SFML_GRAPHICS_API BlendMode
|
struct SFML_GRAPHICS_API BlendMode
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
/// \ingroup graphics
|
|
||||||
/// \brief Enumeration of the blending factors
|
/// \brief Enumeration of the blending factors
|
||||||
///
|
///
|
||||||
/// The factors are mapped directly to their OpenGL equivalents,
|
/// The factors are mapped directly to their OpenGL equivalents,
|
||||||
@ -63,7 +61,6 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
/// \ingroup graphics
|
|
||||||
/// \brief Enumeration of the blending equations
|
/// \brief Enumeration of the blending equations
|
||||||
///
|
///
|
||||||
/// The equations are mapped directly to their OpenGL equivalents,
|
/// The equations are mapped directly to their OpenGL equivalents,
|
||||||
@ -83,6 +80,19 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
BlendMode();
|
BlendMode();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Construct the blend mode given the factors and equation.
|
||||||
|
///
|
||||||
|
/// This constructor uses the same factors and equation for both
|
||||||
|
/// color and alpha components. It also defaults to the Add equation.
|
||||||
|
///
|
||||||
|
/// \param sourceFactor Specifies how to compute the source factor for the color and alpha channels.
|
||||||
|
/// \param destinationFactor Specifies how to compute the destination factor for the color and alpha channels.
|
||||||
|
/// \param blendEquation Specifies how to combine the source and destination colors and alpha.
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct the blend mode given the factors and equation.
|
/// \brief Construct the blend mode given the factors and equation.
|
||||||
///
|
///
|
||||||
@ -133,14 +143,13 @@ SFML_GRAPHICS_API bool operator ==(const BlendMode& left, const BlendMode& right
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFML_GRAPHICS_API bool operator !=(const BlendMode& left, const BlendMode& right);
|
SFML_GRAPHICS_API bool operator !=(const BlendMode& left, const BlendMode& right);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Commonly used blending modes
|
// Commonly used blending modes
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SFML_GRAPHICS_API extern const BlendMode BlendAlpha;
|
SFML_GRAPHICS_API extern const BlendMode BlendAlpha; ///< Blend source and dest according to dest alpha
|
||||||
SFML_GRAPHICS_API extern const BlendMode BlendAdd;
|
SFML_GRAPHICS_API extern const BlendMode BlendAdd; ///< Add source to dest
|
||||||
SFML_GRAPHICS_API extern const BlendMode BlendMultiply;
|
SFML_GRAPHICS_API extern const BlendMode BlendMultiply; ///< Multiply source and dest
|
||||||
SFML_GRAPHICS_API extern const BlendMode BlendNone;
|
SFML_GRAPHICS_API extern const BlendMode BlendNone; ///< Overwrite dest with source
|
||||||
|
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
|
||||||
|
@ -37,10 +37,8 @@ const BlendMode BlendAlpha(BlendMode::SrcAlpha, BlendMode::OneMinusSrcAlpha, Ble
|
|||||||
BlendMode::One, BlendMode::OneMinusSrcAlpha, BlendMode::Add);
|
BlendMode::One, BlendMode::OneMinusSrcAlpha, BlendMode::Add);
|
||||||
const BlendMode BlendAdd(BlendMode::SrcAlpha, BlendMode::One, BlendMode::Add,
|
const BlendMode BlendAdd(BlendMode::SrcAlpha, BlendMode::One, BlendMode::Add,
|
||||||
BlendMode::One, BlendMode::One, BlendMode::Add);
|
BlendMode::One, BlendMode::One, BlendMode::Add);
|
||||||
const BlendMode BlendMultiply(BlendMode::DstColor, BlendMode::Zero, BlendMode::Add,
|
const BlendMode BlendMultiply(BlendMode::DstColor, BlendMode::Zero);
|
||||||
BlendMode::DstColor, BlendMode::Zero, BlendMode::Add);
|
const BlendMode BlendNone(BlendMode::One, BlendMode::Zero);
|
||||||
const BlendMode BlendNone(BlendMode::One, BlendMode::Zero, BlendMode::Add,
|
|
||||||
BlendMode::One, BlendMode::Zero, BlendMode::Add);
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -56,6 +54,19 @@ alphaEquation (BlendMode::Add)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
BlendMode::BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation) :
|
||||||
|
colorSrcFactor(sourceFactor),
|
||||||
|
colorDstFactor(destinationFactor),
|
||||||
|
colorEquation (blendEquation),
|
||||||
|
alphaSrcFactor(sourceFactor),
|
||||||
|
alphaDstFactor(destinationFactor),
|
||||||
|
alphaEquation (blendEquation)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
BlendMode::BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
|
BlendMode::BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor,
|
||||||
Equation colorBlendEquation, Factor alphaSourceFactor,
|
Equation colorBlendEquation, Factor alphaSourceFactor,
|
||||||
|
Loading…
Reference in New Issue
Block a user