pelya wrote:shishanjiu wrote:Do we need SDL_Flip(SDL_GetVideoSurface()) in a while (1) loop like ballfield.cpp?
slvn also said to call SDL_Flip in 1Hz.
Doies this is actully need to solve the pause/resume issue after press home button? I feel it so wild.
Yes, SDL destroys and re-creates video surfaces inside SDL_Flip() call, so you need to call it from time to time (once per 5 seconds at least).
It also sends SDL_ACTIVEEVENT and SDL_VIDEORESIZE events from inside SDL_Flip(), however I did a quick fix, now it will send a SDL_ACTIVEEVENT asynchronously, when the app is put to background.
Please update your SDL repo, and replace all long wait functions in your app with SDL_WaitEvent() (or SDL_PollEvent() with a short sleep in a loop). I think you already did that, because your app should wait for user input.
Whenever you receive a SDL_ACTIVEEVENT - you should call one extra SDL_Flip(), that should fix the bug. SDL_Flip() will block, and will return only when user brings app to foreground.
pelya wrote:Okay, the only thing that lets your application know it was in background are two SDL events, SDL_ACTIVEEVENT and SDL_VIDEORESIZE. Maybe your app does something when it receives those events? Could you please try to comment out that part of code?
pelya wrote:When you receive SDL_ACTIVEEVENT you have to call SDL_Flip() one time - it will sleep until user brings app to foreground. The destroying/creating of OpenGL context is done inside that SDL_Flip(), you don't need to do any other modifications to your code. Please reply if it works for you as I've described.
Users browsing this forum: No registered users and 8 guests