diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index 42f7cc1d10..625d382e4d 100755 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -56,7 +56,7 @@ namespace OpenRA.GameRules { public string Renderer = "Gl"; public WindowMode Mode = WindowMode.PseudoFullscreen; - public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); + public int2 FullscreenSize = new int2(0,0); public int2 WindowedSize = new int2(1024, 768); public readonly int2 MinResolution = new int2(800, 600); diff --git a/OpenRA.Game/Graphics/Renderer.cs b/OpenRA.Game/Graphics/Renderer.cs index 3af5ec6892..91af674593 100644 --- a/OpenRA.Game/Graphics/Renderer.cs +++ b/OpenRA.Game/Graphics/Renderer.cs @@ -125,18 +125,11 @@ namespace OpenRA.Graphics static Size GetResolution(WindowMode windowmode) { - var desktopResolution = Screen.PrimaryScreen.Bounds.Size; - var customSize = (windowmode == WindowMode.Windowed) + var size = (windowmode == WindowMode.Windowed) ? Game.Settings.Graphics.WindowedSize : Game.Settings.Graphics.FullscreenSize; - if (customSize.X > 0 && customSize.Y > 0) - { - desktopResolution.Width = customSize.X; - desktopResolution.Height = customSize.Y; - } - - return desktopResolution; + return new Size(size.X, size.Y); } static IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window, bool vsync ) diff --git a/OpenRA.Renderer.Cg/GraphicsDevice.cs b/OpenRA.Renderer.Cg/GraphicsDevice.cs index 756779c040..60740591dd 100755 --- a/OpenRA.Renderer.Cg/GraphicsDevice.cs +++ b/OpenRA.Renderer.Cg/GraphicsDevice.cs @@ -12,6 +12,7 @@ using System; using System.Drawing; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using OpenRA.FileFormats.Graphics; using Tao.Cg; using Tao.OpenGl; @@ -111,6 +112,17 @@ namespace OpenRA.Renderer.Cg break; } + var info = (Sdl.SDL_VideoInfo) Marshal.PtrToStructure( + Sdl.SDL_GetVideoInfo(), typeof(Sdl.SDL_VideoInfo)); + Console.WriteLine("Desktop resolution: {0}x{1}", + info.current_w, info.current_h); + + if (size.Width == 0 && size.Height == 0) + { + Console.WriteLine("No custom resolution provided, using desktop resolution"); + size = new Size( info.current_w, info.current_h ); + } + Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height); surf = Sdl.SDL_SetVideoMode( size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags ); diff --git a/OpenRA.Renderer.Gl/GraphicsDevice.cs b/OpenRA.Renderer.Gl/GraphicsDevice.cs index 7033f27de8..5c47c587a9 100755 --- a/OpenRA.Renderer.Gl/GraphicsDevice.cs +++ b/OpenRA.Renderer.Gl/GraphicsDevice.cs @@ -12,6 +12,7 @@ using System; using System.Drawing; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using OpenRA.FileFormats.Graphics; using Tao.OpenGl; using Tao.Sdl; @@ -96,6 +97,19 @@ namespace OpenRA.Renderer.Glsl break; } + var info = (Sdl.SDL_VideoInfo) Marshal.PtrToStructure( + Sdl.SDL_GetVideoInfo(), typeof(Sdl.SDL_VideoInfo)); + Console.WriteLine("Desktop resolution: {0}x{1}", + info.current_w, info.current_h); + + if (size.Width == 0 && size.Height == 0) + { + Console.WriteLine("No custom resolution provided, using desktop resolution"); + size = new Size( info.current_w, info.current_h ); + } + + Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height); + surf = Sdl.SDL_SetVideoMode( size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags ); Sdl.SDL_WM_SetCaption( "OpenRA", "OpenRA" ); @@ -112,8 +126,11 @@ namespace OpenRA.Renderer.Glsl "GL_ARB_fragment_shader", "GL_ARB_vertex_buffer_object", }; - + var extensions = Gl.glGetString(Gl.GL_EXTENSIONS); + if (extensions == null) + Console.WriteLine("Failed to fetch GL_EXTENSIONS, this is bad."); + var missingExtensions = required.Where( r => !extensions.Contains(r) ).ToArray(); if (missingExtensions.Any())