Downgrade to C# 3.0, use shorthand array initialisers where possible.

This commit is contained in:
UnknownShadow200 2015-05-31 08:57:05 +10:00
parent 0cd3f22415
commit ab42202a34
9 changed files with 150 additions and 153 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

View file

@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 4.4
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassicalSharp", "ClassicalSharp.csproj", "{BEB1C785-5CAD-48FF-A886-876BF0A318D4}"
EndProject

View file

@ -26,7 +26,7 @@ namespace ClassicalSharp.GraphicsAPI {
const int vBufferSize = 2048;
MatrixStack viewStack, projStack, texStack;
MatrixStack curStack;
PrimitiveType[] modeMappings = new PrimitiveType[] {
PrimitiveType[] modeMappings = {
PrimitiveType.TriangleList, PrimitiveType.LineList,
PrimitiveType.TriangleStrip,
};
@ -47,7 +47,7 @@ namespace ClassicalSharp.GraphicsAPI {
set { device.RenderState.AlphaBlendEnable = value; }
}
Compare[] compareFuncs = new Compare[] {
Compare[] compareFuncs = {
Compare.Always, Compare.NotEqual, Compare.Never, Compare.Less,
Compare.LessEqual, Compare.Equal, Compare.GreaterEqual, Compare.Greater,
};
@ -56,7 +56,7 @@ namespace ClassicalSharp.GraphicsAPI {
device.RenderState.ReferenceAlpha = (int)( value * 255f );
}
Blend[] blendFuncs = new Blend[] {
Blend[] blendFuncs = {
Blend.Zero, Blend.One,
Blend.SourceAlpha, Blend.InvSourceAlpha,
Blend.DestinationAlpha, Blend.InvDestinationAlpha,
@ -82,7 +82,7 @@ namespace ClassicalSharp.GraphicsAPI {
device.RenderState.FogEnd = value;
}
FogMode[] modes = new FogMode[] { FogMode.Linear, FogMode.Exp, FogMode.Exp2 };
FogMode[] modes = { FogMode.Linear, FogMode.Exp, FogMode.Exp2 };
public override void SetFogMode( Fog mode ) {
device.RenderState.FogTableMode = modes[(int)mode];
}
@ -186,14 +186,14 @@ namespace ClassicalSharp.GraphicsAPI {
device.DrawUserPrimitives( modeMappings[(int)mode], count, vertices );
}
FillMode[] fillModes = new FillMode[] { FillMode.Point, FillMode.WireFrame, FillMode.Solid };
FillMode[] fillModes = { FillMode.Point, FillMode.WireFrame, FillMode.Solid };
public override void SetFillType( FillType type ) {
device.RenderState.FillMode = fillModes[(int)type];
}
#region Vertex buffers
VertexFormats[] formatMapping = new VertexFormats[] {
VertexFormats[] formatMapping = {
VertexFormats.Position | VertexFormats.Texture1,
VertexFormats.Position | VertexFormats.Diffuse,
VertexFormats.Position | VertexFormats.Texture1 | VertexFormats.Diffuse,

View file

@ -143,7 +143,7 @@ namespace ClassicalSharp.GraphicsAPI {
protected int GetSizeInBytes( int count, VertexFormat format ) {
return count * strideSizes[(int)format];
}
protected static int[] strideSizes = new [] { 20, 16, 24 };
protected static int[] strideSizes = { 20, 16, 24 };
public abstract void SetMatrixMode( MatrixType mode );

View file

@ -16,9 +16,7 @@ namespace ClassicalSharp.GraphicsAPI {
int textureDimensions;
const string vboExt = "GL_ARB_vertex_buffer_object";
BeginMode[] modeMappings = new BeginMode[] {
BeginMode.Triangles, BeginMode.Lines, BeginMode.TriangleStrip,
};
BeginMode[] modeMappings = { BeginMode.Triangles, BeginMode.Lines, BeginMode.TriangleStrip };
public OpenGLApi() {
GL.GetInteger( GetPName.MaxTextureSize, out textureDimensions );
@ -46,7 +44,7 @@ namespace ClassicalSharp.GraphicsAPI {
set { ToggleCap( EnableCap.Blend, value ); }
}
AlphaFunction[] alphaFuncs = new AlphaFunction[] {
AlphaFunction[] alphaFuncs = {
AlphaFunction.Always, AlphaFunction.Notequal,
AlphaFunction.Never, AlphaFunction.Less,
AlphaFunction.Lequal, AlphaFunction.Equal,
@ -56,12 +54,12 @@ namespace ClassicalSharp.GraphicsAPI {
GL.AlphaFunc( alphaFuncs[(int)func], value );
}
BlendingFactorSrc[] srcBlendFuncs = new BlendingFactorSrc[] {
BlendingFactorSrc[] srcBlendFuncs = {
BlendingFactorSrc.Zero, BlendingFactorSrc.One,
BlendingFactorSrc.SrcAlpha, BlendingFactorSrc.OneMinusSrcAlpha,
BlendingFactorSrc.DstAlpha, BlendingFactorSrc.OneMinusDstAlpha,
};
BlendingFactorDest[] destBlendFuncs = new BlendingFactorDest[] {
BlendingFactorDest[] destBlendFuncs = {
BlendingFactorDest.Zero, BlendingFactorDest.One,
BlendingFactorDest.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha,
BlendingFactorDest.DstAlpha, BlendingFactorDest.OneMinusDstAlpha,
@ -87,7 +85,7 @@ namespace ClassicalSharp.GraphicsAPI {
GL.Fog( FogParameter.FogEnd, value );
}
FogMode[] fogModes = new FogMode[] { FogMode.Linear, FogMode.Exp, FogMode.Exp2 };
FogMode[] fogModes = { FogMode.Linear, FogMode.Exp, FogMode.Exp2 };
public override void SetFogMode( Fog mode ) {
GL.Fog( FogParameter.FogMode, (int)fogModes[(int)mode] );
}
@ -163,7 +161,7 @@ namespace ClassicalSharp.GraphicsAPI {
GL.ColorMask( red, green, blue, alpha );
}
DepthFunction[] depthFuncs = new DepthFunction[] {
DepthFunction[] depthFuncs = {
DepthFunction.Always, DepthFunction.Notequal,
DepthFunction.Never, DepthFunction.Less,
DepthFunction.Lequal, DepthFunction.Equal,
@ -219,7 +217,7 @@ namespace ClassicalSharp.GraphicsAPI {
GL.End();
}
PolygonMode[] fillModes = new PolygonMode[] { PolygonMode.Point, PolygonMode.Line, PolygonMode.Fill };
PolygonMode[] fillModes = { PolygonMode.Point, PolygonMode.Line, PolygonMode.Fill };
public override void SetFillType( FillType type ) {
GL.PolygonMode( MaterialFace.FrontAndBack, fillModes[(int)type] );
}
@ -388,9 +386,7 @@ namespace ClassicalSharp.GraphicsAPI {
#region Matrix manipulation
MatrixMode lastMode = 0;
MatrixMode[] matrixModes = new MatrixMode[] {
MatrixMode.Projection, MatrixMode.Modelview, MatrixMode.Texture,
};
MatrixMode[] matrixModes = { MatrixMode.Projection, MatrixMode.Modelview, MatrixMode.Texture };
public override void SetMatrixMode( MatrixType mode ) {
MatrixMode glMode = matrixModes[(int)mode];
if( glMode != lastMode ) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{23B9BDA8-4330-46AB-9012-08D87430391A}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

View file

@ -117,7 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing">
<value>17, 17</value>
</metadata>
</data>
</root>

View file

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<supportedRuntime version="v2.0.50727" /></startup>
</configuration>

View file

@ -1,3 +1,3 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
<startup><supportedRuntime version="v2.0.50727" /></startup></configuration>