I have a question regarding the spine-sfml runtime.
First, consider the following code starting from line 165 in spine-sfml.cpp (version 3.6):
sf::BlendMode blend;
switch (slot->data->blendMode) {
case BLEND_MODE_ADDITIVE:
blend = BlendAdd;
break;
case BLEND_MODE_MULTIPLY:
blend = BlendMultiply;
break;
case BLEND_MODE_SCREEN: // Unsupported, fall through.
default:
blend = BlendAlpha;
}
if (states.texture == 0) states.texture = texture;
if (states.blendMode != blend || states.texture != texture) {
target.draw(*vertexArray, states);
vertexArray->clear();
states.blendMode = blend;
states.texture = texture;
}
I was trying to change the blend mode in SFML (to enable support for premultiplied alpha atlases) and it took me a while to figure out that spine-sfml was overriding the BlendMode object I had supplied in the RenderStates object. Why is this?
To get it to work, I had to change the runtime (which I really hate to do, since I do not want to maintain the Spine runtimes in addition to my own projects) changed the default case to the following:
default:
blend = states.blendMode;
If states.blendMode is not explicitly set, then it defaults to BlendAlpha, and otherwise I can use whatever BlendMode I want. In my case, I use:
sf::BlendMode blendMode = sf::BlendMode(
sf::BlendMode::Factor::One,
sf::BlendMode::Factor::OneMinusSrcAlpha
);
Was this a design error? Or did I overlook something? I would prefer not to change the spine-sfml runtime at all, but without this my animations look awful.
Thanks for your time.