bool ScreenMgr::Screen::SetVideoMode()
{
unsignedint oldWidth = width;
unsignedint oldHeight = height;
SDL_SetGamma(gamma, gamma, gamma);
flags = SDL_OPENGL | isFullScreen*SDL_FULLSCREEN; // Other places that I use a bool like an int it complains, but not here. *shrug*
ratio = float(width)/float(height);
if(SDL_SetVideoMode(width, height, bpp, flags) == 0)
{
width = oldWidth;
height = oldHeight;
bpp = unsigned int(SDL_GetVideoInfo()->vfmt->BitsPerPixel);
LogMgr ::Inst()->LogErr ("* Video mode set failed: %s", SDL_GetError());
ConsoleMgr ::Inst()->AddText("* Video mode set failed: %s", SDL_GetError());
return false;
}
glViewport(0, 0, width, height);
bpp = unsigned int(SDL_GetVideoInfo()->vfmt->BitsPerPixel);
// Hip Hop our text over back to where it ought to be
if(pFps)
{
pFps->x = width-(strlen(fps.GetFpsText())*10);
pFps->y = height-20;
}
if(pTime)
{
pTime->x = width-(strlen(timeText)*10);
pTime->y = height-35;
}
/* When we change contexts (going to fullscreen, etc
everything in vram gets blown away. What all gets
held in vram is a subject that I cant find an
authoritative source on. Some sources seem to think
that it could depend on hardware implementation.
Things known to get lost: textures, display lists.
*/
static bool fswitch = false;
if(!fswitch)
{
fswitch = true;
}
else
{
Main::RefreshOGLContext();
}
//StateMgr::Inst()->StateSync(); // State *should* be preserved in context change
// However, things like the values of glBlendFunc
// are NOT preserved. Those things aren't handled
// by the the state manager.
return true;
}