Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2017-08-17 11:30:42 +02:00
commit 991bd90a40
3 changed files with 49 additions and 10 deletions

View File

@ -71,6 +71,7 @@
* Fixed renderer to work with 3.6 changes. Sadly, two color tinting does not work, as the vertex format in SFML is fixed. * Fixed renderer to work with 3.6 changes. Sadly, two color tinting does not work, as the vertex format in SFML is fixed.
* Added support for clipping. * Added support for clipping.
* Added support for vertex effects. See raptor example. * Added support for vertex effects. See raptor example.
* Added premultiplied alpha support to `SkeletonDrawable`.
### Unreal Engine 4 ### Unreal Engine 4
* Fixed renderer to work with 3.6 changes * Fixed renderer to work with 3.6 changes

View File

@ -36,6 +36,16 @@
using namespace sf; using namespace sf;
sf::BlendMode normal = sf::BlendMode(sf::BlendMode::SrcAlpha, sf::BlendMode::OneMinusSrcAlpha);
sf::BlendMode additive = sf::BlendMode(sf::BlendMode::SrcAlpha, sf::BlendMode::One);
sf::BlendMode multiply = sf::BlendMode(sf::BlendMode::DstColor, sf::BlendMode::OneMinusSrcAlpha);
sf::BlendMode screen = sf::BlendMode(sf::BlendMode::One, sf::BlendMode::OneMinusSrcColor);
sf::BlendMode normalPma = sf::BlendMode(sf::BlendMode::One, sf::BlendMode::OneMinusSrcAlpha);
sf::BlendMode additivePma = sf::BlendMode(sf::BlendMode::One, sf::BlendMode::One);
sf::BlendMode multiplyPma = sf::BlendMode(sf::BlendMode::DstColor, sf::BlendMode::OneMinusSrcAlpha);
sf::BlendMode screenPma = sf::BlendMode(sf::BlendMode::One, sf::BlendMode::OneMinusSrcColor);
_SP_ARRAY_IMPLEMENT_TYPE(spColorArray, spColor) _SP_ARRAY_IMPLEMENT_TYPE(spColorArray, spColor)
void _AtlasPage_createTexture (AtlasPage* self, const char* path){ void _AtlasPage_createTexture (AtlasPage* self, const char* path){
@ -163,16 +173,40 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
light.a = a / 255.0f; light.a = a / 255.0f;
sf::BlendMode blend; sf::BlendMode blend;
switch (slot->data->blendMode) { if (!usePremultipliedAlpha) {
case BLEND_MODE_ADDITIVE: switch (slot->data->blendMode) {
blend = BlendAdd; case BLEND_MODE_NORMAL:
break; blend = normal;
case BLEND_MODE_MULTIPLY: break;
blend = BlendMultiply; case BLEND_MODE_ADDITIVE:
break; blend = additive;
case BLEND_MODE_SCREEN: // Unsupported, fall through. break;
default: case BLEND_MODE_MULTIPLY:
blend = BlendAlpha; blend = multiply;
break;
case BLEND_MODE_SCREEN:
blend = screen;
break;
default:
blend = normal;
}
} else {
switch (slot->data->blendMode) {
case BLEND_MODE_NORMAL:
blend = normalPma;
break;
case BLEND_MODE_ADDITIVE:
blend = additivePma;
break;
case BLEND_MODE_MULTIPLY:
blend = multiplyPma;
break;
case BLEND_MODE_SCREEN:
blend = screenPma;
break;
default:
blend = normalPma;
}
} }
if (states.texture == 0) states.texture = texture; if (states.texture == 0) states.texture = texture;

View File

@ -58,12 +58,16 @@ public:
void update (float deltaTime); void update (float deltaTime);
virtual void draw (sf::RenderTarget& target, sf::RenderStates states) const; virtual void draw (sf::RenderTarget& target, sf::RenderStates states) const;
void setUsePremultipliedAlpha(bool usePMA) { usePremultipliedAlpha = usePMA; };
bool getUsePremultipliedAlpha() { return usePremultipliedAlpha; };
private: private:
bool ownsAnimationStateData; bool ownsAnimationStateData;
float* worldVertices; float* worldVertices;
spFloatArray* tempUvs; spFloatArray* tempUvs;
spColorArray* tempColors; spColorArray* tempColors;
spSkeletonClipping* clipper; spSkeletonClipping* clipper;
bool usePremultipliedAlpha;
}; };
} /* namespace spine */ } /* namespace spine */