Simplify names, remove unused usings, remove redundant casts.

This commit is contained in:
RoosterDragon
2016-01-17 21:24:41 +00:00
parent aaeb715006
commit 8e89a6a696
304 changed files with 218 additions and 639 deletions

View File

@@ -8,9 +8,7 @@
*/
#endregion
using System;
using System.Drawing;
using System.Reflection;
using OpenRA;
[assembly: Platform(typeof(OpenRA.Platforms.Default.DeviceFactory))]

View File

@@ -13,11 +13,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using OpenAL;
using OpenRA.FileFormats;
using OpenRA.FileSystem;
using OpenRA.GameRules;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Platforms.Default
{
@@ -106,7 +101,7 @@ namespace OpenRA.Platforms.Default
throw new InvalidOperationException("Can't create OpenAL device");
}
var ctx = ALC10.alcCreateContext(device, (int[])null);
var ctx = ALC10.alcCreateContext(device, null);
if (ctx == IntPtr.Zero)
throw new InvalidOperationException("Can't create OpenAL context");
ALC10.alcMakeContextCurrent(ctx);

View File

@@ -362,11 +362,11 @@ namespace OpenRA.Platforms.Default
DetectGLFeatures();
if (!Features.HasFlag(GLFeatures.GL2OrGreater) || !Features.HasFlag(GLFeatures.FramebufferExt))
{
WriteGraphicsLog("Unsupported OpenGL version: " + glGetString(OpenGL.GL_VERSION));
WriteGraphicsLog("Unsupported OpenGL version: " + glGetString(GL_VERSION));
throw new InvalidProgramException("OpenGL Version Error: See graphics.log for details.");
}
else
Console.WriteLine("OpenGL version: " + glGetString(OpenGL.GL_VERSION));
Console.WriteLine("OpenGL version: " + glGetString(GL_VERSION));
try
{
@@ -437,7 +437,7 @@ namespace OpenRA.Platforms.Default
}
catch (Exception e)
{
OpenGL.WriteGraphicsLog("Failed to initialize OpenGL bindings.\nInner exception was: {0}".F(e));
WriteGraphicsLog("Failed to initialize OpenGL bindings.\nInner exception was: {0}".F(e));
throw new InvalidProgramException("Failed to initialize OpenGL. See graphics.log for details.");
}
}
@@ -451,7 +451,7 @@ namespace OpenRA.Platforms.Default
{
try
{
var versionString = glGetString(OpenGL.GL_VERSION);
var versionString = glGetString(GL_VERSION);
var version = versionString.Contains(" ") ? versionString.Split(' ')[0].Split('.') : versionString.Split('.');
var major = 0;
@@ -474,8 +474,8 @@ namespace OpenRA.Platforms.Default
public static void CheckGLError()
{
var n = OpenGL.glGetError();
if (n != OpenGL.GL_NO_ERROR)
var n = glGetError();
if (n != GL_NO_ERROR)
{
var error = "GL Error: {0}\n{1}".F(n, new StackTrace());
WriteGraphicsLog(error);
@@ -488,7 +488,7 @@ namespace OpenRA.Platforms.Default
Log.Write("graphics", message);
Log.Write("graphics", "");
Log.Write("graphics", "OpenGL Information:");
var vendor = OpenGL.glGetString(OpenGL.GL_VENDOR);
var vendor = glGetString(GL_VENDOR);
Log.Write("graphics", "Vendor: {0}", vendor);
if (vendor.Contains("Microsoft"))
{
@@ -498,11 +498,11 @@ namespace OpenRA.Platforms.Default
Log.Write("graphics", msg);
}
Log.Write("graphics", "Renderer: {0}", OpenGL.glGetString(OpenGL.GL_RENDERER));
Log.Write("graphics", "GL Version: {0}", OpenGL.glGetString(OpenGL.GL_VERSION));
Log.Write("graphics", "Shader Version: {0}", OpenGL.glGetString(OpenGL.GL_SHADING_LANGUAGE_VERSION));
Log.Write("graphics", "Renderer: {0}", glGetString(GL_RENDERER));
Log.Write("graphics", "GL Version: {0}", glGetString(GL_VERSION));
Log.Write("graphics", "Shader Version: {0}", glGetString(GL_SHADING_LANGUAGE_VERSION));
Log.Write("graphics", "Available extensions:");
Log.Write("graphics", OpenGL.glGetString(OpenGL.GL_EXTENSIONS));
Log.Write("graphics", glGetString(GL_EXTENSIONS));
}
}
}

View File

@@ -12,8 +12,6 @@ using System;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using OpenRA;
using OpenRA.Graphics;
using SDL2;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Platforms.Default
{
class Sdl2Input
{
MouseButton lastButtonBits = (MouseButton)0;
MouseButton lastButtonBits = MouseButton.None;
public string GetClipboardText() { return SDL.SDL_GetClipboardText(); }
public bool SetClipboardText(string text) { return SDL.SDL_SetClipboardText(text) == 0; }

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Platforms.Default
int success;
OpenGL.glGetShaderiv(shader, OpenGL.GL_COMPILE_STATUS, out success);
OpenGL.CheckGLError();
if (success == (int)OpenGL.GL_FALSE)
if (success == OpenGL.GL_FALSE)
{
int len;
OpenGL.glGetShaderiv(shader, OpenGL.GL_INFO_LOG_LENGTH, out len);
@@ -83,7 +83,7 @@ namespace OpenRA.Platforms.Default
int success;
OpenGL.glGetProgramiv(program, OpenGL.GL_LINK_STATUS, out success);
OpenGL.CheckGLError();
if (success == (int)OpenGL.GL_FALSE)
if (success == OpenGL.GL_FALSE)
{
int len;
OpenGL.glGetProgramiv(program, OpenGL.GL_INFO_LOG_LENGTH, out len);

View File

@@ -63,14 +63,14 @@ namespace OpenRA.Platforms.Default
OpenGL.CheckGLError();
var filter = scaleFilter == TextureScaleFilter.Linear ? OpenGL.GL_LINEAR : OpenGL.GL_NEAREST;
OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, (int)filter);
OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, filter);
OpenGL.CheckGLError();
OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, (int)filter);
OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, filter);
OpenGL.CheckGLError();
OpenGL.glTexParameterf(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, (float)OpenGL.GL_CLAMP_TO_EDGE);
OpenGL.glTexParameterf(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE);
OpenGL.CheckGLError();
OpenGL.glTexParameterf(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, (float)OpenGL.GL_CLAMP_TO_EDGE);
OpenGL.glTexParameterf(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE);
OpenGL.CheckGLError();
OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_BASE_LEVEL, 0);
@@ -137,7 +137,7 @@ namespace OpenRA.Platforms.Default
{
Size = new Size(bitmap.Width, bitmap.Height);
var bits = bitmap.LockBits(bitmap.Bounds(),
ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
PrepareTexture();
OpenGL.glTexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA8, bits.Width, bits.Height,