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

Author Topic: Losing context when changing views  (Read 874 times)

0 Members and 1 Guest are viewing this topic.

support

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Losing context when changing views
« on: August 26, 2014, 01:16:06 pm »
Hi All,

I'm having a strange issue with SFML:

We have a C++ app which we have compiled for Android.
The app is using OpenGL for rendering.

Everything works fine, but we have had some trouble dealing with keyboard input since not all the keyboard events are mapped to sf::Keyboard values.

We then decided that we would create an activity which just takes a TextEdit and throws that up on the screen.
We then wrote some jni code which shows that activity when we need to get text input from the user.

This is where the problem starts:

Showing the activity is fine, we can switch back and forth as we wish.
However, when switching back to the Native activity for the second time (and all subsequent times) all we are getting is a white screen.

Everything else works, we can still get events and our application is still running, but the visual component (Textures) seem to be lost.

However, this only happens the second time we show that Native activity from the java code.

Is there a known workaround? This is a game and it takes quite a long time to start up, so restarting the activity from scratch is not really an option.

I was hoping there would be some way I could, from the native code, preserve the state of the OpenGL context, so that we can just attach that context to the window when it becomes visible again.

I hope this description was clear...

Thank you
Regards

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Losing context when changing views
« Reply #1 on: August 26, 2014, 06:23:50 pm »
Don't take this as gospel/truth since I'm not 100% sure. But I think you are not guaranteed that your textures are still on the GPU after a switch and thus you may have to re-load them. I guess there's a way to detect if you need to do that, but I don't know what it is (or if it even exists), but I have this memory that tells me that there's something in this area one needs to be aware of...

 

anything