The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Context switching / Texture reloading
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
Hi everyone,

I've been thinking about how to best handle the issue of texture
reloading across platforms, when/if the graphic context changes. My
interest is motivated by the fact that I've seen this happen in
Android after leaving the app and coming back to it, and I've done
some research to see if this can happen in other platforms as well...

It looks like in desktop system this is not a problem... in Direct3D
9, textures are automatically managed:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172341(v=vs.85).aspx
Desktop OpenGL does the same (at least from what I've read online), it
keeps copies of the textures in system memory.

The problem then can arise in GL ES platforms. I'm not sure if iOS
devices have this issue and if it's been handled somehow already, can
anyone let me know how/if it's handled?

So, going back to Android, I'd like to know if this is something SDL
should be concerned with...alternatives to the problem seem to be (in
order of preference):

* Changing SDLActivity.java to use GLSurfaceView instead of
SurfaceView (according to this thread
http://groups.google.com/group/android-ndk/browse_thread/thread/7e73c0d2ba7f52f5
it provides context preservation on hardware that supports it, the
issue would remain in hardware that doesn't! and potentially in other
platforms that suffer from the same ES context switching)
* Sending a message when the context changes (which is kinda what we
are doing now, as the activity sends SDL_WINDOWEVENT_MINIMIZED and
SDL_WINDOWEVENT_RESTORED when pause/restore happens)
* Adding a SDL_CheckTexture function that would return true in every
backend except GL ES, and in GL ES would check the texture's renderer
context vs the current context, or something along those lines...
* A combination of the above or something else entirely

I think the solution will depend on what the iOS backend does or can
potentially do. Ideally if we can wrap this issues inside the
SDLActivity, and only fire a SDL_CONTEXT_CHANGED sort of event when
the hardware can't handle context switching, that would be best IMO.

Thanks for any feedback!

--
Gabriel.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
Hi myself, replying to my own message... It appears that out of all the supported platforms this is only an issue for Android, so I'll look into a solution for this platform only!