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"?> <?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> <PropertyGroup>
<ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid> <ProjectGuid>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

View File

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

View File

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

View File

@ -143,7 +143,7 @@ namespace ClassicalSharp.GraphicsAPI {
protected int GetSizeInBytes( int count, VertexFormat format ) { protected int GetSizeInBytes( int count, VertexFormat format ) {
return count * strideSizes[(int)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 ); public abstract void SetMatrixMode( MatrixType mode );

View File

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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?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> <PropertyGroup>
<ProjectGuid>{23B9BDA8-4330-46AB-9012-08D87430391A}</ProjectGuid> <ProjectGuid>{23B9BDA8-4330-46AB-9012-08D87430391A}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

View File

@ -1,123 +1,124 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </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" />
<value>17, 17</value> <data name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing">
</metadata> <value>17, 17</value>
</data>
</root> </root>

View File

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

View File

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