fix broken detection of desktop resolution on linux
This commit is contained in:
@@ -56,7 +56,7 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
public string Renderer = "Gl";
|
public string Renderer = "Gl";
|
||||||
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
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 int2 WindowedSize = new int2(1024, 768);
|
||||||
public readonly int2 MinResolution = new int2(800, 600);
|
public readonly int2 MinResolution = new int2(800, 600);
|
||||||
|
|
||||||
|
|||||||
@@ -125,18 +125,11 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
static Size GetResolution(WindowMode windowmode)
|
static Size GetResolution(WindowMode windowmode)
|
||||||
{
|
{
|
||||||
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;
|
var size = (windowmode == WindowMode.Windowed)
|
||||||
var customSize = (windowmode == WindowMode.Windowed)
|
|
||||||
? Game.Settings.Graphics.WindowedSize
|
? Game.Settings.Graphics.WindowedSize
|
||||||
: Game.Settings.Graphics.FullscreenSize;
|
: Game.Settings.Graphics.FullscreenSize;
|
||||||
|
|
||||||
if (customSize.X > 0 && customSize.Y > 0)
|
return new Size(size.X, size.Y);
|
||||||
{
|
|
||||||
desktopResolution.Width = customSize.X;
|
|
||||||
desktopResolution.Height = customSize.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return desktopResolution;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window, bool vsync )
|
static IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, WindowMode window, bool vsync )
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
using Tao.Cg;
|
using Tao.Cg;
|
||||||
using Tao.OpenGl;
|
using Tao.OpenGl;
|
||||||
@@ -111,6 +112,17 @@ namespace OpenRA.Renderer.Cg
|
|||||||
break;
|
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);
|
Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);
|
||||||
|
|
||||||
surf = Sdl.SDL_SetVideoMode( size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags );
|
surf = Sdl.SDL_SetVideoMode( size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags );
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
using Tao.OpenGl;
|
using Tao.OpenGl;
|
||||||
using Tao.Sdl;
|
using Tao.Sdl;
|
||||||
@@ -96,6 +97,19 @@ namespace OpenRA.Renderer.Glsl
|
|||||||
break;
|
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 );
|
surf = Sdl.SDL_SetVideoMode( size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags );
|
||||||
|
|
||||||
Sdl.SDL_WM_SetCaption( "OpenRA", "OpenRA" );
|
Sdl.SDL_WM_SetCaption( "OpenRA", "OpenRA" );
|
||||||
@@ -112,8 +126,11 @@ namespace OpenRA.Renderer.Glsl
|
|||||||
"GL_ARB_fragment_shader",
|
"GL_ARB_fragment_shader",
|
||||||
"GL_ARB_vertex_buffer_object",
|
"GL_ARB_vertex_buffer_object",
|
||||||
};
|
};
|
||||||
|
|
||||||
var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);
|
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();
|
var missingExtensions = required.Where( r => !extensions.Contains(r) ).ToArray();
|
||||||
|
|
||||||
if (missingExtensions.Any())
|
if (missingExtensions.Any())
|
||||||
|
|||||||
Reference in New Issue
Block a user