Make BlendMode::Factor and BlendMode::Equation scoped enumerations

This commit is contained in:
kimci86 2024-01-27 15:36:29 +01:00 committed by Chris Thrasher
parent 3ca42c9a45
commit b496877c90
7 changed files with 194 additions and 186 deletions

View File

@ -45,7 +45,7 @@ struct SFML_GRAPHICS_API BlendMode
/// The factors are mapped directly to their OpenGL equivalents,
/// specified by glBlendFunc() or glBlendFuncSeparate().
////////////////////////////////////////////////////////
enum Factor
enum class Factor
{
Zero, //!< (0, 0, 0, 0)
One, //!< (1, 1, 1, 1)
@ -65,7 +65,7 @@ struct SFML_GRAPHICS_API BlendMode
/// The equations are mapped directly to their OpenGL equivalents,
/// specified by glBlendEquation() or glBlendEquationSeparate().
////////////////////////////////////////////////////////
enum Equation
enum class Equation
{
Add, //!< 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.
///
////////////////////////////////////////////////////////////
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.
@ -116,12 +116,12 @@ struct SFML_GRAPHICS_API BlendMode
////////////////////////////////////////////////////////////
// Member Data
////////////////////////////////////////////////////////////
Factor colorSrcFactor{BlendMode::SrcAlpha}; //!< Source blending factor for the color channels
Factor colorDstFactor{BlendMode::OneMinusSrcAlpha}; //!< Destination blending factor for the color channels
Equation colorEquation{BlendMode::Add}; //!< Blending equation for the color channels
Factor alphaSrcFactor{BlendMode::One}; //!< Source blending factor for the alpha channel
Factor alphaDstFactor{BlendMode::OneMinusSrcAlpha}; //!< Destination blending factor for the alpha channel
Equation alphaEquation{BlendMode::Add}; //!< Blending equation for the alpha channel
Factor colorSrcFactor{BlendMode::Factor::SrcAlpha}; //!< Source blending factor for the color channels
Factor colorDstFactor{BlendMode::Factor::OneMinusSrcAlpha}; //!< Destination blending factor for the color channels
Equation colorEquation{BlendMode::Equation::Add}; //!< Blending equation for the color channels
Factor alphaSrcFactor{BlendMode::Factor::One}; //!< Source blending factor for the alpha channel
Factor alphaDstFactor{BlendMode::Factor::OneMinusSrcAlpha}; //!< Destination blending factor for the alpha channel
Equation alphaEquation{BlendMode::Equation::Add}; //!< Blending equation for the alpha channel
};
////////////////////////////////////////////////////////////

View File

@ -33,17 +33,22 @@ namespace sf
////////////////////////////////////////////////////////////
// Commonly used blending modes
////////////////////////////////////////////////////////////
const BlendMode BlendAlpha(BlendMode::SrcAlpha,
BlendMode::OneMinusSrcAlpha,
BlendMode::Add,
BlendMode::One,
BlendMode::OneMinusSrcAlpha,
BlendMode::Add);
const BlendMode BlendAdd(BlendMode::SrcAlpha, BlendMode::One, BlendMode::Add, BlendMode::One, BlendMode::One, BlendMode::Add);
const BlendMode BlendMultiply(BlendMode::DstColor, BlendMode::Zero, BlendMode::Add);
const BlendMode BlendMin(BlendMode::One, BlendMode::One, BlendMode::Min);
const BlendMode BlendMax(BlendMode::One, BlendMode::One, BlendMode::Max);
const BlendMode BlendNone(BlendMode::One, BlendMode::Zero, BlendMode::Add);
const BlendMode BlendAlpha(BlendMode::Factor::SrcAlpha,
BlendMode::Factor::OneMinusSrcAlpha,
BlendMode::Equation::Add,
BlendMode::Factor::One,
BlendMode::Factor::OneMinusSrcAlpha,
BlendMode::Equation::Add);
const BlendMode BlendAdd(BlendMode::Factor::SrcAlpha,
BlendMode::Factor::One,
BlendMode::Equation::Add,
BlendMode::Factor::One,
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);
////////////////////////////////////////////////////////////

View File

@ -36,12 +36,12 @@ namespace sf
// 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.
const RenderStates RenderStates::Default(BlendMode(
BlendMode::SrcAlpha,
BlendMode::OneMinusSrcAlpha,
BlendMode::Add,
BlendMode::One,
BlendMode::OneMinusSrcAlpha,
BlendMode::Add));
BlendMode::Factor::SrcAlpha,
BlendMode::Factor::OneMinusSrcAlpha,
BlendMode::Equation::Add,
BlendMode::Factor::One,
BlendMode::Factor::OneMinusSrcAlpha,
BlendMode::Equation::Add));
////////////////////////////////////////////////////////////

View File

@ -91,45 +91,45 @@ std::uint32_t factorToGlConstant(sf::BlendMode::Factor blendFactor)
// clang-format off
switch (blendFactor)
{
case sf::BlendMode::Zero: return GL_ZERO;
case sf::BlendMode::One: return GL_ONE;
case sf::BlendMode::SrcColor: return GL_SRC_COLOR;
case sf::BlendMode::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
case sf::BlendMode::DstColor: return GL_DST_COLOR;
case sf::BlendMode::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
case sf::BlendMode::SrcAlpha: return GL_SRC_ALPHA;
case sf::BlendMode::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
case sf::BlendMode::DstAlpha: return GL_DST_ALPHA;
case sf::BlendMode::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
case sf::BlendMode::Factor::Zero: return GL_ZERO;
case sf::BlendMode::Factor::One: return GL_ONE;
case sf::BlendMode::Factor::SrcColor: return GL_SRC_COLOR;
case sf::BlendMode::Factor::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
case sf::BlendMode::Factor::DstColor: return GL_DST_COLOR;
case sf::BlendMode::Factor::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
case sf::BlendMode::Factor::SrcAlpha: return GL_SRC_ALPHA;
case sf::BlendMode::Factor::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
case sf::BlendMode::Factor::DstAlpha: return GL_DST_ALPHA;
case sf::BlendMode::Factor::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
}
// 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);
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)
{
switch (blendEquation)
{
case sf::BlendMode::Add:
case sf::BlendMode::Equation::Add:
return GLEXT_GL_FUNC_ADD;
case sf::BlendMode::Subtract:
case sf::BlendMode::Equation::Subtract:
if (GLEXT_blend_subtract)
return GLEXT_GL_FUNC_SUBTRACT;
break;
case sf::BlendMode::ReverseSubtract:
case sf::BlendMode::Equation::ReverseSubtract:
if (GLEXT_blend_subtract)
return GLEXT_GL_FUNC_REVERSE_SUBTRACT;
break;
case sf::BlendMode::Min:
case sf::BlendMode::Equation::Min:
if (GLEXT_blend_minmax)
return GLEXT_GL_MIN;
break;
case sf::BlendMode::Max:
case sf::BlendMode::Equation::Max:
if (GLEXT_blend_minmax)
return GLEXT_GL_MAX;
break;
@ -139,7 +139,7 @@ std::uint32_t equationToGlConstant(sf::BlendMode::Equation blendEquation)
if (!warned)
{
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;
warned = true;
@ -641,7 +641,7 @@ void RenderTarget::applyBlendMode(const BlendMode& mode)
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;

View File

@ -20,50 +20,52 @@ TEST_CASE("[Graphics] sf::BlendMode")
SECTION("Default constructor")
{
const sf::BlendMode blendMode;
CHECK(blendMode.colorSrcFactor == sf::BlendMode::SrcAlpha);
CHECK(blendMode.colorDstFactor == sf::BlendMode::OneMinusSrcAlpha);
CHECK(blendMode.colorEquation == sf::BlendMode::Add);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::One);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::OneMinusSrcAlpha);
CHECK(blendMode.alphaEquation == sf::BlendMode::Add);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::SrcAlpha);
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::Add);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::One);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::Add);
}
SECTION("Combined color and alpha constructor using default parameter")
{
const sf::BlendMode blendMode(sf::BlendMode::Zero, sf::BlendMode::SrcColor);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Zero);
CHECK(blendMode.colorDstFactor == sf::BlendMode::SrcColor);
CHECK(blendMode.colorEquation == sf::BlendMode::Add);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Zero);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::SrcColor);
CHECK(blendMode.alphaEquation == sf::BlendMode::Add);
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::SrcColor);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::Zero);
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::SrcColor);
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::Add);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::Zero);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::SrcColor);
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::Add);
}
SECTION("Combined color and alpha constructor")
{
const sf::BlendMode blendMode(sf::BlendMode::Zero, sf::BlendMode::SrcColor, sf::BlendMode::ReverseSubtract);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Zero);
CHECK(blendMode.colorDstFactor == sf::BlendMode::SrcColor);
CHECK(blendMode.colorEquation == sf::BlendMode::ReverseSubtract);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Zero);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::SrcColor);
CHECK(blendMode.alphaEquation == sf::BlendMode::ReverseSubtract);
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::Zero);
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::SrcColor);
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::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")
{
const sf::BlendMode blendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Zero);
CHECK(blendMode.colorDstFactor == sf::BlendMode::SrcColor);
CHECK(blendMode.colorEquation == sf::BlendMode::ReverseSubtract);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::OneMinusDstAlpha);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::DstAlpha);
CHECK(blendMode.alphaEquation == sf::BlendMode::Max);
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max);
CHECK(blendMode.colorSrcFactor == sf::BlendMode::Factor::Zero);
CHECK(blendMode.colorDstFactor == sf::BlendMode::Factor::SrcColor);
CHECK(blendMode.colorEquation == sf::BlendMode::Equation::ReverseSubtract);
CHECK(blendMode.alphaSrcFactor == sf::BlendMode::Factor::OneMinusDstAlpha);
CHECK(blendMode.alphaDstFactor == sf::BlendMode::Factor::DstAlpha);
CHECK(blendMode.alphaEquation == sf::BlendMode::Equation::Max);
}
}
@ -72,118 +74,118 @@ TEST_CASE("[Graphics] sf::BlendMode")
SECTION("operator==")
{
CHECK(sf::BlendMode() == sf::BlendMode());
CHECK(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) ==
sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
CHECK(sf::BlendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max) ==
sf::BlendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max));
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) ==
sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max) ==
sf::BlendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max));
CHECK_FALSE(sf::BlendMode() == sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) ==
sf::BlendMode(sf::BlendMode::One, sf::BlendMode::Zero));
CHECK_FALSE(sf::BlendMode() == sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) ==
sf::BlendMode(sf::BlendMode::Factor::One, sf::BlendMode::Factor::Zero));
CHECK_FALSE(
sf::BlendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max) ==
sf::BlendMode(sf::BlendMode::One,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max));
sf::BlendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max) ==
sf::BlendMode(sf::BlendMode::Factor::One,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max));
}
SECTION("operator!=")
{
CHECK_FALSE(sf::BlendMode() != sf::BlendMode());
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) !=
sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
CHECK_FALSE(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) !=
sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
CHECK_FALSE(
sf::BlendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max) !=
sf::BlendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max));
sf::BlendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max) !=
sf::BlendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max));
CHECK(sf::BlendMode() != sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One));
CHECK(sf::BlendMode(sf::BlendMode::Zero, sf::BlendMode::One) !=
sf::BlendMode(sf::BlendMode::One, sf::BlendMode::Zero));
CHECK(sf::BlendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max) !=
sf::BlendMode(sf::BlendMode::One,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max));
CHECK(sf::BlendMode() != sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One));
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero, sf::BlendMode::Factor::One) !=
sf::BlendMode(sf::BlendMode::Factor::One, sf::BlendMode::Factor::Zero));
CHECK(sf::BlendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max) !=
sf::BlendMode(sf::BlendMode::Factor::One,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max));
}
}
SECTION("Static constants")
{
CHECK(sf::BlendAlpha.colorSrcFactor == sf::BlendMode::SrcAlpha);
CHECK(sf::BlendAlpha.colorDstFactor == sf::BlendMode::OneMinusSrcAlpha);
CHECK(sf::BlendAlpha.colorEquation == sf::BlendMode::Add);
CHECK(sf::BlendAlpha.alphaSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendAlpha.alphaDstFactor == sf::BlendMode::OneMinusSrcAlpha);
CHECK(sf::BlendAlpha.alphaEquation == sf::BlendMode::Add);
CHECK(sf::BlendAlpha.colorSrcFactor == sf::BlendMode::Factor::SrcAlpha);
CHECK(sf::BlendAlpha.colorDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
CHECK(sf::BlendAlpha.colorEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendAlpha.alphaSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendAlpha.alphaDstFactor == sf::BlendMode::Factor::OneMinusSrcAlpha);
CHECK(sf::BlendAlpha.alphaEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendAdd.colorSrcFactor == sf::BlendMode::SrcAlpha);
CHECK(sf::BlendAdd.colorDstFactor == sf::BlendMode::One);
CHECK(sf::BlendAdd.colorEquation == sf::BlendMode::Add);
CHECK(sf::BlendAdd.alphaSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendAdd.alphaDstFactor == sf::BlendMode::One);
CHECK(sf::BlendAdd.alphaEquation == sf::BlendMode::Add);
CHECK(sf::BlendAdd.colorSrcFactor == sf::BlendMode::Factor::SrcAlpha);
CHECK(sf::BlendAdd.colorDstFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendAdd.colorEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendAdd.alphaSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendAdd.alphaDstFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendAdd.alphaEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendMultiply.colorSrcFactor == sf::BlendMode::DstColor);
CHECK(sf::BlendMultiply.colorDstFactor == sf::BlendMode::Zero);
CHECK(sf::BlendMultiply.colorEquation == sf::BlendMode::Add);
CHECK(sf::BlendMultiply.alphaSrcFactor == sf::BlendMode::DstColor);
CHECK(sf::BlendMultiply.alphaDstFactor == sf::BlendMode::Zero);
CHECK(sf::BlendMultiply.alphaEquation == sf::BlendMode::Add);
CHECK(sf::BlendMultiply.colorSrcFactor == sf::BlendMode::Factor::DstColor);
CHECK(sf::BlendMultiply.colorDstFactor == sf::BlendMode::Factor::Zero);
CHECK(sf::BlendMultiply.colorEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendMultiply.alphaSrcFactor == sf::BlendMode::Factor::DstColor);
CHECK(sf::BlendMultiply.alphaDstFactor == sf::BlendMode::Factor::Zero);
CHECK(sf::BlendMultiply.alphaEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendMin.colorSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendMin.colorDstFactor == sf::BlendMode::One);
CHECK(sf::BlendMin.colorEquation == sf::BlendMode::Min);
CHECK(sf::BlendMin.alphaSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendMin.alphaDstFactor == sf::BlendMode::One);
CHECK(sf::BlendMin.alphaEquation == sf::BlendMode::Min);
CHECK(sf::BlendMin.colorSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMin.colorDstFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMin.colorEquation == sf::BlendMode::Equation::Min);
CHECK(sf::BlendMin.alphaSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMin.alphaDstFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMin.alphaEquation == sf::BlendMode::Equation::Min);
CHECK(sf::BlendMax.colorSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendMax.colorDstFactor == sf::BlendMode::One);
CHECK(sf::BlendMax.colorEquation == sf::BlendMode::Max);
CHECK(sf::BlendMax.alphaSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendMax.alphaDstFactor == sf::BlendMode::One);
CHECK(sf::BlendMax.alphaEquation == sf::BlendMode::Max);
CHECK(sf::BlendMax.colorSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMax.colorDstFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMax.colorEquation == sf::BlendMode::Equation::Max);
CHECK(sf::BlendMax.alphaSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMax.alphaDstFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendMax.alphaEquation == sf::BlendMode::Equation::Max);
CHECK(sf::BlendNone.colorSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendNone.colorDstFactor == sf::BlendMode::Zero);
CHECK(sf::BlendNone.colorEquation == sf::BlendMode::Add);
CHECK(sf::BlendNone.alphaSrcFactor == sf::BlendMode::One);
CHECK(sf::BlendNone.alphaDstFactor == sf::BlendMode::Zero);
CHECK(sf::BlendNone.alphaEquation == sf::BlendMode::Add);
CHECK(sf::BlendNone.colorSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendNone.colorDstFactor == sf::BlendMode::Factor::Zero);
CHECK(sf::BlendNone.colorEquation == sf::BlendMode::Equation::Add);
CHECK(sf::BlendNone.alphaSrcFactor == sf::BlendMode::Factor::One);
CHECK(sf::BlendNone.alphaDstFactor == sf::BlendMode::Factor::Zero);
CHECK(sf::BlendNone.alphaEquation == sf::BlendMode::Equation::Add);
}
}

View File

@ -29,12 +29,12 @@ TEST_CASE("[Graphics] sf::RenderStates")
SECTION("BlendMode constructor")
{
const sf::BlendMode blendMode(sf::BlendMode::Zero,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max);
const sf::BlendMode blendMode(sf::BlendMode::Factor::Zero,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max);
const sf::RenderStates renderStates(blendMode);
CHECK(renderStates.blendMode == blendMode);
CHECK(renderStates.transform == sf::Transform());
@ -78,12 +78,12 @@ TEST_CASE("[Graphics] sf::RenderStates")
SECTION("Verbose constructor")
{
const sf::BlendMode blendMode(sf::BlendMode::One,
sf::BlendMode::SrcColor,
sf::BlendMode::ReverseSubtract,
sf::BlendMode::OneMinusDstAlpha,
sf::BlendMode::DstAlpha,
sf::BlendMode::Max);
const sf::BlendMode blendMode(sf::BlendMode::Factor::One,
sf::BlendMode::Factor::SrcColor,
sf::BlendMode::Equation::ReverseSubtract,
sf::BlendMode::Factor::OneMinusDstAlpha,
sf::BlendMode::Factor::DstAlpha,
sf::BlendMode::Equation::Max);
const sf::Transform transform(10, 2, 3, 4, 50, 40, 30, 20, 10);
const sf::RenderStates renderStates(blendMode, transform, sf::CoordinateType::Normalized, nullptr, nullptr);
CHECK(renderStates.blendMode == blendMode);

View File

@ -11,9 +11,10 @@ namespace sf
{
std::ostream& operator<<(std::ostream& os, const BlendMode& blendMode)
{
return os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation
<< ", " << blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation
<< " )";
return os << "( " << static_cast<int>(blendMode.colorSrcFactor) << ", "
<< 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)