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
and all is working fine.
When I do a resolution switch, i.e. calling
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?
Cheers
- Iain
I'm using SDL to set up my OpenGL context, then I load some textures from disk with
Code:
glGenTextures()
glTexImage2D()When I do a resolution switch, i.e. calling
Code:
SDL_SetVideoMode(width, height, 32, SDL_OPENGL | fsthen 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?
Cheers
- Iain
*everything* in OpenGL belongs to a context. All your objects (textures, VBOs, display lists, framebuffers, etc) and all your state (bound textures, enables, etc).
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.
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.
The version I have found here (ages ago) uses sharing. There may be other versions around somewhere.
So I think I'll just go with reloading all my textures and resetting state when the context is destroyed and recreated...
If I have objects (textures, VBOs) etc. am I still responsible for releasing these resources e.g.
or does destroying the context clear it all up for me, and I just need to recreate them all again?
Cheers
- Iain
If I have objects (textures, VBOs) etc. am I still responsible for releasing these resources e.g.
Code:
glDeleteTextures()or does destroying the context clear it all up for me, and I just need to recreate them all again?
Cheers
- Iain
Destroying the context clears it all up.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| DPI and Resolution for Graphics | mickyg | 9 | 6,622 |
Apr 27, 2012 03:02 PM Last Post: Andres Calil |
|
| fullscreen-window mode switch | NYGhost | 10 | 4,768 |
Feb 10, 2005 09:52 AM Last Post: NYGhost |
|
| changing resolution in fullscreen | ghettotek | 22 | 7,587 |
Jan 18, 2005 09:39 PM Last Post: arekkusu |
|
| Switch Between Fullscreen and Windowed Modes - Again... | thaeez | 2 | 2,679 |
Jul 9, 2004 02:49 AM Last Post: thaeez |
|
| OpenGL CGL Switch Between Fullscreen and Windowed Mode | thaeez | 1 | 3,002 |
Jun 30, 2004 04:29 AM Last Post: OneSadCookie |
|

