From 5174e33b92ee259107ac887b059e9ebea0607e31 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 19 Apr 2011 04:03:52 +0000 Subject: [PATCH] - attempt a better video recovery when selected mode and colour bits fail --- .../sources/platform/sdl/gl_wrap.cpp | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 930d90420..ea532f0b6 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -115,17 +115,35 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg.str().c_str()); for(int i = 32; i >= 8; i-=8) { - // try to revert to 800x600 - screen = SDL_SetVideoMode(800, 600, i, flags); - if(screen == 0) { - // try to revert to 640x480 - screen = SDL_SetVideoMode(640, 480, i, flags); - if(screen == 0) { - throw std::runtime_error(msg.str()); + // try different color bits + screen = SDL_SetVideoMode(resW, resH, i, flags); + if(screen != 0) { + break; + } + } + + if(screen == 0) { + for(int i = 32; i >= 8; i-=8) { + // try to revert to 800x600 + screen = SDL_SetVideoMode(800, 600, i, flags); + if(screen != 0) { + break; } } } - //throw std::runtime_error(msg.str()); + if(screen == 0) { + for(int i = 32; i >= 8; i-=8) { + // try to revert to 640x480 + screen = SDL_SetVideoMode(640, 480, i, flags); + if(screen != 0) { + break; + } + } + } + + if(screen == 0) { + throw std::runtime_error(msg.str()); + } } SDL_WM_GrabInput(SDL_GRAB_OFF);