Add support for blend color by Arc8ne · Pull Request #3646 · SFML/SFML · GitHub
Skip to content

Add support for blend color#3646

Draft
Arc8ne wants to merge 2 commits intoSFML:masterfrom
Arc8ne:issue-1503
Draft

Add support for blend color#3646
Arc8ne wants to merge 2 commits intoSFML:masterfrom
Arc8ne:issue-1503

Conversation

@Arc8ne
Copy link
Copy Markdown

@Arc8ne Arc8ne commented Jan 22, 2026

Description

This PR adds support for constant color blending modes so as to resolve issue #1503.

Link to the relevant forum post: https://en.sfml-dev.org/forums/index.php?topic=24653.0

Tasks

  • Tested on Linux
  • Tested on Windows
  • Tested on macOS
  • Tested on iOS
  • Tested on Android

How to test this PR?

Arc8ne and others added 2 commits January 22, 2026 10:26
…ant color used in blending.

Add 4 new values to the `sf::BlendMode::Factor` enum to allow the constant color to be used in the blending equation.
Update the application of `sf::BlendMode` in `sf::RenderTarget` to allow the constant color to be used in the blending equation.
Comment on lines +718 to +735
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something along the lines of:

const auto isBlendColorFactor = [](sf::BlendMode::Factor factor)
{
    return factor == BlendMode::Factor::ConstColor ||
           factor == BlendMode::Factor::OneMinusConstColor ||
           factor == BlendMode::Factor::ConstAlpha ||
           factor == BlendMode::Factor::OneMinusConstAlpha;
};

if (isBlendColorFactor(mode.colorSrcFactor) ||
    isBlendColorFactor(mode.colorDstFactor) ||
    isBlendColorFactor(mode.alphaSrcFactor) ||
    isBlendColorFactor(mode.alphaDstFactor))
{
   glCheck(glBlendColor(mode.constColor.r, mode.constColor.g, mode.constColor.b, mode.constColor.a));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants