So you're saying that if the scene graph hasn't changed since the program
started, I could just create the new surface (with SDL_SetVideoMode) and reload
the file? And if the scene graph has changed, then I would have to save the
scene graph, create the new surface and reload the file afterwards? It's messy,
but it might work.


You may not have to recall SDL_SetVideoMode. SDL might already make
sure you have a valid context if you toggle. I' don't remember that
detail.

But the big picture is that you are responsible for reloading all the
texture and displaylist data. This has less to do about your scene
graph or SDL surface as to opposed what's contained in video memory.
Regardless of whether your scene graph has changed, all the video
memory stuff is gone. But anything in regular C++ system memory still
exists. The most straight forward thing to do is unload everything (to
prevent memory leaks) and reload it. But this can be slow and painful
if you have a lot of data and a lot of application specific state that
is not easy to restore.

So there might be smarter things you can do. OSG has infrastructure to
handle multiple contexts. When you load something like a texture, OSG
has infrastructure to help load it for each context. From what I've
seen, it seems to do it on demand. So some trivial examples I've seen,
if you put two windows up (via osgProducer) and introduce text
(textures) to one window, and move it quickly to the other window, you
may see an actual hiccup and you can see that the texture was uploaded
on demand into the second window (context).

I'm thinking you might be able to hook into this infrastructure if you
treat the SDL toggle as a new separate context. Then you don't have to
reload everything and reconstruct your scene graph or anything else in
system memory. Assuming you write the correct hooks, when you start
rendering, OSG will reload all the video resources and you can
continue on your merry way. One issue might be the on-demand loading.
You might want to force OSG to load every in one shot so you don't
experience hiccups while playing. I'm not sure how easy this is to do.

But I'm talking about a lot of things I haven't actually done myself,
so take all this with a grain of salt.

-Eric
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to