diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj index 7918c15f..5e8615ce 100644 --- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj +++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj @@ -32,20 +32,42 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_Linux.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_Linux.csproj index f20fb7d7..8d02a7b5 100644 --- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_Linux.csproj +++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_Linux.csproj @@ -32,20 +32,42 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_PSVita.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_PSVita.csproj index 6a680889..9958592f 100644 --- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_PSVita.csproj +++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_PSVita.csproj @@ -32,20 +32,42 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_WindowsMetro.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_WindowsMetro.csproj index 4dbfa0e7..d346edae 100644 --- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_WindowsMetro.csproj +++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline_WindowsMetro.csproj @@ -34,20 +34,42 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/BuiltInTypeWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/BuiltInTypeWriter.cs new file mode 100644 index 00000000..66e39f4c --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/BuiltInTypeWriter.cs @@ -0,0 +1,13 @@ +using System; + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler +{ + internal abstract class BuiltinTypeWriter : ContentTypeWriter + { + public override string GetRuntimeReader(TargetPlatform targetPlatform) + { + // TODO! + return ""; + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/ContentTypeWriterAttribute.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/ContentTypeWriterAttribute.cs index a056c484..c33bc047 100644 --- a/ANX.Framework.Content.Pipeline/Serialization/Compiler/ContentTypeWriterAttribute.cs +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/ContentTypeWriterAttribute.cs @@ -9,6 +9,7 @@ using System; namespace ANX.Framework.Content.Pipeline.Serialization.Compiler { + [AttributeUsage(AttributeTargets.Class)] public class ContentTypeWriterAttribute : Attribute { public ContentTypeWriterAttribute() diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingBoxWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingBoxWriter.cs new file mode 100644 index 00000000..9844493b --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingBoxWriter.cs @@ -0,0 +1,18 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class BoundingBoxWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, BoundingBox value) + { + output.Write(value.Min); + output.Write(value.Max); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingFrustumWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingFrustumWriter.cs new file mode 100644 index 00000000..11ae4b1e --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingFrustumWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class BoundingFrustumWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, BoundingFrustum value) + { + output.Write(value.Matrix); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingSphereWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingSphereWriter.cs new file mode 100644 index 00000000..3e79832a --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/BoundingSphereWriter.cs @@ -0,0 +1,18 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class BoundingSphereWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, BoundingSphere value) + { + output.Write(value.Center); + output.Write(value.Radius); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/ColorWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/ColorWriter.cs new file mode 100644 index 00000000..8ca7e4b9 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/ColorWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class ColorWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Color value) + { + output.Write(value.PackedValue); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/MatrixWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/MatrixWriter.cs new file mode 100644 index 00000000..96284371 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/MatrixWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class MatrixWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Matrix value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/PlaneWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/PlaneWriter.cs new file mode 100644 index 00000000..321d3935 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/PlaneWriter.cs @@ -0,0 +1,18 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class PlaneWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Plane value) + { + output.Write(value.Normal); + output.Write(value.D); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/PointWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/PointWriter.cs new file mode 100644 index 00000000..2207066a --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/PointWriter.cs @@ -0,0 +1,18 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class PointWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Point value) + { + output.Write(value.X); + output.Write(value.Y); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/QuaternionWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/QuaternionWriter.cs new file mode 100644 index 00000000..8ce0279f --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/QuaternionWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class QuaternionWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Quaternion value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/RayWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/RayWriter.cs new file mode 100644 index 00000000..8e4f134b --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/RayWriter.cs @@ -0,0 +1,18 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class RayWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Ray value) + { + output.Write(value.Position); + output.Write(value.Direction); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/RectangleWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/RectangleWriter.cs new file mode 100644 index 00000000..874bc02f --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/RectangleWriter.cs @@ -0,0 +1,20 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class RectangleWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Rectangle value) + { + output.Write(value.X); + output.Write(value.Y); + output.Write(value.Width); + output.Write(value.Height); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector2Writer.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector2Writer.cs new file mode 100644 index 00000000..c8abf406 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector2Writer.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class Vector2Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Vector2 value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector3Writer.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector3Writer.cs new file mode 100644 index 00000000..e8279cc7 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector3Writer.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class Vector3Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Vector3 value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector4Writer.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector4Writer.cs new file mode 100644 index 00000000..12de639b --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/MathTypeWriters/Vector4Writer.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.MathTypeWriters +{ + [ContentTypeWriter] + internal class Vector4Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, Vector4 value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/BooleanWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/BooleanWriter.cs new file mode 100644 index 00000000..46381e14 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/BooleanWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class BooleanWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, byte value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/ByteWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/ByteWriter.cs new file mode 100644 index 00000000..0d7dcad5 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/ByteWriter.cs @@ -0,0 +1,26 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class ByteWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, byte value) + { + output.Write(value); + } + } + + [ContentTypeWriter] + internal class SByteWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, sbyte value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/CharWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/CharWriter.cs new file mode 100644 index 00000000..76b85736 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/CharWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class CharWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, bool value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/DoubleWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/DoubleWriter.cs new file mode 100644 index 00000000..9c88eae2 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/DoubleWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class DoubleWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, double value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int16Writer.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int16Writer.cs new file mode 100644 index 00000000..c5c76fd4 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int16Writer.cs @@ -0,0 +1,26 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class Int16Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, short value) + { + output.Write(value); + } + } + + [ContentTypeWriter] + internal class UInt16Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, ushort value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int32Writer.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int32Writer.cs new file mode 100644 index 00000000..c435e297 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int32Writer.cs @@ -0,0 +1,26 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class Int32Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, int value) + { + output.Write(value); + } + } + + [ContentTypeWriter] + internal class UInt32Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, uint value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int64Writer.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int64Writer.cs new file mode 100644 index 00000000..cdec4570 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/Int64Writer.cs @@ -0,0 +1,26 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class Int64Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, long value) + { + output.Write(value); + } + + [ContentTypeWriter] + internal class UInt64Writer : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, ulong value) + { + output.Write(value); + } + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/ObjectWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/ObjectWriter.cs new file mode 100644 index 00000000..d3f7b9de --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/ObjectWriter.cs @@ -0,0 +1,27 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class ObjectWriter : ContentTypeWriter + { + public ObjectWriter() + : base(typeof(object)) + { + } + + protected internal override void Write(ContentWriter output, object value) + { + throw new NotSupportedException(); + } + + public override string GetRuntimeReader(TargetPlatform targetPlatform) + { + throw new NotSupportedException(); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/SingleWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/SingleWriter.cs new file mode 100644 index 00000000..d420e485 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/SingleWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class SingleWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, float value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/StringWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/StringWriter.cs new file mode 100644 index 00000000..73cc82a2 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/PrimitiveTypeWriters/StringWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.PrimitiveTypeWriters +{ + [ContentTypeWriter] + internal class StringWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, string value) + { + output.Write(value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/DateTimeWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/DateTimeWriter.cs new file mode 100644 index 00000000..5a43d979 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/DateTimeWriter.cs @@ -0,0 +1,22 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.SystemTypeWriters +{ + [ContentTypeWriter] + internal class DateTimeWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, DateTime value) + { + DateTimeKind kind = value.Kind; + if (kind == DateTimeKind.Local) + { + value = value.ToUniversalTime(); + } + output.Write(value.Ticks | (long)kind << 62); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/DecimalWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/DecimalWriter.cs new file mode 100644 index 00000000..476b922a --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/DecimalWriter.cs @@ -0,0 +1,21 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.SystemTypeWriters +{ + [ContentTypeWriter] + internal class DecimalWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, decimal value) + { + int[] bits = decimal.GetBits(value); + for (int i = 0; i < bits.Length; i++) + { + output.Write(bits[i]); + } + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/NullableWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/NullableWriter.cs new file mode 100644 index 00000000..7f8e67c5 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/NullableWriter.cs @@ -0,0 +1,39 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.SystemTypeWriters +{ + [ContentTypeWriter] + internal class NullableWriter : BuiltinTypeWriter where T : struct + { + private ContentTypeWriter underlyingTypeWriter; + + protected override void Initialize(ContentCompiler compiler) + { + underlyingTypeWriter = compiler.GetTypeWriter(typeof(T)); + } + + protected internal override void Write(ContentWriter output, T? value) + { + output.Write(value.HasValue); + if (value.HasValue) + { + output.WriteRawObject(value.Value, underlyingTypeWriter); + } + } + + protected internal override void Write(ContentWriter output, object value) + { + if (value == null) + { + output.Write(false); + return; + } + + base.Write(output, value); + } + } +} diff --git a/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/TimeSpanWriter.cs b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/TimeSpanWriter.cs new file mode 100644 index 00000000..01b96594 --- /dev/null +++ b/ANX.Framework.Content.Pipeline/Serialization/Compiler/SystemTypeWriters/TimeSpanWriter.cs @@ -0,0 +1,17 @@ +using System; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.Content.Pipeline.Serialization.Compiler.SystemTypeWriters +{ + [ContentTypeWriter] + internal class TimeSpanWriter : BuiltinTypeWriter + { + protected internal override void Write(ContentWriter output, TimeSpan value) + { + output.Write(value.Ticks); + } + } +} diff --git a/ANX.Framework/ANX.Framework.csproj b/ANX.Framework/ANX.Framework.csproj index 525b7c5d..a0b9e44e 100644 --- a/ANX.Framework/ANX.Framework.csproj +++ b/ANX.Framework/ANX.Framework.csproj @@ -430,6 +430,7 @@ + @@ -472,6 +473,7 @@ + diff --git a/ANX.Framework/ANX.Framework_Linux.csproj b/ANX.Framework/ANX.Framework_Linux.csproj index 4a1429e7..5bd3e645 100644 --- a/ANX.Framework/ANX.Framework_Linux.csproj +++ b/ANX.Framework/ANX.Framework_Linux.csproj @@ -430,6 +430,7 @@ + @@ -472,6 +473,7 @@ + diff --git a/ANX.Framework/ANX.Framework_PSVita.csproj b/ANX.Framework/ANX.Framework_PSVita.csproj index bb9eafe8..9f8d0a4c 100644 --- a/ANX.Framework/ANX.Framework_PSVita.csproj +++ b/ANX.Framework/ANX.Framework_PSVita.csproj @@ -431,6 +431,7 @@ + @@ -473,6 +474,7 @@ + diff --git a/ANX.Framework/ANX.Framework_WindowsMetro.csproj b/ANX.Framework/ANX.Framework_WindowsMetro.csproj index 890e7a72..0fe0d545 100644 --- a/ANX.Framework/ANX.Framework_WindowsMetro.csproj +++ b/ANX.Framework/ANX.Framework_WindowsMetro.csproj @@ -433,6 +433,7 @@ + @@ -475,6 +476,7 @@ + diff --git a/ANX.Framework/Content/SystemTypeReaders/NullableReader.cs b/ANX.Framework/Content/SystemTypeReaders/NullableReader.cs index a2fe3cac..175aaf6f 100644 --- a/ANX.Framework/Content/SystemTypeReaders/NullableReader.cs +++ b/ANX.Framework/Content/SystemTypeReaders/NullableReader.cs @@ -20,13 +20,11 @@ namespace ANX.Framework.Content protected internal override T? Read(ContentReader input, T? existingInstance) { - bool isNull = !input.ReadBoolean(); + bool hasValue = input.ReadBoolean(); - if (isNull) - { - return null; - } - return new T?(input.ReadRawObject(this.baseTypeReader)); + return hasValue ? + new T?(input.ReadRawObject(this.baseTypeReader)) : + null; } } } diff --git a/ANX.Framework/NonXNA/Reflection/AssemblyListFile.cs b/ANX.Framework/NonXNA/Reflection/AssemblyListFile.cs index 0e291a57..bfc70030 100644 --- a/ANX.Framework/NonXNA/Reflection/AssemblyListFile.cs +++ b/ANX.Framework/NonXNA/Reflection/AssemblyListFile.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using ANX.Framework.NonXNA.Windows8; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -23,7 +24,6 @@ namespace ANX.Framework.NonXNA.Reflection #region Private private List allAssemblyNames; - private Stream assemblyListStream; #endregion #region Constructor @@ -54,8 +54,10 @@ namespace ANX.Framework.NonXNA.Reflection #region Load public void Load() { + Stream assemblyListStream = null; + #if WINDOWSMETRO - LoadStreamFromMetroAssets(); + assemblyListStream = LoadStreamFromMetroAssets(); #endif if (assemblyListStream != null) @@ -67,18 +69,14 @@ namespace ANX.Framework.NonXNA.Reflection #region LoadStreamFromMetroAssets #if WINDOWSMETRO - private void LoadStreamFromMetroAssets() + private Stream LoadStreamFromMetroAssets() { - var library = Windows.ApplicationModel.Package.Current.InstalledLocation; - try + Stream result = AssetsHelper.LoadStreamFromAssets("Assets\\" + Filename); + + if(result == null) { - var task = library.OpenStreamForReadAsync("Assets\\" + Filename); - assemblyListStream = TaskHelper.WaitForAsyncOperation(task); - } - catch - { - assemblyListStream = new MemoryStream(); - BinaryWriter writer = new BinaryWriter(assemblyListStream); + result = new MemoryStream(); + BinaryWriter writer = new BinaryWriter(result); writer.Write(5); writer.Write("ANX.PlatformSystem.Metro"); writer.Write("ANX.RenderSystem.Windows.Metro"); @@ -86,8 +84,10 @@ namespace ANX.Framework.NonXNA.Reflection writer.Write("ANX.MediaSystem.Windows.OpenAL"); writer.Write("ANX.SoundSystem.Windows.XAudio"); - assemblyListStream.Position = 0; + result.Position = 0; } + + return result; } #endif #endregion diff --git a/ANX.Framework/NonXNA/Windows8/AssetsHelper.cs b/ANX.Framework/NonXNA/Windows8/AssetsHelper.cs new file mode 100644 index 00000000..1abbc91c --- /dev/null +++ b/ANX.Framework/NonXNA/Windows8/AssetsHelper.cs @@ -0,0 +1,49 @@ +#if WINDOWSMETRO +using System; +using System.IO; +using Windows.ApplicationModel; +using Windows.Storage; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.NonXNA.Windows8 +{ + public static class AssetsHelper + { + private static StorageFolder installLocation; + + static AssetsHelper() + { + installLocation = Package.Current.InstalledLocation; + } + + public static Stream LoadStreamFromAssets(string relativeFilepath) + { + relativeFilepath = relativeFilepath.Replace("/", "\\"); + try + { + var task = installLocation.OpenStreamForReadAsync(relativeFilepath); + Stream filestream = TaskHelper.WaitForAsyncOperation(task); + + // TODO: this copy is really inefficient!! + // Find out why reading from the asset stream causes + // the position property to go crazy :/ + MemoryStream stream = new MemoryStream(); + filestream.CopyTo(stream); + filestream.Dispose(); + filestream = null; + + stream.Position = 0; + return stream; + } + catch + { + } + + return null; + } + } +} +#endif diff --git a/ANX.Framework/NonXNA/Windows8/DictionaryEntry.cs b/ANX.Framework/NonXNA/Windows8/DictionaryEntry.cs index 02bf0389..de91083e 100644 --- a/ANX.Framework/NonXNA/Windows8/DictionaryEntry.cs +++ b/ANX.Framework/NonXNA/Windows8/DictionaryEntry.cs @@ -1,45 +1,35 @@ -#if WINDOWSMETRO using System; using System.Collections; -using System.Threading.Tasks; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. // For details see: http://anxframework.codeplex.com/license +#if WINDOWSMETRO namespace ANX.Framework { - public struct DictionaryEntry - { - private Object key; - private Object value; + public struct DictionaryEntry + { + private Object key; + private Object value; - public DictionaryEntry(Object key, Object value) - { - this.key = key; - this.value = value; - } - - public Object Key - { - get { return this.key; } - set { this.key = value; } - } - - public Object Value - { - get { return this.value; } - set { this.value = value; } - } - } - - public static class TaskHelper + public DictionaryEntry(Object key, Object value) { - public static T WaitForAsyncOperation(Task task) - { - task.Wait(); - return task.Result; - } + this.key = key; + this.value = value; } + + public Object Key + { + get { return this.key; } + set { this.key = value; } + } + + public Object Value + { + get { return this.value; } + set { this.value = value; } + } + } } #endif \ No newline at end of file diff --git a/ANX.Framework/NonXNA/Windows8/TaskHelper.cs b/ANX.Framework/NonXNA/Windows8/TaskHelper.cs new file mode 100644 index 00000000..d53a3af8 --- /dev/null +++ b/ANX.Framework/NonXNA/Windows8/TaskHelper.cs @@ -0,0 +1,18 @@ +using System; +using System.Threading.Tasks; + +// This file is part of the ANX.Framework created by the +// "ANX.Framework developer group" and released under the Ms-PL license. +// For details see: http://anxframework.codeplex.com/license + +namespace ANX.Framework.NonXNA.Windows8 +{ + public static class TaskHelper + { + public static T WaitForAsyncOperation(Task task) + { + task.Wait(); + return task.Result; + } + } +} diff --git a/PlatformSystems/ANX.PlatformSystem.Metro/MetroContentManager.cs b/PlatformSystems/ANX.PlatformSystem.Metro/MetroContentManager.cs index da4e1f51..e7a60fca 100644 --- a/PlatformSystems/ANX.PlatformSystem.Metro/MetroContentManager.cs +++ b/PlatformSystems/ANX.PlatformSystem.Metro/MetroContentManager.cs @@ -1,6 +1,7 @@ using System.IO; using ANX.Framework; using ANX.Framework.NonXNA.PlatformSystem; +using ANX.Framework.NonXNA.Windows8; using Windows.ApplicationModel; using Windows.Storage; @@ -33,35 +34,7 @@ namespace ANX.PlatformSystem.Metro #region OpenStream public Stream OpenStream(string filepath) { - filepath = filepath.Replace("/", "\\"); - Stream filestream = LoadStreamFromMetroAssets(filepath); - - // TODO: this copy is really inefficient!! - // Find out why reading from the asset stream causes - // the position property to go crazy :/ - MemoryStream stream = new MemoryStream(); - filestream.CopyTo(stream); - filestream.Dispose(); - filestream = null; - - stream.Position = 0; - return stream; - } - #endregion - - #region LoadStreamFromMetroAssets - private Stream LoadStreamFromMetroAssets(string filepath) - { - try - { - var task = installLocation.OpenStreamForReadAsync(filepath); - return TaskHelper.WaitForAsyncOperation(task); - } - catch - { - } - - return null; + return AssetsHelper.LoadStreamFromAssets(filepath); } #endregion } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs index dd09748f..f592c3d4 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs @@ -195,16 +195,11 @@ namespace ANX.RenderSystem.Windows.Metro #region Apply public void Apply(GraphicsDevice graphicsDevice) { - GraphicsDeviceWindowsMetro gdMetro = - graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - var device = gdMetro.NativeDevice.NativeDevice; - var context = gdMetro.NativeDevice.NativeContext; - - UpdateNativeBlendState(device); + UpdateNativeBlendState(); this.bound = true; - context.OutputMerger.SetBlendState(nativeBlendState, - this.blendFactor, this.multiSampleMask); + NativeDxDevice.Current.OutputMerger.SetBlendState( + nativeBlendState, this.blendFactor, this.multiSampleMask); } #endregion @@ -220,7 +215,7 @@ namespace ANX.RenderSystem.Windows.Metro #endregion #region UpdateNativeBlendState - private void UpdateNativeBlendState(Dx11.Device device) + private void UpdateNativeBlendState() { if (isDirty == true || nativeBlendState == null) { @@ -230,7 +225,8 @@ namespace ANX.RenderSystem.Windows.Metro nativeBlendState = null; } - nativeBlendState = new Dx11.BlendState(device, + nativeBlendState = new Dx11.BlendState( + NativeDxDevice.Current.NativeDevice, ref blendStateDescription); isDirty = false; diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs index ff4f386d..4c0d7ac1 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs @@ -193,15 +193,10 @@ namespace ANX.RenderSystem.Windows.Metro #region Apply public void Apply(GraphicsDevice graphicsDevice) { - GraphicsDeviceWindowsMetro gdMetro = - graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - var device = gdMetro.NativeDevice.NativeDevice; - var context = gdMetro.NativeDevice.NativeContext; - - UpdateNativeDepthStencilState(device); + UpdateNativeDepthStencilState(); bound = true; - context.OutputMerger.SetDepthStencilState( + NativeDxDevice.Current.OutputMerger.SetDepthStencilState( nativeDepthStencilState, referenceStencil); } #endregion @@ -218,7 +213,7 @@ namespace ANX.RenderSystem.Windows.Metro #endregion #region UpdateNativeDepthStencilState - private void UpdateNativeDepthStencilState(Dx11.Device1 device) + private void UpdateNativeDepthStencilState() { if (isDirty == true || nativeDepthStencilState == null) { @@ -228,8 +223,8 @@ namespace ANX.RenderSystem.Windows.Metro nativeDepthStencilState = null; } - nativeDepthStencilState = - new Dx11.DepthStencilState(device, ref description); + nativeDepthStencilState = new Dx11.DepthStencilState( + NativeDxDevice.Current.NativeDevice, ref description); isDirty = false; } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs index 2ea23666..20564a78 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs @@ -14,50 +14,20 @@ namespace ANX.RenderSystem.Windows.Metro public class Effect_Metro : INativeEffect { #region Private - private Dx11.VertexShader vertexShader; - private Dx11.PixelShader pixelShader; private Effect managedEffect; #endregion #region Public - //internal Dx11.Effect NativeEffect - //{ - // get - // { - // return this.nativeEffect; - // } - //} - internal Dx11.VertexShader NativeVertexShader { - get - { - return this.vertexShader; - } + get; + private set; } internal Dx11.PixelShader NativePixelShader { - get - { - return this.pixelShader; - } - } - - internal Dx11.VertexShader VertexShader - { - get - { - return this.vertexShader; - } - } - - internal Dx11.PixelShader PixelShader - { - get - { - return this.pixelShader; - } + get; + private set; } public IEnumerable Techniques @@ -65,7 +35,6 @@ namespace ANX.RenderSystem.Windows.Metro get { throw new NotImplementedException(); - //for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++) //{ // EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10(this.managedEffect); @@ -83,7 +52,7 @@ namespace ANX.RenderSystem.Windows.Metro get { //TODO: implement - + System.Diagnostics.Debugger.Break(); return null; @@ -109,10 +78,10 @@ namespace ANX.RenderSystem.Windows.Metro this.managedEffect = managedEffect; byte[] vertexData = SeekIfPossibleAndReadBytes(vertexShaderByteCode); - vertexShader = new Dx11.VertexShader((Dx11.Device)device.NativeDevice, vertexData); + NativeVertexShader = new Dx11.VertexShader((Dx11.Device)device.NativeDevice, vertexData); byte[] pixelData = SeekIfPossibleAndReadBytes(pixelShaderByteCode); - pixelShader = new Dx11.PixelShader((Dx11.Device)device.NativeDevice, pixelData); + NativePixelShader = new Dx11.PixelShader((Dx11.Device)device.NativeDevice, pixelData); } public Effect_Metro(GraphicsDevice device, Effect managedEffect, Stream effectByteCode) @@ -161,16 +130,16 @@ namespace ANX.RenderSystem.Windows.Metro #region Dispose public void Dispose() { - if (pixelShader != null) + if (NativeVertexShader != null) { - pixelShader.Dispose(); - pixelShader = null; + NativeVertexShader.Dispose(); + NativeVertexShader = null; } - if (vertexShader != null) + if (NativePixelShader != null) { - vertexShader.Dispose(); - vertexShader = null; + NativePixelShader.Dispose(); + NativePixelShader = null; } } #endregion diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs index b3ab9043..d1ac7198 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs @@ -56,7 +56,9 @@ namespace ANX.RenderSystem.Windows.Metro ResizeRenderWindow(presentationParameters); - currentViewport = new Dx11.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); + currentViewport = new Dx11.Viewport(0, 0, + presentationParameters.BackBufferWidth, + presentationParameters.BackBufferHeight); } #endregion @@ -161,9 +163,12 @@ namespace ANX.RenderSystem.Windows.Metro #endregion // DrawPrimitives & DrawIndexedPrimitives #region DrawInstancedPrimitives - public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount) + public void DrawInstancedPrimitives(PrimitiveType primitiveType, + int baseVertex, int minVertexIndex, int numVertices, int startIndex, + int primitiveCount, int instanceCount) { - NativeDevice.NativeContext.DrawIndexedInstanced(numVertices, instanceCount, startIndex, baseVertex, 0); + NativeDevice.NativeContext.DrawIndexedInstanced(numVertices, + instanceCount, startIndex, baseVertex, 0); } #endregion // DrawInstancedPrimitives diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs index bca1d66f..31d63efb 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs @@ -80,11 +80,6 @@ namespace ANX.RenderSystem.Windows.Metro public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct { - GraphicsDeviceWindowsMetro metroGraphicsDevice = - graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - Dx11.Device1 device = metroGraphicsDevice.NativeDevice.NativeDevice; - Dx11.DeviceContext1 context = metroGraphicsDevice.NativeDevice.NativeContext; - //TODO: check offsetInBytes parameter for bounds etc. GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); @@ -102,8 +97,7 @@ namespace ANX.RenderSystem.Windows.Metro } SharpDX.DataStream stream; - SharpDX.DataBox box = context.MapSubresource(this.buffer, - Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream); + SharpDX.DataBox box = NativeDxDevice.Current.MapSubresource(buffer, out stream); if (startIndex > 0 || elementCount < data.Length) { for (int i = startIndex; i < startIndex + elementCount; i++) @@ -115,7 +109,7 @@ namespace ANX.RenderSystem.Windows.Metro { vData.CopyTo(stream); } - context.UnmapSubresource(this.buffer, 0); + NativeDxDevice.Current.UnmapSubresource(buffer, 0); } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeDxDevice.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeDxDevice.cs index 5c5719ff..2cb3af19 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeDxDevice.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeDxDevice.cs @@ -37,6 +37,20 @@ namespace ANX.RenderSystem.Windows.Metro return nativeContext; } } + + internal Dx11.OutputMergerStage OutputMerger + { + get + { + return nativeContext.OutputMerger; + } + } + + internal static NativeDxDevice Current + { + get; + private set; + } #endregion #region Public @@ -50,6 +64,8 @@ namespace ANX.RenderSystem.Windows.Metro #region Constructor public NativeDxDevice(PresentationParameters presentationParameters) { + Current = this; + this.presentationParameters = presentationParameters; swapChain = new SwapChainMetro(this, presentationParameters); @@ -102,9 +118,9 @@ namespace ANX.RenderSystem.Windows.Metro var viewport = new Dx11.Viewport((float)RenderTargetBounds.X, (float)RenderTargetBounds.Y, (float)RenderTargetBounds.Width, (float)RenderTargetBounds.Height, 0.0f, 1.0f); - NativeContext.Rasterizer.SetViewports(viewport); + nativeContext.Rasterizer.SetViewports(viewport); - NativeContext.OutputMerger.SetTargets(depthStencilView, renderTargetView); + nativeContext.OutputMerger.SetTargets(depthStencilView, renderTargetView); } #endregion @@ -114,7 +130,7 @@ namespace ANX.RenderSystem.Windows.Metro // TODO: find better solution to lazy init the swapChain from the coreWindow!! EnsureScreenBuffersAvailable(); - NativeContext.ClearDepthStencilView(depthStencilView, flags, depth, stencil); + nativeContext.ClearDepthStencilView(depthStencilView, flags, depth, stencil); } #endregion @@ -124,7 +140,7 @@ namespace ANX.RenderSystem.Windows.Metro // TODO: find better solution to lazy init the swapChain from the coreWindow!! EnsureScreenBuffersAvailable(); - NativeContext.ClearRenderTargetView(renderTargetView, color); + nativeContext.ClearRenderTargetView(renderTargetView, color); } #endregion @@ -145,6 +161,28 @@ namespace ANX.RenderSystem.Windows.Metro } #endregion + #region MapSubresource + public SharpDX.DataBox MapSubresource(Dx11.Buffer resource, + out SharpDX.DataStream stream) + { + return nativeContext.MapSubresource(resource, Dx11.MapMode.WriteDiscard, + Dx11.MapFlags.None, out stream); + } + + public SharpDX.DataBox MapSubresource(Dx11.Resource resource, int subresource) + { + return nativeContext.MapSubresource(resource, subresource, + Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None); + } + #endregion + + #region UnmapSubresource + public void UnmapSubresource(Dx11.Resource resource, int subresource) + { + nativeContext.UnmapSubresource(resource, subresource); + } + #endregion + #region Dispose public void Dispose() { diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs index 7d23e921..73a9b54f 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs @@ -97,14 +97,11 @@ namespace ANX.RenderSystem.Windows.Metro #region Apply public void Apply(GraphicsDevice graphicsDevice) { - GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - var device = gdMetro.NativeDevice.NativeDevice; - var context = gdMetro.NativeDevice.NativeContext; - - UpdateNativeRasterizerState(device); + UpdateNativeRasterizerState(); bound = true; - context.Rasterizer.State = nativeRasterizerState; + NativeDxDevice.Current.NativeContext.Rasterizer.State = + nativeRasterizerState; } #endregion @@ -120,7 +117,7 @@ namespace ANX.RenderSystem.Windows.Metro #endregion #region UpdateNativeRasterizerState - private void UpdateNativeRasterizerState(Dx11.Device1 device) + private void UpdateNativeRasterizerState() { if (isDirty == true || nativeRasterizerState == null) @@ -129,8 +126,8 @@ namespace ANX.RenderSystem.Windows.Metro try { - nativeRasterizerState = - new Dx11.RasterizerState1(device, description); + nativeRasterizerState = new Dx11.RasterizerState1( + NativeDxDevice.Current.NativeDevice, description); isDirty = false; } catch diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs index 9df921ee..8dc4ed92 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs @@ -99,10 +99,7 @@ namespace ANX.RenderSystem.Windows.Metro #region Apply (TODO) public void Apply(GraphicsDevice graphicsDevice, int index) { - var gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - Dx11.Device1 device = gdMetro.NativeDevice.NativeDevice; - - UpdateNativeSamplerState(device); + UpdateNativeSamplerState(); bound = true; throw new NotImplementedException(); @@ -122,7 +119,7 @@ namespace ANX.RenderSystem.Windows.Metro #endregion #region UpdateNativeSamplerState - private void UpdateNativeSamplerState(Dx11.Device1 device) + private void UpdateNativeSamplerState() { if (isDirty == true || nativeSamplerState == null) { @@ -132,8 +129,8 @@ namespace ANX.RenderSystem.Windows.Metro nativeSamplerState = null; } - nativeSamplerState = - new Dx11.SamplerState(device, ref description); + nativeSamplerState = new Dx11.SamplerState( + NativeDxDevice.Current.NativeDevice, ref description); isDirty = false; } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs index 76e1239f..ef60a63f 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs @@ -167,15 +167,11 @@ namespace ANX.RenderSystem.Windows.Metro //TODO: handle offsetInBytes parameter //TODO: handle startIndex parameter //TODO: handle elementCount parameter - - var metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - Dx11.Device1 device = metroGraphicsDevice.NativeDevice.NativeDevice; - Dx11.DeviceContext1 context = metroGraphicsDevice.NativeDevice.NativeContext; - + if (this.surfaceFormat == SurfaceFormat.Color) { int subresource = Dx11.Texture2D.CalculateSubResourceIndex(0, 0, 1); - SharpDX.DataBox rectangle = context.MapSubresource(this.nativeTexture, subresource, Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None); + SharpDX.DataBox rectangle = NativeDxDevice.Current.MapSubresource(nativeTexture, subresource); int rowPitch = rectangle.RowPitch; unsafe @@ -203,7 +199,7 @@ namespace ANX.RenderSystem.Windows.Metro handle.Free(); } - context.UnmapSubresource(this.nativeTexture, subresource); + NativeDxDevice.Current.UnmapSubresource(nativeTexture, subresource); } else if (surfaceFormat == SurfaceFormat.Dxt5 || surfaceFormat == SurfaceFormat.Dxt3 || surfaceFormat == SurfaceFormat.Dxt1) { diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs index 0f6833ec..10b6bd13 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs @@ -74,10 +74,6 @@ namespace ANX.RenderSystem.Windows.Metro public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct { - GraphicsDeviceWindowsMetro gdMetro = - graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; - Dx11.DeviceContext1 context = gdMetro.NativeDevice.NativeContext; - //TODO: check offsetInBytes parameter for bounds etc. GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); @@ -95,8 +91,7 @@ namespace ANX.RenderSystem.Windows.Metro } SharpDX.DataStream stream; - SharpDX.DataBox box = context.MapSubresource(buffer, - Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream); + SharpDX.DataBox box = NativeDxDevice.Current.MapSubresource(buffer, out stream); if (startIndex > 0 || elementCount < data.Length) { for (int i = startIndex; i < startIndex + elementCount; i++) @@ -108,7 +103,7 @@ namespace ANX.RenderSystem.Windows.Metro { vData.CopyTo(stream); } - context.UnmapSubresource(buffer, 0); + NativeDxDevice.Current.UnmapSubresource(buffer, 0); } }