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 (http://github.com/MoVoDesign/SFML_Android_RenderTexture.git)
What settings do you get when you call getSettings() on the window?
result when run in Android Studio emu.
depthBits=0x18
stencilBits=0x8
antialiasingLevel=0
majorVersion=0
minorVersion=0
attributeFlags=0x0
sRgbCapable=0
bonus dump from Android emu Monitor
[ 09-28 16:42:41.889 11728:11768 W/ ]
Unrecognized GLES max version string in extensions: ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1
09-28 16:42:41.891 11728-11768/sfml.example.app D/EGL_emulation: eglCreateContext: 0xaa032b80: maj 1 min 0 rcv 1
09-28 16:42:41.891 11728-11768/sfml.example.app D/EGL_emulation: eglMakeCurrent: 0xaa032b80: ver 1 0 (tinfo 0xaa00b3e0)
09-28 16:42:41.892 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821b
09-28 16:42:41.892 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821c
09-28 16:42:41.893 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821e
09-28 16:42:41.893 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x00009126
09-28 16:42:41.893 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821b
09-28 16:42:41.899 11728-11768/sfml.example.app D/EGL_emulation: eglMakeCurrent: 0xaa032b80: ver 1 0 (tinfo 0xaa00b3e0)
09-28 16:42:41.902 11728-11768/sfml.example.app D/EGL_emulation: eglCreateContext: 0xaa032be0: maj 1 min 0 rcv 1
09-28 16:42:41.902 11728-11768/sfml.example.app E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
09-28 16:42:41.902 11728-11768/sfml.example.app I/sfml-error: Warning: The created OpenGL context does not fully meet the settings that were requested
09-28 16:42:41.902 11728-11768/sfml.example.app I/sfml-error: Requested: version = 1.1 ; depth bits = 0 ; stencil bits = 0 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
09-28 16:42:41.902 11728-11768/sfml.example.app I/sfml-error: Created: version = 0.0 ; depth bits = 24 ; stencil bits = 8 ; AA level = 0 ; core = false ; debug = false ; sRGB = false
09-28 16:42:41.902 11728-11768/sfml.example.app I/sfml-error: Failed to activate the window's context
09-28 16:42:41.902 11728-11768/sfml.example.app I/sfml-error: Failed to activate the window's context
09-28 16:42:41.902 11728-11768/sfml.example.app I/native-activity: depthBits=0x18, stencilBits=0x8, antialiasingLevel=0, majorVersion=0, minorVersion=0, attributeFlags=0x0, sRgbCapable=0
09-28 16:42:41.904 11728-11768/sfml.example.app D/EGL_emulation: eglMakeCurrent: 0xaa032b80: ver 1 0 (tinfo 0xaa00b3e0)
09-28 16:42:41.924 11728-11768/sfml.example.app I/chatty: uid=10085(u0_a85) sfml.example.app identical 4 lines
09-28 16:42:41.924 11728-11768/sfml.example.app D/EGL_emulation: eglMakeCurrent: 0xaa032b80: ver 1 0 (tinfo 0xaa00b3e0)
09-28 16:42:41.930 11728-11768/sfml.example.app D/EGL_emulation: eglCreateContext: 0xaa032ca0: maj 1 min 0 rcv 1
09-28 16:42:41.932 11728-11768/sfml.example.app D/EGL_emulation: eglMakeCurrent: 0xaa032ca0: ver 1 0 (tinfo 0xaa00b3e0)
09-28 16:42:41.932 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821b
09-28 16:42:41.939 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821c
09-28 16:42:41.941 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x0000821e
09-28 16:42:41.941 11728-11768/sfml.example.app E/eglCodecCommon: glUtilsParamSize: unknow param 0x00009126
09-28 16:42:42.000 11728-11768/sfml.example.app D/EGL_emulation: eglMakeCurrent: 0xaa032be0: ver 1 0 (tinfo 0xaa00b3e0)