Fullscreen -> WindowMode; defaults to pseudofullscreen which does hax on windows, falls back to normal fullscreen for everyone else.

This commit is contained in:
Paul Chote
2010-07-07 23:00:24 +12:00
parent 731e7af45a
commit 5fba682fe0
5 changed files with 35 additions and 23 deletions

View File

@@ -50,27 +50,31 @@ namespace OpenRA.GlRenderer
throw new InvalidOperationException("GL Error");
}
public GraphicsDevice(int width, int height, bool windowed, bool vsync)
public GraphicsDevice(int width, int height, WindowMode window, bool vsync)
{
Sdl.SDL_Init(Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_RED_SIZE, 8);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_GREEN_SIZE, 8);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 8);
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
// pseudo-fullscreen, for sane debugging.
Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_NOFRAME | Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
}
else
{
// OSX doesn't like this, due to quirks of their WM.
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_OPENGL | (windowed ? 0 : Sdl.SDL_FULLSCREEN));
}
Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);
int windowFlags = 0;
switch (window)
{
case WindowMode.Fullscreen:
windowFlags |= Sdl.SDL_FULLSCREEN;
break;
case WindowMode.PseudoFullscreen:
// pseudo-fullscreen only reliably works on windows; fall back to fullscreen for everyone else
windowFlags |= (Environment.OSVersion.Platform == PlatformID.Win32NT) ? Sdl.SDL_NOFRAME : Sdl.SDL_FULLSCREEN;
break;
default:
break;
}
surf = Sdl.SDL_SetVideoMode(width, height, 0, Sdl.SDL_OPENGL | windowFlags);
Sdl.SDL_WM_SetCaption("OpenRA", "OpenRA");
Sdl.SDL_ShowCursor(0);
Sdl.SDL_EnableUNICODE(1);