/// <summary>Changes to or from fullscreen mode.</summary>
internal static void ToggleFullscreen()
{
Fullscreen = !Fullscreen;
// begin HACK //
Renderer.ClearDisplayLists();
if (World.MouseGrabEnabled)
{
SDL.SDL_SetRelativeMouseMode(SDL.SDL_bool.SDL_FALSE);
}
GL.Disable(EnableCap.Fog);
Renderer.FogEnabled = false;
GL.Disable(EnableCap.Lighting);
Renderer.LightingEnabled = false;
Textures.UnloadAllTextures();
if (Fullscreen)
{
SDL.SDL_SetWindowSize(Window, Options.Current.FullscreenWidth, Options.Current.FullscreenHeight);
SDL.SDL_SetWindowFullscreen(Window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN);
Width = Options.Current.FullscreenWidth;
Height = Options.Current.FullscreenHeight;
}
else
{
SDL.SDL_SetWindowSize(Window, Options.Current.WindowWidth, Options.Current.WindowHeight);
SDL.SDL_SetWindowFullscreen(Window, 0);
Width = Options.Current.WindowWidth;
Height = Options.Current.WindowHeight;
}
Renderer.InitializeLighting();
MainLoop.UpdateViewport(MainLoop.ViewPortChangeMode.NoChange);
MainLoop.InitializeMotionBlur();
Timetable.CreateTimetable();
Timetable.UpdateCustomTimetable(null, null);
if (World.MouseGrabEnabled)
{
SDL.SDL_SetRelativeMouseMode(SDL.SDL_bool.SDL_TRUE);
}
World.MouseGrabTarget = new OpenBveApi.Math.Vector2D(0.0, 0.0);
World.MouseGrabIgnoreOnce = true;
World.InitializeCameraRestriction();
if (Renderer.OptionBackfaceCulling)
{
GL.Enable(EnableCap.CullFace);
}
else
{
GL.Disable(EnableCap.CullFace);
}
Renderer.ReAddObjects();
// end HACK //
}