Why do I have two different visual results for
- the Shapes
- the RenderTexture dump with a Sprite
the screenshot is taken from the Android Emulator (API 26), app launched through Android Studio
using SFML 2.4.2
not the difference of blending of the top (white, alpha = 50%) square on the grey square (grey 50% alpha=100%)
- the left group is drawn using a RenderTexture applied to a Sprite
- the right group is drawn directly
min code
void App::loop()
{
// FULLSCREEN mode + autoRotate ON
sf::RenderWindow window(sf::VideoMode::getFullscreenModes().front(), "Alpha-WeirdAlpha", sf::Style::Fullscreen | sf::Style::Resize);
// simple
sf::RectangleShape rbg(sf::Vector2f(400.f, 400.f));
rbg.setFillColor(sf::Color(0x808080FF));
rbg.setPosition(50.f, 50.f);
sf::RectangleShape rfg(sf::Vector2f(200.f, 200.f));
rfg.setFillColor(sf::Color(0xFFFFFF80));
rfg.setPosition(25.f, 25.f);
// create render texture
sf::RenderTexture rt;
rt.create(500, 500);
rt.clear(sf::Color(0x00000000));
rt.setSmooth(true);
rt.draw(rbg);
rt.draw(rfg);
rt.display();
sf::Sprite sprRT(rt.getTexture());
rbg.move(500.f,0.f);
rfg.move(500.f,0.f);
sf::View view = window.getDefaultView();
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::Resized: {
view.setSize(event.size.width, event.size.height);
view.setCenter(event.size.width / 2, event.size.height / 2);
window.setView(view);
} break;
default: break;
}
}
window.clear(sf::Color(0x80a0f0ff));
window.draw(rbg);
window.draw(rfg);
window.draw(sprRT);
window.display();
}
}
source code here
http://github.com/MoVoDesign/SFML_Android_RenderTexture.git