mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Make BlendMode::Factor and BlendMode::Equation scoped enumerations
This commit is contained in:
parent
3ca42c9a45
commit
b496877c90
@ -45,7 +45,7 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
/// The factors are mapped directly to their OpenGL equivalents,
|
/// The factors are mapped directly to their OpenGL equivalents,
|
||||||
/// specified by glBlendFunc() or glBlendFuncSeparate().
|
/// specified by glBlendFunc() or glBlendFuncSeparate().
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
enum Factor
|
enum class Factor
|
||||||
{
|
{
|
||||||
Zero, //!< (0, 0, 0, 0)
|
Zero, //!< (0, 0, 0, 0)
|
||||||
One, //!< (1, 1, 1, 1)
|
One, //!< (1, 1, 1, 1)
|
||||||
@ -65,7 +65,7 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
/// The equations are mapped directly to their OpenGL equivalents,
|
/// The equations are mapped directly to their OpenGL equivalents,
|
||||||
/// specified by glBlendEquation() or glBlendEquationSeparate().
|
/// specified by glBlendEquation() or glBlendEquationSeparate().
|
||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
enum Equation
|
enum class Equation
|
||||||
{
|
{
|
||||||
Add, //!< Pixel = Src * SrcFactor + Dst * DstFactor
|
Add, //!< Pixel = Src * SrcFactor + Dst * DstFactor
|
||||||
Subtract, //!< Pixel = Src * SrcFactor - Dst * DstFactor
|
Subtract, //!< Pixel = Src * SrcFactor - Dst * DstFactor
|
||||||
@ -93,7 +93,7 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
/// \param blendEquation Specifies how to combine the source and destination colors and alpha.
|
/// \param blendEquation Specifies how to combine the source and destination colors and alpha.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);
|
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Equation::Add);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct the blend mode given the factors and equation.
|
/// \brief Construct the blend mode given the factors and equation.
|
||||||
@ -116,12 +116,12 @@ struct SFML_GRAPHICS_API BlendMode
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member Data
|
// Member Data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Factor colorSrcFactor{BlendMode::SrcAlpha}; //!< Source blending factor for the color channels
|
Factor colorSrcFactor{BlendMode::Factor::SrcAlpha}; //!< Source blending factor for the color channels
|
||||||
Factor colorDstFactor{BlendMode::OneMinusSrcAlpha}; //!< Destination blending factor for the color channels
|
Factor colorDstFactor{BlendMode::Factor::OneMinusSrcAlpha}; //!< Destination blending factor for the color channels
|
||||||
Equation colorEquation{BlendMode::Add}; //!< Blending equation for the color channels
|
Equation colorEquation{BlendMode::Equation::Add}; //!< Blending equation for the color channels
|
||||||
Factor alphaSrcFactor{BlendMode::One}; //!< Source blending factor for the alpha channel
|
Factor alphaSrcFactor{BlendMode::Factor::One}; //!< Source blending factor for the alpha channel
|
||||||
Factor alphaDstFactor{BlendMode::OneMinusSrcAlpha}; //!< Destination blending factor for the alpha channel
|
Factor alphaDstFactor{BlendMode::Factor::OneMinusSrcAlpha}; //!< Destination blending factor for the alpha channel
|
||||||
Equation alphaEquation{BlendMode::Add}; //!< Blending equation for the alpha channel
|
Equation alphaEquation{BlendMode::Equation::Add}; //!< Blending equation for the alpha channel
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -33,17 +33,22 @@ namespace sf
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Commonly used blending modes
|
// Commonly used blending modes
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const BlendMode BlendAlpha(BlendMode::SrcAlpha,
|
const BlendMode BlendAlpha(BlendMode::Factor::SrcAlpha,
|
||||||
BlendMode::OneMinusSrcAlpha,
|
BlendMode::Factor::OneMinusSrcAlpha,
|
||||||
BlendMode::Add,
|
BlendMode::Equation::Add,
|
||||||
BlendMode::One,
|
BlendMode::Factor::One,
|
||||||
BlendMode::OneMinusSrcAlpha,
|
BlendMode::Factor::OneMinusSrcAlpha,
|
||||||
BlendMode::Add);
|
BlendMode::Equation::Add);
|
||||||
const BlendMode BlendAdd(BlendMode::SrcAlpha, BlendMode::One, BlendMode::Add, BlendMode::One, BlendMode::One, BlendMode::Add);
|
const BlendMode BlendAdd(BlendMode::Factor::SrcAlpha,
|
||||||
const BlendMode BlendMultiply(BlendMode::DstColor, BlendMode::Zero, BlendMode::Add);
|
BlendMode::Factor::One,
|
||||||
const BlendMode BlendMin(BlendMode::One, BlendMode::One, BlendMode::Min);
|
BlendMode::Equation::Add,
|
||||||
const BlendMode BlendMax(BlendMode::One, BlendMode::One, BlendMode::Max);
|
BlendMode::Factor::One,
|
||||||
const BlendMode BlendNone(BlendMode::One, BlendMode::Zero, BlendMode::Add);
|
BlendMode::Factor::One,
|
||||||
|
BlendMode::Equation::Add);
|
||||||
|
const BlendMode BlendMultiply(BlendMode::Factor::DstColor, BlendMode::Factor::Zero, BlendMode::Equation::Add);
|
||||||
|
const BlendMode BlendMin(BlendMode::Factor::One, BlendMode::Factor::One, BlendMode::Equation::Min);
|
||||||
|
const BlendMode BlendMax(BlendMode::Factor::One, BlendMode::Factor::One, BlendMode::Equation::Max);
|
||||||
|
const BlendMode BlendNone(BlendMode::Factor::One, BlendMode::Factor::Zero, BlendMode::Equation::Add);
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -36,12 +36,12 @@ namespace sf
|
|||||||
// We cannot use the default constructor here, because it accesses BlendAlpha, which is also global (and dynamically
|
// We cannot use the default constructor here, because it accesses BlendAlpha, which is also global (and dynamically
|
||||||
// initialized). Initialization order of global objects in different translation units is not defined.
|
// initialized). Initialization order of global objects in different translation units is not defined.
|
||||||
const RenderStates RenderStates::Default(BlendMode(
|
const RenderStates RenderStates::Default(BlendMode(
|
||||||
BlendMode::SrcAlpha,
|
BlendMode::Factor::SrcAlpha,
|
||||||
BlendMode::OneMinusSrcAlpha,
|
BlendMode::Factor::OneMinusSrcAlpha,
|
||||||
BlendMode::Add,
|
BlendMode::Equation::Add,
|
||||||
BlendMode::One,
|
BlendMode::Factor::One,
|
||||||
BlendMode::OneMinusSrcAlpha,
|
BlendMode::Factor::OneMinusSrcAlpha,
|
||||||
BlendMode::Add));
|
BlendMode::Equation::Add));
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -91,45 +91,45 @@ std::uint32_t factorToGlConstant(sf::BlendMode::Factor blendFactor)
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
switch (blendFactor)
|
switch (blendFactor)
|
||||||
{
|
{
|
||||||
case sf::BlendMode::Zero: return GL_ZERO;
|
case sf::BlendMode::Factor::Zero: return GL_ZERO;
|
||||||
case sf::BlendMode::One: return GL_ONE;
|
case sf::BlendMode::Factor::One: return GL_ONE;
|
||||||
case sf::BlendMode::SrcColor: return GL_SRC_COLOR;
|
case sf::BlendMode::Factor::SrcColor: return GL_SRC_COLOR;
|
||||||
case sf::BlendMode::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
|
case sf::BlendMode::Factor::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
|
||||||
case sf::BlendMode::DstColor: return GL_DST_COLOR;
|
case sf::BlendMode::Factor::DstColor: return GL_DST_COLOR;
|
||||||
case sf::BlendMode::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
|
case sf::BlendMode::Factor::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
|
||||||
case sf::BlendMode::SrcAlpha: return GL_SRC_ALPHA;
|
case sf::BlendMode::Factor::SrcAlpha: return GL_SRC_ALPHA;
|
||||||
case sf::BlendMode::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
|
case sf::BlendMode::Factor::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
|
||||||
case sf::BlendMode::DstAlpha: return GL_DST_ALPHA;
|
case sf::BlendMode::Factor::DstAlpha: return GL_DST_ALPHA;
|
||||||
case sf::BlendMode::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
case sf::BlendMode::Factor::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
||||||
}
|
}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
sf::err() << "Invalid value for sf::BlendMode::Factor! Fallback to sf::BlendMode::Zero." << std::endl;
|
sf::err() << "Invalid value for sf::BlendMode::Factor! Fallback to sf::BlendMode::Factor::Zero." << std::endl;
|
||||||
assert(false);
|
assert(false);
|
||||||
return GL_ZERO;
|
return GL_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert an sf::BlendMode::BlendEquation constant to the corresponding OpenGL constant.
|
// Convert an sf::BlendMode::Equation constant to the corresponding OpenGL constant.
|
||||||
std::uint32_t equationToGlConstant(sf::BlendMode::Equation blendEquation)
|
std::uint32_t equationToGlConstant(sf::BlendMode::Equation blendEquation)
|
||||||
{
|
{
|
||||||
switch (blendEquation)
|
switch (blendEquation)
|
||||||
{
|
{
|
||||||
case sf::BlendMode::Add:
|
case sf::BlendMode::Equation::Add:
|
||||||
return GLEXT_GL_FUNC_ADD;
|
return GLEXT_GL_FUNC_ADD;
|
||||||
case sf::BlendMode::Subtract:
|
case sf::BlendMode::Equation::Subtract:
|
||||||
if (GLEXT_blend_subtract)
|
if (GLEXT_blend_subtract)
|
||||||
return GLEXT_GL_FUNC_SUBTRACT;
|
return GLEXT_GL_FUNC_SUBTRACT;
|
||||||
break;
|
break;
|
||||||
case sf::BlendMode::ReverseSubtract:
|
case sf::BlendMode::Equation::ReverseSubtract:
|
||||||
if (GLEXT_blend_subtract)
|
if (GLEXT_blend_subtract)
|
||||||
return GLEXT_GL_FUNC_REVERSE_SUBTRACT;
|
return GLEXT_GL_FUNC_REVERSE_SUBTRACT;
|
||||||
break;
|
break;
|
||||||
case sf::BlendMode::Min:
|
case sf::BlendMode::Equation::Min:
|
||||||
if (GLEXT_blend_minmax)
|
if (GLEXT_blend_minmax)
|
||||||
return GLEXT_GL_MIN;
|
return GLEXT_GL_MIN;
|
||||||
break;
|
break;
|
||||||
case sf::BlendMode::Max:
|
case sf::BlendMode::Equation::Max:
|
||||||
if (GLEXT_blend_minmax)
|
if (GLEXT_blend_minmax)
|
||||||
return GLEXT_GL_MAX;
|
return GLEXT_GL_MAX;
|
||||||
break;
|
break;
|
||||||
@ -139,7 +139,7 @@ std::uint32_t equationToGlConstant(sf::BlendMode::Equation blendEquation)
|
|||||||
if (!warned)
|
if (!warned)
|
||||||
{
|
{
|
||||||
sf::err() << "OpenGL extension EXT_blend_minmax or EXT_blend_subtract unavailable" << '\n'
|
sf::err() << "OpenGL extension EXT_blend_minmax or EXT_blend_subtract unavailable" << '\n'
|
||||||
<< "Some blending equations will fallback to sf::BlendMode::Add" << '\n'
|
<< "Some blending equations will fallback to sf::BlendMode::Equation::Add" << '\n'
|
||||||
<< "Ensure that hardware acceleration is enabled if available" << std::endl;
|
<< "Ensure that hardware acceleration is enabled if available" << std::endl;
|
||||||
|
|
||||||
warned = true;
|
warned = true;
|
||||||
@ -641,7 +641,7 @@ void RenderTarget::applyBlendMode(const BlendMode& mode)
|
|||||||
glCheck(GLEXT_glBlendEquation(equationToGlConstant(mode.colorEquation)));
|
glCheck(GLEXT_glBlendEquation(equationToGlConstant(mode.colorEquation)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((mode.colorEquation != BlendMode::Add) || (mode.alphaEquation != BlendMode::Add))
|
else if ((mode.colorEquation != BlendMode::Equation::Add) || (mode.alphaEquation != BlendMode::Equation::Add))
|
||||||
{
|
{
|
||||||
static bool warned = false;
|
static bool warned = false;
|
||||||
|
|
||||||
|
@ -20,50 +20,52 @@ TEST_CASE("[Graphics] sf::BlendMode")
|
|||||||
SECTION("Default constructor")
|
SECTION("Default constructor")
|
||||||
{
|
{
|
||||||
const sf::BlendMode blendMode;
|
const sf::BlendMode blendMode;
|
||||||
CHECK(blendMode.colorSrcFactor == sf::BlendMode::SrcAlpha);
|
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::SrcAlpha);
|
||||||
CHECK(blendMode.colorDstFactor == sf::BlendMode::OneMinusSrcAlpha);
|
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
|
||||||
CHECK(blendMode.colorEquation == sf::BlendMode::Add);
|
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::Add);
|
||||||
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::One);
|
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(blendMode.alphaDstFactor == sf::BlendMode::OneMinusSrcAlpha);
|
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
|
||||||
CHECK(blendMode.alphaEquation == sf::BlendMode::Add);
|
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::Add);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Combined color and alpha constructor using default parameter")
|
SECTION("Combined color and alpha constructor using default parameter")
|
||||||
{
|
{
|
||||||
const sf::BlendMode blendMode(sf::BlendMode::Zero, sf::BlendMode::SrcColor);
|
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::SrcColor);
|
||||||
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Zero);
|
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(blendMode.colorDstFactor == sf::BlendMode::SrcColor);
|
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::SrcColor);
|
||||||
CHECK(blendMode.colorEquation == sf::BlendMode::Add);
|
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::Add);
|
||||||
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Zero);
|
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(blendMode.alphaDstFactor == sf::BlendMode::SrcColor);
|
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::SrcColor);
|
||||||
CHECK(blendMode.alphaEquation == sf::BlendMode::Add);
|
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::Add);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Combined color and alpha constructor")
|
SECTION("Combined color and alpha constructor")
|
||||||
{
|
{
|
||||||
const sf::BlendMode blendMode(sf::BlendMode::Zero, sf::BlendMode::SrcColor, sf::BlendMode::ReverseSubtract);
|
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero,
|
||||||
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Zero);
|
sf::BlendMode::Factor::SrcColor,
|
||||||
CHECK(blendMode.colorDstFactor == sf::BlendMode::SrcColor);
|
sf::BlendMode::Equation::ReverseSubtract);
|
||||||
CHECK(blendMode.colorEquation == sf::BlendMode::ReverseSubtract);
|
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Zero);
|
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::SrcColor);
|
||||||
CHECK(blendMode.alphaDstFactor == sf::BlendMode::SrcColor);
|
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::ReverseSubtract);
|
||||||
CHECK(blendMode.alphaEquation == sf::BlendMode::ReverseSubtract);
|
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::Zero);
|
||||||
|
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::SrcColor);
|
||||||
|
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::ReverseSubtract);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Separate color and alpha constructor")
|
SECTION("Separate color and alpha constructor")
|
||||||
{
|
{
|
||||||
const sf::BlendMode blendMode(sf::BlendMode::Zero,
|
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max);
|
sf::BlendMode::Equation::Max);
|
||||||
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Zero);
|
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(blendMode.colorDstFactor == sf::BlendMode::SrcColor);
|
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::SrcColor);
|
||||||
CHECK(blendMode.colorEquation == sf::BlendMode::ReverseSubtract);
|
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::ReverseSubtract);
|
||||||
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::OneMinusDstAlpha);
|
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::OneMinusDstAlpha);
|
||||||
CHECK(blendMode.alphaDstFactor == sf::BlendMode::DstAlpha);
|
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::DstAlpha);
|
||||||
CHECK(blendMode.alphaEquation == sf::BlendMode::Max);
|
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::Max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,118 +74,118 @@ TEST_CASE("[Graphics] sf::BlendMode")
|
|||||||
SECTION("operator==")
|
SECTION("operator==")
|
||||||
{
|
{
|
||||||
CHECK(sf::BlendMode() == sf::BlendMode());
|
CHECK(sf::BlendMode() == sf::BlendMode());
|
||||||
CHECK(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) ==
|
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) ==
|
||||||
sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
|
sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
|
||||||
CHECK(sf::BlendMode(sf::BlendMode::Zero,
|
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max) ==
|
sf::BlendMode::Equation::Max) ==
|
||||||
sf::BlendMode(sf::BlendMode::Zero,
|
sf::BlendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max));
|
sf::BlendMode::Equation::Max));
|
||||||
|
|
||||||
CHECK_FALSE(sf::BlendMode() == sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
|
CHECK_FALSE(sf::BlendMode() == sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
|
||||||
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) ==
|
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) ==
|
||||||
sf::BlendMode(sf::BlendMode::One, sf::BlendMode::Zero));
|
sf::BlendMode(sf::BlendMode::Factor::One, sf::BlendMode::Factor::Zero));
|
||||||
CHECK_FALSE(
|
CHECK_FALSE(
|
||||||
sf::BlendMode(sf::BlendMode::Zero,
|
sf::BlendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max) ==
|
sf::BlendMode::Equation::Max) ==
|
||||||
sf::BlendMode(sf::BlendMode::One,
|
sf::BlendMode(sf::BlendMode::Factor::One,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max));
|
sf::BlendMode::Equation::Max));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("operator!=")
|
SECTION("operator!=")
|
||||||
{
|
{
|
||||||
CHECK_FALSE(sf::BlendMode() != sf::BlendMode());
|
CHECK_FALSE(sf::BlendMode() != sf::BlendMode());
|
||||||
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) !=
|
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) !=
|
||||||
sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
|
sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
|
||||||
CHECK_FALSE(
|
CHECK_FALSE(
|
||||||
sf::BlendMode(sf::BlendMode::Zero,
|
sf::BlendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max) !=
|
sf::BlendMode::Equation::Max) !=
|
||||||
sf::BlendMode(sf::BlendMode::Zero,
|
sf::BlendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max));
|
sf::BlendMode::Equation::Max));
|
||||||
|
|
||||||
CHECK(sf::BlendMode() != sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
|
CHECK(sf::BlendMode() != sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
|
||||||
CHECK(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) !=
|
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) !=
|
||||||
sf::BlendMode(sf::BlendMode::One, sf::BlendMode::Zero));
|
sf::BlendMode(sf::BlendMode::Factor::One, sf::BlendMode::Factor::Zero));
|
||||||
CHECK(sf::BlendMode(sf::BlendMode::Zero,
|
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max) !=
|
sf::BlendMode::Equation::Max) !=
|
||||||
sf::BlendMode(sf::BlendMode::One,
|
sf::BlendMode(sf::BlendMode::Factor::One,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max));
|
sf::BlendMode::Equation::Max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Static constants")
|
SECTION("Static constants")
|
||||||
{
|
{
|
||||||
CHECK(sf::BlendAlpha.colorSrcFactor == sf::BlendMode::SrcAlpha);
|
CHECK(sf::BlendAlpha.colorSrcFactor == sf::BlendMode::Factor::SrcAlpha);
|
||||||
CHECK(sf::BlendAlpha.colorDstFactor == sf::BlendMode::OneMinusSrcAlpha);
|
CHECK(sf::BlendAlpha.colorDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
|
||||||
CHECK(sf::BlendAlpha.colorEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendAlpha.colorEquation == sf::BlendMode::Equation::Add);
|
||||||
CHECK(sf::BlendAlpha.alphaSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendAlpha.alphaSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendAlpha.alphaDstFactor == sf::BlendMode::OneMinusSrcAlpha);
|
CHECK(sf::BlendAlpha.alphaDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
|
||||||
CHECK(sf::BlendAlpha.alphaEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendAlpha.alphaEquation == sf::BlendMode::Equation::Add);
|
||||||
|
|
||||||
CHECK(sf::BlendAdd.colorSrcFactor == sf::BlendMode::SrcAlpha);
|
CHECK(sf::BlendAdd.colorSrcFactor == sf::BlendMode::Factor::SrcAlpha);
|
||||||
CHECK(sf::BlendAdd.colorDstFactor == sf::BlendMode::One);
|
CHECK(sf::BlendAdd.colorDstFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendAdd.colorEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendAdd.colorEquation == sf::BlendMode::Equation::Add);
|
||||||
CHECK(sf::BlendAdd.alphaSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendAdd.alphaSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendAdd.alphaDstFactor == sf::BlendMode::One);
|
CHECK(sf::BlendAdd.alphaDstFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendAdd.alphaEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendAdd.alphaEquation == sf::BlendMode::Equation::Add);
|
||||||
|
|
||||||
CHECK(sf::BlendMultiply.colorSrcFactor == sf::BlendMode::DstColor);
|
CHECK(sf::BlendMultiply.colorSrcFactor == sf::BlendMode::Factor::DstColor);
|
||||||
CHECK(sf::BlendMultiply.colorDstFactor == sf::BlendMode::Zero);
|
CHECK(sf::BlendMultiply.colorDstFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(sf::BlendMultiply.colorEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendMultiply.colorEquation == sf::BlendMode::Equation::Add);
|
||||||
CHECK(sf::BlendMultiply.alphaSrcFactor == sf::BlendMode::DstColor);
|
CHECK(sf::BlendMultiply.alphaSrcFactor == sf::BlendMode::Factor::DstColor);
|
||||||
CHECK(sf::BlendMultiply.alphaDstFactor == sf::BlendMode::Zero);
|
CHECK(sf::BlendMultiply.alphaDstFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(sf::BlendMultiply.alphaEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendMultiply.alphaEquation == sf::BlendMode::Equation::Add);
|
||||||
|
|
||||||
CHECK(sf::BlendMin.colorSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMin.colorSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMin.colorDstFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMin.colorDstFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMin.colorEquation == sf::BlendMode::Min);
|
CHECK(sf::BlendMin.colorEquation == sf::BlendMode::Equation::Min);
|
||||||
CHECK(sf::BlendMin.alphaSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMin.alphaSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMin.alphaDstFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMin.alphaDstFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMin.alphaEquation == sf::BlendMode::Min);
|
CHECK(sf::BlendMin.alphaEquation == sf::BlendMode::Equation::Min);
|
||||||
|
|
||||||
CHECK(sf::BlendMax.colorSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMax.colorSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMax.colorDstFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMax.colorDstFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMax.colorEquation == sf::BlendMode::Max);
|
CHECK(sf::BlendMax.colorEquation == sf::BlendMode::Equation::Max);
|
||||||
CHECK(sf::BlendMax.alphaSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMax.alphaSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMax.alphaDstFactor == sf::BlendMode::One);
|
CHECK(sf::BlendMax.alphaDstFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendMax.alphaEquation == sf::BlendMode::Max);
|
CHECK(sf::BlendMax.alphaEquation == sf::BlendMode::Equation::Max);
|
||||||
|
|
||||||
CHECK(sf::BlendNone.colorSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendNone.colorSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendNone.colorDstFactor == sf::BlendMode::Zero);
|
CHECK(sf::BlendNone.colorDstFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(sf::BlendNone.colorEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendNone.colorEquation == sf::BlendMode::Equation::Add);
|
||||||
CHECK(sf::BlendNone.alphaSrcFactor == sf::BlendMode::One);
|
CHECK(sf::BlendNone.alphaSrcFactor == sf::BlendMode::Factor::One);
|
||||||
CHECK(sf::BlendNone.alphaDstFactor == sf::BlendMode::Zero);
|
CHECK(sf::BlendNone.alphaDstFactor == sf::BlendMode::Factor::Zero);
|
||||||
CHECK(sf::BlendNone.alphaEquation == sf::BlendMode::Add);
|
CHECK(sf::BlendNone.alphaEquation == sf::BlendMode::Equation::Add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ TEST_CASE("[Graphics] sf::RenderStates")
|
|||||||
|
|
||||||
SECTION("BlendMode constructor")
|
SECTION("BlendMode constructor")
|
||||||
{
|
{
|
||||||
const sf::BlendMode blendMode(sf::BlendMode::Zero,
|
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max);
|
sf::BlendMode::Equation::Max);
|
||||||
const sf::RenderStates renderStates(blendMode);
|
const sf::RenderStates renderStates(blendMode);
|
||||||
CHECK(renderStates.blendMode == blendMode);
|
CHECK(renderStates.blendMode == blendMode);
|
||||||
CHECK(renderStates.transform == sf::Transform());
|
CHECK(renderStates.transform == sf::Transform());
|
||||||
@ -78,12 +78,12 @@ TEST_CASE("[Graphics] sf::RenderStates")
|
|||||||
|
|
||||||
SECTION("Verbose constructor")
|
SECTION("Verbose constructor")
|
||||||
{
|
{
|
||||||
const sf::BlendMode blendMode(sf::BlendMode::One,
|
const sf::BlendMode blendMode(sf::BlendMode::Factor::One,
|
||||||
sf::BlendMode::SrcColor,
|
sf::BlendMode::Factor::SrcColor,
|
||||||
sf::BlendMode::ReverseSubtract,
|
sf::BlendMode::Equation::ReverseSubtract,
|
||||||
sf::BlendMode::OneMinusDstAlpha,
|
sf::BlendMode::Factor::OneMinusDstAlpha,
|
||||||
sf::BlendMode::DstAlpha,
|
sf::BlendMode::Factor::DstAlpha,
|
||||||
sf::BlendMode::Max);
|
sf::BlendMode::Equation::Max);
|
||||||
const sf::Transform transform(10, 2, 3, 4, 50, 40, 30, 20, 10);
|
const sf::Transform transform(10, 2, 3, 4, 50, 40, 30, 20, 10);
|
||||||
const sf::RenderStates renderStates(blendMode, transform, sf::CoordinateType::Normalized, nullptr, nullptr);
|
const sf::RenderStates renderStates(blendMode, transform, sf::CoordinateType::Normalized, nullptr, nullptr);
|
||||||
CHECK(renderStates.blendMode == blendMode);
|
CHECK(renderStates.blendMode == blendMode);
|
||||||
|
@ -11,9 +11,10 @@ namespace sf
|
|||||||
{
|
{
|
||||||
std::ostream& operator<<(std::ostream& os, const BlendMode& blendMode)
|
std::ostream& operator<<(std::ostream& os, const BlendMode& blendMode)
|
||||||
{
|
{
|
||||||
return os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation
|
return os << "( " << static_cast<int>(blendMode.colorSrcFactor) << ", "
|
||||||
<< ", " << blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation
|
<< static_cast<int>(blendMode.colorDstFactor) << ", " << static_cast<int>(blendMode.colorEquation) << ", "
|
||||||
<< " )";
|
<< static_cast<int>(blendMode.alphaSrcFactor) << ", " << static_cast<int>(blendMode.alphaDstFactor)
|
||||||
|
<< ", " << static_cast<int>(blendMode.alphaEquation) << " )";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const Color& color)
|
std::ostream& operator<<(std::ostream& os, const Color& color)
|
||||||
|
Loading…
Reference in New Issue
Block a user