Losing Texture/VBO/etc when changing resolution in fullscreen

Started by
3 comments, last by Phantom5800 12 years, 4 months ago
So, I "think" I know exactly what is happening. When you change resolution in fullscreen, or go from windowed to fullscreen (or vice-versa), SDL recreates it's OpenGL context, which means all textures, vbos, etc, need to be reloaded into graphics memory (please correct me if this is not entirely true).

What I am attempting to do in order to handle this case:


// WindowSystem_SDL::RefreshWindow
// ...

// unload any resources that depend on opengl context
g_resources->LostDevice();

ConfigureSDLFlags(); // sets flags for opengl context + fullscreen/not-fullscreen
SetAttributes(); // double buffering, hardware accelerated context, etc

// re-create the window
m_screen = SDL_SetVideoMode(m_width, m_height, 32, m_windowFlags);

// reloads all graphics resources
g_resources->FoundDevice();

// ...


Is there any flaw to what I am doing? Something obvious I am missing? Any help would be appreciated.
Advertisement
Do a search on these forums. I distinctly remember this very issue being brought up in the past. If I remember correctly, it is a very well known bug in SDL. I don't think there is a solution or work around. You have to reload everything on each resolution change.
I've tried searching previous posts and haven't been able to find anything (at least not that I don't already know). I am destroying everything and recreating it after changing the resolution as you can see from my code snippet, I just don't understand what I'm doing wrong so that nothing draws after toggling fullscreen or changing resolution while in fullscreen (I can change the window size in windowed mode just fine). I can post any of my code, I'm just not sure what exactly would be relevant to anyone that might know how to fix this.

When I recreate everything, I just do the exact same process of creating all my resources as I did when originally loading them.
http://www.gamedev.net/topic/605122-sdl-sdl-setvideomode-with-opengl-and-fullscreen/page__p__4831410__hl__sdl+fullscreen__fromsearch__1#entry4831410
http://www.gamedev.net/topic/551489-opengl--sdl_setvideomode-fullscreen-problem/page__p__551489__hl__sdl+fullscreen__fromsearch__1#entry551489
http://www.gamedev.net/topic/535529-sdl-resizing-fullscreen-and-lost-rendering-contexts/page__p__4462299__hl__sdl+fullscreen__fromsearch__1#entry4462299

http://www.gamedev.n..._1#entry4831410
http://www.gamedev.n...__1#entry551489
http://www.gamedev.n..._1#entry4462299


>_< bah, thanks. I am bad at searching I guess. I was forgetting to re-enable GL_VERTEX_ARRAY and GL_TEXTURE_COORD_ARRAY.

This topic is closed to new replies.

Advertisement