Fullscreen/resolution switch causes texture loss

I have found several references to this type of problem but can't quite get my head around the solution, so please go right back to basics in your explanations.

I'm using SDL to set up my OpenGL context, then I load some textures from disk with

Code:

glGenTextures()
glTexImage2D()

and all is working fine.

When I do a resolution switch, i.e. calling

Code:

SDL_SetVideoMode(width, height, 32, SDL_OPENGL | fs

then none of my textures draw any more, but all non-textured geometry is OK. My understandng of this is that some data (including textures) is bound to a particular OpenGL context, and SDL is destroying the context when I switch resolution. Also, if I switch back to a previous setting (e.g. toggle fullscreen and back again), then the texture data is gone completely.

So I guess I have several questions:

1) What is context-stored data i.e. what do I have to recreate when I switch contexts?
2) I have heard a bit about context sharing - is this possible with SDL and if so how would this work?

Since SDL destroys the context when changing video mode, you need to start completely from scratch each time.

OpenGL contexts can share objects if set up correctly, but not state, so if you can set up sharing between your windowed and full screen contexts your textures will be preserved, but you'll still need to carefully manage your enables and the like.

If you search these boards you can probably turn up a patch to SDL (by fcovett if memory serves?) that allows full-screen toggling without context destruction. I don't remember how it works, whether it's by sharing or by using the same context for both full-screen and windowed modes. If the latter, both objects and state will be preserved.