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

@@ -102,4 +102,11 @@ namespace OpenRA.FileFormats.Graphics
public readonly T Start, End;
public Range( T start, T end ) { Start = start; End = end; }
}
public enum WindowMode
{
Windowed,
Fullscreen,
PseudoFullscreen,
}
}

View File

@@ -575,9 +575,8 @@ namespace OpenRA
Renderer.SheetSize = Settings.SheetSize;
bool windowed = !Game.Settings.Fullscreen;
var resolution = GetResolution(settings);
renderer = new Renderer(resolution, windowed);
renderer = new Renderer(resolution, Game.Settings.WindowMode);
resolution = renderer.Resolution;
controller = new Controller();

View File

@@ -18,6 +18,8 @@
*/
#endregion
using OpenRA.FileFormats.Graphics;
namespace OpenRA.GameRules
{
public class UserSettings
@@ -32,7 +34,7 @@ namespace OpenRA.GameRules
// Window settings
public readonly int Width = 0;
public readonly int Height = 0;
public readonly bool Fullscreen = false;
public readonly WindowMode WindowMode = WindowMode.PseudoFullscreen;
public bool MusicPlayer = true;
// Internal game settings

View File

@@ -51,9 +51,9 @@ namespace OpenRA.Graphics
public Size Resolution { get { return device.WindowSize; } }
public Renderer(Size resolution, bool windowed)
public Renderer(Size resolution, OpenRA.FileFormats.Graphics.WindowMode windowMode)
{
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Gl.dll" ) ), resolution.Width, resolution.Height, windowed, false );
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Gl.dll" ) ), resolution.Width, resolution.Height, windowMode, false );
SpriteShader = device.CreateShader(FileSystem.Open("shaders/world-shp.fx"));
LineShader = device.CreateShader(FileSystem.Open("shaders/line.fx"));
@@ -69,12 +69,12 @@ namespace OpenRA.Graphics
TitleFont = new SpriteFont(this, "titles.ttf", 48);
}
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool windowed, bool vsync )
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window, bool vsync )
{
foreach( RendererAttribute r in rendererDll.GetCustomAttributes( typeof( RendererAttribute ), false ) )
{
return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( int ), typeof( int ), typeof( bool ), typeof( bool ) } )
.Invoke( new object[] { width, height, windowed, vsync } );
return (IGraphicsDevice)r.Type.GetConstructor( new Type[] { typeof( int ), typeof( int ), typeof( WindowMode ), typeof( bool ) } )
.Invoke( new object[] { width, height, window, vsync } );
}
throw new NotImplementedException();
}

View File

@@ -50,7 +50,7 @@ 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);
@@ -59,18 +59,22 @@ namespace OpenRA.GlRenderer
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)
int windowFlags = 0;
switch (window)
{
// 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));
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);