Thanks for taking the time to look at it.
1. It does break API compatibility since sf::BlendMode is now a structure and no longer an enum. In "regular" use cases it won't make any difference, but we could imagine scenarios like serialization (direct cast to int) that would no longer work with the new implementation. Is this acceptable though?
Yes, also the mentioned
switch statement is such a case. My thought was that the user would mostly not dispatch on different blend modes himself, but rather pass them to SFML and store them in variables.
If you deem it crucial to allow switch or serialization for backwards compatibility, it would be possible to introduce implicit conversions to
int and explicit ones from
int for the existing blend modes. But I don't like to introduce such a hack unless absolutely necessary.
2. We must have a fallback for systems without glBlendFuncSeparate.
Would it suffice if it were supported for the existing blend modes? Then we could adapt the SFML rendering such that if the GLEW extension is not supported, it will recognize those cases and use the old
glBlendFunc().
But in general, it's not possible to map the new API with 6 parameters to the simplified one.
On a more personal note, I think that this new API brings complexity. Instead of 4 simple blend modes, we now have factors and equations, with a lot more possibilities. Sure for those who are used to the current API, things can remain as simple as before. But for newcomers, that will have a look at the documentation, won't they be lost with all these parameters?
It does indeed add complexity, but if you want to make blending more flexible, there's hardly a way around it. Going only half-way (support
glBlendFunc() but not
glBlendFuncSeparate() and
glBlendEquation()) is a bad idea, because it still doesn't satisfy a lot of use cases. If we only provided predefined blend modes, there would have to be a lot to cover many cases, and then users would again be lost because they don't know which of them are the most common ones.
One thing we should certainly do is emphasize in the tutorials and documentation that the predefined blend mode constants will be enough for most cases, and the rest only exists for customization.
The alternative would be a separate API (conceptually similar to the separation of high-level and low-level rendering API in SFML), but I think it would add even more complexity.
By the way, are all the new constants really necessary? I didn't look deeply at them, so make sure they are all really relevant, and not just added "because now we can".
I'll investigate that. The question is whether you only want to provide the minimum number of enumerators that is necessary to implement the current blend modes, or at least a few more common ones? Where should we draw the border? It will be more or less arbitrary...