From a212881e72425b4d9bc8db1c24ca1d06ec7ef620 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 7 Sep 2009 23:28:59 +0000 Subject: [PATCH] Fixed several code instances that relies on C# 3.0 features. --- .../OpenGL/EXT/GeometryShaderAdvanced.cs | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Source/Examples/OpenGL/EXT/GeometryShaderAdvanced.cs b/Source/Examples/OpenGL/EXT/GeometryShaderAdvanced.cs index 0d1e0085..53ddc5de 100644 --- a/Source/Examples/OpenGL/EXT/GeometryShaderAdvanced.cs +++ b/Source/Examples/OpenGL/EXT/GeometryShaderAdvanced.cs @@ -82,6 +82,13 @@ namespace Examples.Tutorial { public Vector3 Position, Normal; public Vector2 Texture; + + public VertexPositionNormalTexture(Vector3 position, Vector3 normal, Vector2 texture) + { + Position = position; + Normal = normal; + Texture = texture; + } } #region Fields @@ -1015,7 +1022,7 @@ namespace Examples.Tutorial static VertexPositionNormalTexture[] CalculateSphereVertices(float radius, float height, byte segments, byte rings) { - var data = new VertexPositionNormalTexture[segments * rings]; + VertexPositionNormalTexture[] data = new VertexPositionNormalTexture[segments * rings]; int i = 0; @@ -1026,20 +1033,16 @@ namespace Examples.Tutorial { double theta = (x / (segments - 1)) * 2 * Math.PI; - Vector3 v = new Vector3() - { - X = (float)(radius * Math.Sin(phi) * Math.Cos(theta)), - Y = (float)(height * Math.Cos(phi)), - Z = (float)(radius * Math.Sin(phi) * Math.Sin(theta)), - }; + Vector3 v = new Vector3( + (float)(radius * Math.Sin(phi) * Math.Cos(theta)), + (float)(height * Math.Cos(phi)), + (float)(radius * Math.Sin(phi) * Math.Sin(theta))); Vector3 n = Vector3.Normalize(v); - Vector2 uv = new Vector2() - { - X = (float)(x / (segments - 1)), - Y = (float)(y / (rings - 1)) - }; + Vector2 uv = new Vector2( + (float)(x / (segments - 1)), + (float)(y / (rings - 1))); // Using data[i++] causes i to be incremented multiple times in Mono 2.2 (bug #479506). - data[i] = new VertexPositionNormalTexture() { Position = v, Normal = n, Texture = uv }; + data[i] = new VertexPositionNormalTexture(v, n, uv); i++; } @@ -1050,8 +1053,8 @@ namespace Examples.Tutorial static ushort[] CalculateSphereElements(float radius, float height, byte segments, byte rings) { - var num_vertices = segments * rings; - var data = new ushort[num_vertices * 6]; + int num_vertices = segments * rings; + ushort[] data = new ushort[num_vertices * 6]; ushort i = 0;