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

Author Topic: Window not redrawing after onResume on Android  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

FraKtus

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Window not redrawing after onResume on Android
« on: May 14, 2017, 08:20:45 am »

I have an application running 4 OS with SFML and Nuklear, congrats for the amazing API!

There is one issue where the Android app does not redraw after onResume on Android, when I switch the app it does not redraw anymore.

I see that sometimes several main are running, it's like ANativeActivity_onCreate is called again and the main is recreated and of course it's a problem...

That may be in the Nuklear code https://github.com/vurtun/nuklear/blob/master/demo/sfml_opengl2/nuklear_sfml_gl2.h
There is a static that I did remove for testing but it did not solve the issue...

I receive the events sf::Event::MouseEntered and sf::Event::MouseLeft correctly...

Should I recreate the window when I receive sf::Event::MouseEntered ?

FraKtus

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Window not redrawing after onResume on Android
« Reply #1 on: May 18, 2017, 09:44:43 am »
After using logcat I see this OpenGL error after a resume:

sfml-error: An internal EGL call failed in EglContext.cpp (189) : EGL_BAD_SURFACE, an EGLSurface argument does not name a valid surface (window, pbuffer, or pixmap) configured for rendering

This is how I create the window:
sf::ContextSettings settings;
sf::VideoMode mode = sf::VideoMode::getDesktopMode();
sf::Window win(mode, "SFAppDelegate", sf::Style::Fullscreen, settings);

Does that seems correct ?

FraKtus

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Window not redrawing after onResume on Android
« Reply #2 on: May 18, 2017, 10:19:42 pm »
So I fixed the issue after adding messages to logcat.. I saw that the OpenGL context was not correctly selected after resuming.

In the end it's really important to do win.setActive(false) when receiving sf::Event::LostFocus... and making win.setActive(true) on sf::Event::GainedFocus...

Now the 4 platforms are working fine :-)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Window not redrawing after onResume on Android
« Reply #3 on: May 19, 2017, 05:41:03 pm »
Good to hear that you figured it out! :)

Did you change anything in the SFML source code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/