Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML Android - RenderTexture Problem  (Read 2424 times)

0 Members and 1 Guest are viewing this topic.

madcat

  • Newbie
  • *
  • Posts: 21
  • Creator of TacWars
    • View Profile
    • TacWars
SFML Android - RenderTexture Problem
« on: September 27, 2017, 08:40:20 pm »
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
« Last Edit: October 02, 2017, 05:30:36 pm by chezlio@yahoo.com »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML Android - RenderTexture odd behaviour?!
« Reply #1 on: September 27, 2017, 08:58:58 pm »
Can you please describe what happens, what you expected and what you think is wrong? Can you also tell us if this is specific to Android (as your title implies)? And if so, what is the output on the other OS that you tested?
Laurent Gomila - SFML developer

madcat

  • Newbie
  • *
  • Posts: 21
  • Creator of TacWars
    • View Profile
    • TacWars
Re: SFML Android - RenderTexture odd behaviour?!
« Reply #2 on: September 27, 2017, 09:05:49 pm »
Ok, I expected to get the same result for drawing the Sprite set with the RenderTexture
and the Shapes directly.

It seems to be specific to Android.

I tried on OSX/IOS, no problemo, see attached pic (OSX screenshot).

btw, this is the result I expected for Android (draw(Sprite(RenderTexture)) = Draw(direct))
 :'(
« Last Edit: September 27, 2017, 10:03:53 pm by madcat »

madcat

  • Newbie
  • *
  • Posts: 21
  • Creator of TacWars
    • View Profile
    • TacWars
Re: SFML Android - RenderTexture Alpha Problem - It gets weirder.
« Reply #3 on: September 28, 2017, 03:43:08 pm »
I had a friend run the .apk on his mobile - Android 7.0 (5 février 2017)
and the result is even more dumbfounding!

the RenderTextured Sprite doesn't even appear:o
« Last Edit: September 28, 2017, 03:51:06 pm by madcat »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: SFML Android - RenderTexture Problem
« Reply #4 on: September 28, 2017, 04:06:59 pm »
What settings do you get when you call getSettings() on the window?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

madcat

  • Newbie
  • *
  • Posts: 21
  • Creator of TacWars
    • View Profile
    • TacWars
Re: SFML Android - RenderTexture Problem
« Reply #5 on: September 28, 2017, 04:25:49 pm »
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)
« Last Edit: September 28, 2017, 04:46:26 pm by madcat »

 

anything