From 7b1c3d402c6b70dc1fe33217549659bc70776ead Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Tue, 21 Feb 2012 07:52:20 +0000 Subject: [PATCH] - added the RenderSystem.Windows.Metro with a bunch of new files (NOT WORKING currently) - changed many things in ANX.Framework core assembly to make it compile using VS2011 and .NET 4.5 for Win8 (not finished yet) --- ANX.Framework/ANX.Framework.csproj | 3 +- .../Audio/InstancePlayLimitException.cs | 11 +- .../Audio/NoAudioHardwareException.cs | 6 +- ANX.Framework/Content/ContentLoadException.cs | 6 +- ANX.Framework/Content/LzxDecoder.cs | 4 +- ANX.Framework/Content/ReflectiveReader.cs | 4 + ANX.Framework/Design/ANXFieldDescriptor.cs | 58 +++- ANX.Framework/Design/ANXPropertyDescriptor.cs | 58 +++- ANX.Framework/Design/BoundingBoxConverter.cs | 58 +++- .../Design/BoundingSphereConverter.cs | 58 +++- ANX.Framework/Design/ColorConverter.cs | 58 +++- ANX.Framework/Design/MathTypeConverter.cs | 62 +++- ANX.Framework/Design/MatrixConverter.cs | 58 +++- ANX.Framework/Design/PlaneConverter.cs | 58 +++- ANX.Framework/Design/PointConverter.cs | 58 +++- ANX.Framework/Design/QuaternionConverter.cs | 58 +++- ANX.Framework/Design/RayConverter.cs | 58 +++- ANX.Framework/Design/RectangleConverter.cs | 58 +++- ANX.Framework/Design/Vector2Converter.cs | 58 +++- ANX.Framework/Design/Vector3Converter.cs | 58 +++- ANX.Framework/Design/Vector4Converter.cs | 58 +++- .../GameUpdateRequiredException.cs | 2 + .../GamerServices/GamerPrivilegeException.cs | 2 + .../GamerServicesNotAvailableException.cs | 2 + .../GuideAlreadyVisibleException.cs | 2 + .../GamerServices/NetworkException.cs | 2 + .../NetworkNotAvailableException.cs | 2 + ANX.Framework/GraphicsDeviceManager.cs | 5 +- ANX.Framework/Input/MouseState.cs | 2 + ANX.Framework/Net/AvailableNetworkSession.cs | 4 + ANX.Framework/Net/NetworkException.cs | 2 + .../Net/NetworkSessionJoinException.cs | 4 +- ANX.Framework/NonXNA/AddIn.cs | 48 +-- ANX.Framework/NonXNA/AddInLoadingException.cs | 2 + ANX.Framework/NonXNA/AddInSystemFactory.cs | 260 +++++++++------- ANX.Framework/NonXNA/IServiceProvider.cs | 62 ++++ .../NonXNA/NoInputDeviceException.cs | 2 + ANX.Framework/Storage/StorageContainer.cs | 3 + ANX.Framework/Storage/StorageDevice.cs | 3 + .../StorageDeviceNotConnectedException.cs | 2 + ANX.RenderSystem.Windows.Metro.sln | 40 +++ .../ANX.RenderSystem.Windows.Metro.csproj | 37 ++- .../ANX.RenderSystem.Windows.Metro.sln | 20 -- .../BlendState_Metro.cs | 117 ++++--- .../ANX.RenderSystem.Windows.Metro/Creator.cs | 35 +-- .../DepthStencilState_Metro.cs | 59 ++-- .../EffectParameter_Metro.cs | 289 ++++++++++-------- .../EffectPass_Metro.cs | 33 +- .../EffectTechnique_Metro.cs | 67 ++-- .../Effect_Metro.cs | 90 ++++-- .../FormatConverter.cs | 46 +-- .../GraphicsDeviceWindowsMetro.cs | 264 ++++++++++------ .../IndexBuffer_Metro.cs | 77 +++-- .../Metadata.Designer.cs | 72 ----- .../Metadata.resx | 123 -------- .../NativeMethods.cs | 58 +--- .../Properties/AssemblyInfo.cs | 6 +- .../RasterizerState_Metro.cs | 31 +- .../RenderTarget2D_Metro.cs | 26 +- .../SamplerState_Metro.cs | 32 +- .../ShaderByteCode.cs | 2 +- .../Texture2D_Metro.cs | 58 ++-- .../VertexBuffer_Metro.cs | 63 ++-- .../WindowsGameHost.cs | 134 +++++--- .../WindowsGameWindow.cs | 67 ++-- Samples/MultiRenderTarget/Game1.cs | 12 +- .../MultiRenderTarget.csproj | 30 +- Samples/SampleContent/Effects/MRT.fx | 14 +- .../SampleContent/SampleContent.contentproj | 3 +- 69 files changed, 2134 insertions(+), 1090 deletions(-) create mode 100644 ANX.Framework/NonXNA/IServiceProvider.cs create mode 100644 ANX.RenderSystem.Windows.Metro.sln delete mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.sln delete mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs delete mode 100644 RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx diff --git a/ANX.Framework/ANX.Framework.csproj b/ANX.Framework/ANX.Framework.csproj index f44011db..84795acc 100644 --- a/ANX.Framework/ANX.Framework.csproj +++ b/ANX.Framework/ANX.Framework.csproj @@ -1,7 +1,6 @@  - 8.0.30703 2.0 @@ -9,7 +8,6 @@ ANX.Framework ANX.Framework - False @@ -402,6 +400,7 @@ + diff --git a/ANX.Framework/Audio/InstancePlayLimitException.cs b/ANX.Framework/Audio/InstancePlayLimitException.cs index 7124b356..a1b1078b 100644 --- a/ANX.Framework/Audio/InstancePlayLimitException.cs +++ b/ANX.Framework/Audio/InstancePlayLimitException.cs @@ -1,6 +1,9 @@ -using System; +#region Using Statements +using System; using System.Runtime.InteropServices; +#endregion // Using Statements + #region License // @@ -50,8 +53,10 @@ using System.Runtime.InteropServices; namespace ANX.Framework.Audio { - [SerializableAttribute] - public sealed class InstancePlayLimitException : ExternalException +#if !WIN8 //TODO: search replacement for Win8 + [SerializableAttribute] +#endif + public sealed class InstancePlayLimitException : ExternalException { #region Constructor public InstancePlayLimitException() diff --git a/ANX.Framework/Audio/NoAudioHardwareException.cs b/ANX.Framework/Audio/NoAudioHardwareException.cs index 3733fd8d..229e05ee 100644 --- a/ANX.Framework/Audio/NoAudioHardwareException.cs +++ b/ANX.Framework/Audio/NoAudioHardwareException.cs @@ -50,8 +50,10 @@ using System.Runtime.InteropServices; namespace ANX.Framework.Audio { - [SerializableAttribute] - public sealed class NoAudioHardwareException : ExternalException +#if !WIN8 //TODO: search replacement for Win8 + [SerializableAttribute] +#endif + public sealed class NoAudioHardwareException : ExternalException { public NoAudioHardwareException() : base() diff --git a/ANX.Framework/Content/ContentLoadException.cs b/ANX.Framework/Content/ContentLoadException.cs index 1bff5e5b..5612b791 100644 --- a/ANX.Framework/Content/ContentLoadException.cs +++ b/ANX.Framework/Content/ContentLoadException.cs @@ -54,7 +54,9 @@ using System.Runtime.Serialization; namespace ANX.Framework.Content { - [Serializable] +#if !WIN8 //TODO: search replacement for Win8 + [SerializableAttribute] +#endif public class ContentLoadException : Exception { /// @@ -79,6 +81,7 @@ namespace ANX.Framework.Content { } +#if !WIN8 //TODO: search replacement for Win8 /// /// Creates a new ContentLoadException. /// @@ -86,5 +89,6 @@ namespace ANX.Framework.Content : base(info, context) { } +#endif } } diff --git a/ANX.Framework/Content/LzxDecoder.cs b/ANX.Framework/Content/LzxDecoder.cs index 5bd47acb..9e8d9b2e 100644 --- a/ANX.Framework/Content/LzxDecoder.cs +++ b/ANX.Framework/Content/LzxDecoder.cs @@ -220,7 +220,7 @@ namespace ANX.Framework.Content * remaining - in this boundary case they aren't really part of * the compressed data) */ - Console.WriteLine("WTF"); + //TODO Console.WriteLine("WTF"); // does not work under Win8 if (inData.Position > (startpos + inLen + 2) || bitbuf.GetBitsLeft() < 16) return -1; //TODO throw proper exception } @@ -445,7 +445,7 @@ namespace ANX.Framework.Content if ((inData.Position + this_run) > endpos) return -1; //TODO throw proper exception byte[] temp_buffer = new byte[this_run]; inData.Read(temp_buffer, 0, this_run); - temp_buffer.CopyTo(window, window_posn); + temp_buffer.CopyTo(window, (int)window_posn); window_posn += (uint)this_run; break; diff --git a/ANX.Framework/Content/ReflectiveReader.cs b/ANX.Framework/Content/ReflectiveReader.cs index 1c399d54..e598938e 100644 --- a/ANX.Framework/Content/ReflectiveReader.cs +++ b/ANX.Framework/Content/ReflectiveReader.cs @@ -52,6 +52,8 @@ using System.Reflection; namespace ANX.Framework.Content { +#if !WIN8 + public class ReflectiveReader : ContentTypeReader { private int typeVersion; @@ -114,4 +116,6 @@ namespace ANX.Framework.Content return existingInstance; } } + +#endif } diff --git a/ANX.Framework/Design/ANXFieldDescriptor.cs b/ANX.Framework/Design/ANXFieldDescriptor.cs index 646c5c67..48b52179 100644 --- a/ANX.Framework/Design/ANXFieldDescriptor.cs +++ b/ANX.Framework/Design/ANXFieldDescriptor.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 + public class ANXFieldDescriptor : PropertyDescriptor { private FieldInfo field; @@ -63,4 +117,6 @@ namespace ANX.Framework.Design return true; } } + +#endif } diff --git a/ANX.Framework/Design/ANXPropertyDescriptor.cs b/ANX.Framework/Design/ANXPropertyDescriptor.cs index 7536e520..75fc4a3d 100644 --- a/ANX.Framework/Design/ANXPropertyDescriptor.cs +++ b/ANX.Framework/Design/ANXPropertyDescriptor.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 + public class ANXPropertyDescriptor : PropertyDescriptor { private PropertyInfo property; @@ -63,4 +117,6 @@ namespace ANX.Framework.Design return true; } } + +#endif } diff --git a/ANX.Framework/Design/BoundingBoxConverter.cs b/ANX.Framework/Design/BoundingBoxConverter.cs index bfcd5239..8056fd37 100644 --- a/ANX.Framework/Design/BoundingBoxConverter.cs +++ b/ANX.Framework/Design/BoundingBoxConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class BoundingBoxConverter : MathTypeConverter { public BoundingBoxConverter() @@ -50,4 +104,6 @@ namespace ANX.Framework.Design return new BoundingBox((Vector3)propertyValues["Min"], (Vector3)propertyValues["Max"]); } } + +#endif } diff --git a/ANX.Framework/Design/BoundingSphereConverter.cs b/ANX.Framework/Design/BoundingSphereConverter.cs index e9a8073a..7e39c752 100644 --- a/ANX.Framework/Design/BoundingSphereConverter.cs +++ b/ANX.Framework/Design/BoundingSphereConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class BoundingSphereConverter : MathTypeConverter { public BoundingSphereConverter() @@ -50,4 +104,6 @@ namespace ANX.Framework.Design return new BoundingSphere((Vector3)propertyValues["Center"], (float)propertyValues["Radius"]); } } + +#endif } diff --git a/ANX.Framework/Design/ColorConverter.cs b/ANX.Framework/Design/ColorConverter.cs index 030f6877..826614d1 100644 --- a/ANX.Framework/Design/ColorConverter.cs +++ b/ANX.Framework/Design/ColorConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class ColorConverter : MathTypeConverter { public ColorConverter() @@ -58,4 +112,6 @@ namespace ANX.Framework.Design return new Color((float)propertyValues["R"], (float)propertyValues["G"], (float)propertyValues["B"], (float)propertyValues["A"]); } } + +#endif } diff --git a/ANX.Framework/Design/MathTypeConverter.cs b/ANX.Framework/Design/MathTypeConverter.cs index 30c59967..b19f7b0d 100644 --- a/ANX.Framework/Design/MathTypeConverter.cs +++ b/ANX.Framework/Design/MathTypeConverter.cs @@ -1,12 +1,68 @@ -using System; -using System.Text; +#region Using Statements +using System; +using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; +using System.Reflection; +using System.Text; + +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class MathTypeConverter : ExpandableObjectConverter { protected PropertyDescriptorCollection propertyDescriptions; @@ -106,4 +162,6 @@ namespace ANX.Framework.Design return result; } } + +#endif } diff --git a/ANX.Framework/Design/MatrixConverter.cs b/ANX.Framework/Design/MatrixConverter.cs index e863a239..e659709e 100644 --- a/ANX.Framework/Design/MatrixConverter.cs +++ b/ANX.Framework/Design/MatrixConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class MatrixConverter : MathTypeConverter { public MatrixConverter() @@ -63,4 +117,6 @@ namespace ANX.Framework.Design (float)propertyValues["M41"], (float)propertyValues["M42"], (float)propertyValues["M43"], (float)propertyValues["M44"]); } } + +#endif } diff --git a/ANX.Framework/Design/PlaneConverter.cs b/ANX.Framework/Design/PlaneConverter.cs index 43aa68e1..4f2a0ab6 100644 --- a/ANX.Framework/Design/PlaneConverter.cs +++ b/ANX.Framework/Design/PlaneConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class PlaneConverter : MathTypeConverter { public PlaneConverter() @@ -45,4 +99,6 @@ namespace ANX.Framework.Design return new Vector4((Vector3)propertyValues["Normal"], (float)propertyValues["D"]); } } + +#endif } diff --git a/ANX.Framework/Design/PointConverter.cs b/ANX.Framework/Design/PointConverter.cs index 221ebef5..9b9decf6 100644 --- a/ANX.Framework/Design/PointConverter.cs +++ b/ANX.Framework/Design/PointConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class PointConverter : MathTypeConverter { public PointConverter() @@ -58,4 +112,6 @@ namespace ANX.Framework.Design return new Point((int)propertyValues["X"], (int)propertyValues["Y"]); } } + +#endif } diff --git a/ANX.Framework/Design/QuaternionConverter.cs b/ANX.Framework/Design/QuaternionConverter.cs index 3e5b969b..a5761ff1 100644 --- a/ANX.Framework/Design/QuaternionConverter.cs +++ b/ANX.Framework/Design/QuaternionConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class QuaternionConverter : MathTypeConverter { public QuaternionConverter() @@ -58,4 +112,6 @@ namespace ANX.Framework.Design return new Quaternion((float)propertyValues["X"], (float)propertyValues["Y"], (float)propertyValues["Z"], (float)propertyValues["W"]); } } + +#endif } diff --git a/ANX.Framework/Design/RayConverter.cs b/ANX.Framework/Design/RayConverter.cs index c7a66b1a..827e0949 100644 --- a/ANX.Framework/Design/RayConverter.cs +++ b/ANX.Framework/Design/RayConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class RayConverter : MathTypeConverter { public RayConverter() @@ -50,4 +104,6 @@ namespace ANX.Framework.Design return new Ray((Vector3)propertyValues["Position"], (Vector3)propertyValues["Direction"]); } } + +#endif } diff --git a/ANX.Framework/Design/RectangleConverter.cs b/ANX.Framework/Design/RectangleConverter.cs index d58f217f..b2b25e50 100644 --- a/ANX.Framework/Design/RectangleConverter.cs +++ b/ANX.Framework/Design/RectangleConverter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class RectangleConverter : MathTypeConverter { public RectangleConverter() @@ -45,4 +99,6 @@ namespace ANX.Framework.Design return new Rectangle((int)propertyValues["X"], (int)propertyValues["Y"], (int)propertyValues["Width"], (int)propertyValues["Height"]); } } + +#endif } diff --git a/ANX.Framework/Design/Vector2Converter.cs b/ANX.Framework/Design/Vector2Converter.cs index f8906b82..8c2501c2 100644 --- a/ANX.Framework/Design/Vector2Converter.cs +++ b/ANX.Framework/Design/Vector2Converter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class Vector2Converter : MathTypeConverter { public Vector2Converter() @@ -58,4 +112,6 @@ namespace ANX.Framework.Design return new Vector2((float)propertyValues["X"], (float)propertyValues["Y"]); } } + +#endif } diff --git a/ANX.Framework/Design/Vector3Converter.cs b/ANX.Framework/Design/Vector3Converter.cs index d3be53a2..fa7abf0c 100644 --- a/ANX.Framework/Design/Vector3Converter.cs +++ b/ANX.Framework/Design/Vector3Converter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class Vector3Converter : MathTypeConverter { public Vector3Converter() @@ -58,4 +112,6 @@ namespace ANX.Framework.Design return new Vector3((float)propertyValues["X"], (float)propertyValues["Y"], (float)propertyValues["Z"]); } } + +#endif } diff --git a/ANX.Framework/Design/Vector4Converter.cs b/ANX.Framework/Design/Vector4Converter.cs index 53a5fb6f..af08a7af 100644 --- a/ANX.Framework/Design/Vector4Converter.cs +++ b/ANX.Framework/Design/Vector4Converter.cs @@ -1,13 +1,67 @@ -using System; +#region Using Statements +using System; using System.Collections; using System.ComponentModel; +#if !WIN8 using System.ComponentModel.Design.Serialization; +#endif using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; +#endregion // Using Statements + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + namespace ANX.Framework.Design { +#if !WIN8 //TODO: search replacement for Win8 + public class Vector4Converter : MathTypeConverter { public Vector4Converter() @@ -58,4 +112,6 @@ namespace ANX.Framework.Design return new Vector4((float)propertyValues["X"], (float)propertyValues["Y"], (float)propertyValues["Z"], (float)propertyValues["W"]); } } + +#endif } diff --git a/ANX.Framework/GamerServices/GameUpdateRequiredException.cs b/ANX.Framework/GamerServices/GameUpdateRequiredException.cs index f509fe0c..d04644c0 100644 --- a/ANX.Framework/GamerServices/GameUpdateRequiredException.cs +++ b/ANX.Framework/GamerServices/GameUpdateRequiredException.cs @@ -60,10 +60,12 @@ namespace ANX.Framework.GamerServices { } +#if !WIN8 //TODO: search replacement for Win8 protected GameUpdateRequiredException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public GameUpdateRequiredException(string message) : base(message) diff --git a/ANX.Framework/GamerServices/GamerPrivilegeException.cs b/ANX.Framework/GamerServices/GamerPrivilegeException.cs index f189e21c..c36c319d 100644 --- a/ANX.Framework/GamerServices/GamerPrivilegeException.cs +++ b/ANX.Framework/GamerServices/GamerPrivilegeException.cs @@ -60,10 +60,12 @@ namespace ANX.Framework.GamerServices { } +#if !WIN8 //TODO: search replacement for Win8 protected GamerPrivilegeException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public GamerPrivilegeException(string message) : base(message) diff --git a/ANX.Framework/GamerServices/GamerServicesNotAvailableException.cs b/ANX.Framework/GamerServices/GamerServicesNotAvailableException.cs index c01ce862..1d585cab 100644 --- a/ANX.Framework/GamerServices/GamerServicesNotAvailableException.cs +++ b/ANX.Framework/GamerServices/GamerServicesNotAvailableException.cs @@ -60,10 +60,12 @@ namespace ANX.Framework.GamerServices { } +#if !WIN8 //TODO: search replacement for Win8 protected GamerServicesNotAvailableException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public GamerServicesNotAvailableException(string message) : base(message) diff --git a/ANX.Framework/GamerServices/GuideAlreadyVisibleException.cs b/ANX.Framework/GamerServices/GuideAlreadyVisibleException.cs index a272f08a..25a2fd32 100644 --- a/ANX.Framework/GamerServices/GuideAlreadyVisibleException.cs +++ b/ANX.Framework/GamerServices/GuideAlreadyVisibleException.cs @@ -60,10 +60,12 @@ namespace ANX.Framework.GamerServices { } +#if !WIN8 //TODO: search replacement for Win8 protected GuideAlreadyVisibleException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public GuideAlreadyVisibleException(string message) : base(message) diff --git a/ANX.Framework/GamerServices/NetworkException.cs b/ANX.Framework/GamerServices/NetworkException.cs index ec9e876b..bace2630 100644 --- a/ANX.Framework/GamerServices/NetworkException.cs +++ b/ANX.Framework/GamerServices/NetworkException.cs @@ -60,10 +60,12 @@ namespace ANX.Framework.GamerServices { } +#if !WIN8 //TODO: search replacement for Win8 protected NetworkException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public NetworkException(string message) : base(message) diff --git a/ANX.Framework/GamerServices/NetworkNotAvailableException.cs b/ANX.Framework/GamerServices/NetworkNotAvailableException.cs index 329f43f5..14dafff7 100644 --- a/ANX.Framework/GamerServices/NetworkNotAvailableException.cs +++ b/ANX.Framework/GamerServices/NetworkNotAvailableException.cs @@ -60,10 +60,12 @@ namespace ANX.Framework.GamerServices { } +#if !WIN8 //TODO: search replacement for Win8 protected NetworkNotAvailableException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public NetworkNotAvailableException(string message) : base(message) diff --git a/ANX.Framework/GraphicsDeviceManager.cs b/ANX.Framework/GraphicsDeviceManager.cs index 74a5519e..774c5d1a 100644 --- a/ANX.Framework/GraphicsDeviceManager.cs +++ b/ANX.Framework/GraphicsDeviceManager.cs @@ -407,8 +407,11 @@ namespace ANX.Framework private GraphicsProfile FetchGraphicsProfile() { +#if !WIN8 Stream manifestResourceStream = this.game.GetType().Assembly.GetManifestResourceStream("Microsoft.Xna.Framework.RuntimeProfile"); - +#else + Stream manifestResourceStream = this.game.GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Microsoft.Xna.Framework.RuntimeProfile"); +#endif if (manifestResourceStream != null) { using (StreamReader reader = new StreamReader(manifestResourceStream)) diff --git a/ANX.Framework/Input/MouseState.cs b/ANX.Framework/Input/MouseState.cs index 8bcf7454..755b73c4 100644 --- a/ANX.Framework/Input/MouseState.cs +++ b/ANX.Framework/Input/MouseState.cs @@ -52,7 +52,9 @@ using System; namespace ANX.Framework.Input { +#if !WIN8 //TODO: search replacement for Win8 [SerializableAttribute] +#endif public struct MouseState { private int x; diff --git a/ANX.Framework/Net/AvailableNetworkSession.cs b/ANX.Framework/Net/AvailableNetworkSession.cs index 6093870e..40f88b08 100644 --- a/ANX.Framework/Net/AvailableNetworkSession.cs +++ b/ANX.Framework/Net/AvailableNetworkSession.cs @@ -56,8 +56,10 @@ namespace ANX.Framework.Net private int openPublicGamerSlots; private QualityOfService qualityOfService; private NetworkSessionProperties sessionProperties; +#if !WIN8 //TODO: search replacement for Win8 private IPEndPoint endPoint; private IPEndPoint internalendPoint; +#endif private int _currentGameCount; private string hostGamertag; private int openPrivateGamerSlots; @@ -139,6 +141,7 @@ namespace ANX.Framework.Net } } +#if !WIN8 //TODO: search replacement for Win8 internal IPEndPoint EndPoint { get @@ -162,6 +165,7 @@ namespace ANX.Framework.Net internalendPoint = value; } } +#endif internal NetworkSessionType SessionType { diff --git a/ANX.Framework/Net/NetworkException.cs b/ANX.Framework/Net/NetworkException.cs index 29c685ef..514f3f30 100644 --- a/ANX.Framework/Net/NetworkException.cs +++ b/ANX.Framework/Net/NetworkException.cs @@ -66,10 +66,12 @@ namespace ANX.Framework.Net { } +#if !WIN8 //TODO: search replacement for Win8 protected NetworkException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif } } diff --git a/ANX.Framework/Net/NetworkSessionJoinException.cs b/ANX.Framework/Net/NetworkSessionJoinException.cs index 716c2a27..a146d829 100644 --- a/ANX.Framework/Net/NetworkSessionJoinException.cs +++ b/ANX.Framework/Net/NetworkSessionJoinException.cs @@ -80,6 +80,7 @@ namespace ANX.Framework.Net { } +#if !WIN8 //TODO: search replacement for Win8 protected NetworkSessionJoinException(SerializationInfo info, StreamingContext context) : base(info, context) @@ -93,5 +94,6 @@ namespace ANX.Framework.Net base.GetObjectData(info, context); info.AddValue("joinError", (int)JoinError); } - } +#endif + } } diff --git a/ANX.Framework/NonXNA/AddIn.cs b/ANX.Framework/NonXNA/AddIn.cs index 0e406f27..c45fd3f3 100644 --- a/ANX.Framework/NonXNA/AddIn.cs +++ b/ANX.Framework/NonXNA/AddIn.cs @@ -108,10 +108,10 @@ namespace ANX.Framework.NonXNA } foreach (Type t in allTypes.Where(p => - typeof(IInputSystemCreator).IsAssignableFrom(p) || - typeof(IRenderSystemCreator).IsAssignableFrom(p) || - typeof(ISoundSystemCreator).IsAssignableFrom(p) || - typeof(IMediaSystemCreator).IsAssignableFrom(p))) + IsAssignable(typeof(IInputSystemCreator), p) || + IsAssignable(typeof(IRenderSystemCreator), p) || + IsAssignable(typeof(ISoundSystemCreator), p) || + IsAssignable(typeof(IMediaSystemCreator), p))) { this.creatorType = t; this.addInType = AddInSystemFactory.GetAddInType(t); @@ -131,27 +131,23 @@ namespace ANX.Framework.NonXNA // Scan the addin for InputDeviceCreators and register them // - foreach (Type t in allTypes.Where(p => - typeof(IGamePadCreator).IsAssignableFrom(p))) + foreach (Type t in allTypes.Where(p => IsAssignable(typeof(IGamePadCreator), p))) { InputDeviceFactory.Instance.AddCreator(Activator.CreateInstance(t) as IGamePadCreator); } - foreach (Type t in allTypes.Where(p => - typeof(IKeyboardCreator).IsAssignableFrom(p))) + foreach (Type t in allTypes.Where(p => IsAssignable(typeof(IKeyboardCreator), p))) { InputDeviceFactory.Instance.AddCreator(Activator.CreateInstance(t) as IKeyboardCreator); } - foreach (Type t in allTypes.Where(p => - typeof(IMouseCreator).IsAssignableFrom(p))) + foreach (Type t in allTypes.Where(p => IsAssignable(typeof(IMouseCreator), p))) { InputDeviceFactory.Instance.AddCreator(Activator.CreateInstance(t) as IMouseCreator); } #if XNAEXT - foreach (Type t in allTypes.Where(p => - typeof(IMotionSensingDeviceCreator).IsAssignableFrom(p))) + foreach (Type t in allTypes.Where(p => IsAssignable(typeof(IMotionSensingDeviceCreator), p))) { InputDeviceFactory.Instance.AddCreator(Activator.CreateInstance(t) as IMotionSensingDeviceCreator); } @@ -201,7 +197,11 @@ namespace ANX.Framework.NonXNA { foreach (string platform in this.platforms) { - if (string.Equals(Environment.OSVersion.Platform.ToString(), platform, StringComparison.InvariantCultureIgnoreCase)) +#if !WIN8 + if (string.Equals(Environment.OSVersion.Platform.ToString(), platform, StringComparison.OrdinalIgnoreCase)) +#else + if (string.Equals("Win8", platform, StringComparison.OrdinalIgnoreCase)) +#endif { return true; } @@ -290,8 +290,8 @@ namespace ANX.Framework.NonXNA #region Private Helpers - #region FetchSupportedPlattforms - private string[] FetchSupportedPlattforms(Assembly assembly) + #region FetchSupportedPlattforms + private string[] FetchSupportedPlattforms(Assembly assembly) { string[] platforms = null; string[] res = assembly.GetManifestResourceNames(); @@ -309,7 +309,7 @@ namespace ANX.Framework.NonXNA IDictionaryEnumerator dict = resourceReader.GetEnumerator(); while (dict.MoveNext()) { - if (string.Equals(dict.Key.ToString(), "SupportedPlatforms", StringComparison.InvariantCultureIgnoreCase) && + if (string.Equals(dict.Key.ToString(), "SupportedPlatforms", StringComparison.OrdinalIgnoreCase) && dict.Value.GetType() == typeof(string)) { platforms = dict.Value.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); @@ -324,13 +324,23 @@ namespace ANX.Framework.NonXNA return platforms; } - #endregion + #endregion - #endregion // Private Helpers + #endregion // Private Helpers - public int CompareTo(AddIn other) + public int CompareTo(AddIn other) { return this.Priority.CompareTo(other.Priority); } + + private static bool IsAssignable(System.Type lt, System.Type rt) + { +#if WIN8 + return lt.GetTypeInfo().IsAssignableFrom(rt.GetTypeInfo()); +#else + return lt.IsAssignableFrom(rt); +#endif + } + } } diff --git a/ANX.Framework/NonXNA/AddInLoadingException.cs b/ANX.Framework/NonXNA/AddInLoadingException.cs index a814a44a..fa2b7e6c 100644 --- a/ANX.Framework/NonXNA/AddInLoadingException.cs +++ b/ANX.Framework/NonXNA/AddInLoadingException.cs @@ -59,10 +59,12 @@ namespace ANX.Framework.NonXNA { } +#if !WIN8 //TODO: search replacement for Win8 protected AddInLoadingException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public AddInLoadingException(string message) : base(message) diff --git a/ANX.Framework/NonXNA/AddInSystemFactory.cs b/ANX.Framework/NonXNA/AddInSystemFactory.cs index 23363f29..ea102085 100644 --- a/ANX.Framework/NonXNA/AddInSystemFactory.cs +++ b/ANX.Framework/NonXNA/AddInSystemFactory.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; using NLog; +using System.Runtime.InteropServices; #endregion // Using Statements @@ -64,17 +65,20 @@ namespace ANX.Framework.NonXNA private static AddInSystemFactory instance; private bool initialized; private Dictionary defaultCreators = new Dictionary(); +#if !WIN8 private OperatingSystem operatingSystem; +#else + private String operatingSystem; +#endif private Version operatingSystemVersion; - - private Dictionary addinSystems; + private Dictionary addinSystems; private static Logger logger = LogManager.GetCurrentClassLogger(); #endregion // Private Members - #region Public - public static AddInSystemFactory Instance + #region Public + public static AddInSystemFactory Instance { get { @@ -86,44 +90,60 @@ namespace ANX.Framework.NonXNA return instance; } - } + } - public OperatingSystem OperatingSystem - { - get - { - return this.operatingSystem; - } - } +#if !WIN8 + public OperatingSystem OperatingSystem + { + get + { + return this.operatingSystem; + } + } +#else + public String OperatingSystem + { + get + { + return this.operatingSystem; + } + } +#endif + public Version OperatingSystemVersion + { + get + { + return this.operatingSystemVersion; + } + } - public Version OperatingSystemVersion - { - get - { - return this.operatingSystemVersion; - } - } - #endregion + #endregion - #region Constructor - private AddInSystemFactory() + #region Constructor + private AddInSystemFactory() { - addinSystems = new Dictionary(); - addinSystems.Add(AddInType.InputSystem, new AddInSystemInfo()); - addinSystems.Add(AddInType.MediaSystem, new AddInSystemInfo()); - addinSystems.Add(AddInType.RenderSystem, new AddInSystemInfo()); - addinSystems.Add(AddInType.SoundSystem, new AddInSystemInfo()); + addinSystems = new Dictionary(); + addinSystems.Add(AddInType.InputSystem, new AddInSystemInfo()); + addinSystems.Add(AddInType.MediaSystem, new AddInSystemInfo()); + addinSystems.Add(AddInType.RenderSystem, new AddInSystemInfo()); + addinSystems.Add(AddInType.SoundSystem, new AddInSystemInfo()); this.creators = new Dictionary(); +#if !WIN8 this.operatingSystem = Environment.OSVersion; this.operatingSystemVersion = this.operatingSystem.Version; logger.Info("Operating System: {0} ({1})", operatingSystem.VersionString, operatingSystemVersion.ToString()); +#else + this.operatingSystem = "Win8"; + this.operatingSystemVersion = new Version(RuntimeEnvironment.GetSystemVersion()); + logger.Info("Operating System: {0} ({1})", "Win8", operatingSystemVersion.ToString()); +#endif } - #endregion + #endregion - #region Initialize - public void Initialize() + #region Initialize + public void Initialize() { if (initialized == false) { @@ -155,10 +175,10 @@ namespace ANX.Framework.NonXNA SortAddIns(); } } - #endregion + #endregion - #region AddCreator - public void AddCreator(ICreator creator) + #region AddCreator + public void AddCreator(ICreator creator) { string creatorName = creator.Name.ToLowerInvariant(); @@ -171,17 +191,17 @@ namespace ANX.Framework.NonXNA logger.Debug("added creator '{0}'. Total count of registered creators is now {1}.", creatorName, creators.Count); } - #endregion + #endregion - #region HasFramework - public bool HasFramework(String name) + #region HasFramework + public bool HasFramework(String name) { return creators.ContainsKey(name.ToLowerInvariant()); - } - #endregion + } + #endregion - #region GetCreator - public T GetCreator(String name) where T : class, ICreator + #region GetCreator + public T GetCreator(String name) where T : class, ICreator { if (!initialized) { @@ -191,11 +211,11 @@ namespace ANX.Framework.NonXNA ICreator creator = null; creators.TryGetValue(name.ToLowerInvariant(), out creator); return creator as T; - } - #endregion + } + #endregion - #region GetCreators - public IEnumerable GetCreators() where T : class, ICreator + #region GetCreators + public IEnumerable GetCreators() where T : class, ICreator { if (!initialized) { @@ -205,15 +225,19 @@ namespace ANX.Framework.NonXNA Type t = typeof(T); foreach (ICreator creator in this.creators.Values.Where(p => - p.GetType().GetInterfaces()[0].Equals(t))) +#if WIN8 + p.GetType().GetTypeInfo().ImplementedInterfaces.First().Equals(t))) +#else + p.GetType().GetInterfaces()[0].Equals(t))) +#endif { yield return creator as T; } } - #endregion + #endregion - #region GetDefaultCreator - public T GetDefaultCreator() where T : class, ICreator + #region GetDefaultCreator + public T GetDefaultCreator() where T : class, ICreator { if (initialized == false) { @@ -223,102 +247,110 @@ namespace ANX.Framework.NonXNA Type type = typeof(T); AddInType addInType = GetAddInType(type); - AddInSystemInfo info = addinSystems[addInType]; - if (String.IsNullOrEmpty(info.PreferredName)) - { - if (info.AvailableSystems.Count > 0) - { - return info.AvailableSystems[0].Instance as T; - } + AddInSystemInfo info = addinSystems[addInType]; + if (String.IsNullOrEmpty(info.PreferredName)) + { + if (info.AvailableSystems.Count > 0) + { + return info.AvailableSystems[0].Instance as T; + } - throw new AddInLoadingException(String.Format( - "Couldn't get default {0} because there are no " + - "registered {0}s available!", addInType)); - } - else - { - foreach (AddIn addin in info.AvailableSystems) - { - if (addin.Name.Equals(info.PreferredName, - StringComparison.InvariantCultureIgnoreCase)) - { - return addin.Instance as T; - } - } + throw new AddInLoadingException(String.Format( + "Couldn't get default {0} because there are no " + + "registered {0}s available!", addInType)); + } + else + { + foreach (AddIn addin in info.AvailableSystems) + { + if (addin.Name.Equals(info.PreferredName, StringComparison.CurrentCultureIgnoreCase)) + { + return addin.Instance as T; + } + } - throw new AddInLoadingException(String.Format( - "Couldn't get default {0} '{1}' because it was not found in the " + - "list of registered creators!", addInType, info.PreferredName)); - } + throw new AddInLoadingException(String.Format( + "Couldn't get default {0} '{1}' because it was not found in the " + + "list of registered creators!", addInType, info.PreferredName)); + } throw new AddInLoadingException(String.Format( "Couldn't find a DefaultCreator of type '{0}'!", type.FullName)); } - #endregion + #endregion - #region SortAddIns - public void SortAddIns() + #region SortAddIns + public void SortAddIns() { - foreach (AddInSystemInfo info in addinSystems.Values) - { - info.AvailableSystems.Sort(); - } + foreach (AddInSystemInfo info in addinSystems.Values) + { + info.AvailableSystems.Sort(); + } this.creators = this.creators.OrderBy(x => x.Value.Priority).ToDictionary(x => x.Key, x => x.Value); - } - #endregion + } + #endregion - #region GetPreferredSystem - public string GetPreferredSystem(AddInType addInType) - { - return addinSystems[addInType].PreferredName; - } - #endregion + #region GetPreferredSystem + public string GetPreferredSystem(AddInType addInType) + { + return addinSystems[addInType].PreferredName; + } + #endregion - #region SetPreferredSystem - public void SetPreferredSystem(AddInType addInType, string preferredName) - { - if (addinSystems[addInType].PreferredLocked) - { - throw new AddInLoadingException(String.Format( - "Can't set preferred {0} because a {0} is alread in use.", addInType)); - } + #region SetPreferredSystem + public void SetPreferredSystem(AddInType addInType, string preferredName) + { + if (addinSystems[addInType].PreferredLocked) + { + throw new AddInLoadingException(String.Format( + "Can't set preferred {0} because a {0} is alread in use.", addInType)); + } - addinSystems[addInType].PreferredName = preferredName; - } - #endregion + addinSystems[addInType].PreferredName = preferredName; + } + #endregion - #region PreventSystemChange - public void PreventSystemChange(AddInType addInType) + #region PreventSystemChange + public void PreventSystemChange(AddInType addInType) { addinSystems[addInType].PreferredLocked = true; } - #endregion + #endregion - #region GetAddInType - internal static AddInType GetAddInType(Type t) + #region GetAddInType + internal static AddInType GetAddInType(Type t) { - if (typeof(IRenderSystemCreator).IsAssignableFrom(t)) + if (IsAssignable(typeof(IRenderSystemCreator), t)) { return AddInType.RenderSystem; } - else if (typeof(IInputSystemCreator).IsAssignableFrom(t)) + else if (IsAssignable(typeof(IInputSystemCreator), t)) { return AddInType.InputSystem; } - else if (typeof(ISoundSystemCreator).IsAssignableFrom(t)) + else if (IsAssignable(typeof(ISoundSystemCreator), t)) { return AddInType.SoundSystem; - } - else if (typeof(IMediaSystemCreator).IsAssignableFrom(t)) - { - return AddInType.MediaSystem; - } + } + else if (IsAssignable(typeof(IMediaSystemCreator), t)) + { + return AddInType.MediaSystem; + } else { return AddInType.Unknown; } - } - #endregion } + #endregion + + private static bool IsAssignable(System.Type lt, System.Type rt) + { +#if WIN8 + return lt.GetTypeInfo().IsAssignableFrom(rt.GetTypeInfo()); +#else + return lt.IsAssignableFrom(rt); +#endif + } + } } diff --git a/ANX.Framework/NonXNA/IServiceProvider.cs b/ANX.Framework/NonXNA/IServiceProvider.cs new file mode 100644 index 00000000..908379b5 --- /dev/null +++ b/ANX.Framework/NonXNA/IServiceProvider.cs @@ -0,0 +1,62 @@ +#region Using Statements +using System; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + + +namespace ANX.Framework +{ +#if WIN8 + public interface IServiceProvider + { + Object GetService(Type serviceType); + } +#endif +} diff --git a/ANX.Framework/NonXNA/NoInputDeviceException.cs b/ANX.Framework/NonXNA/NoInputDeviceException.cs index a054fb25..2821c40e 100644 --- a/ANX.Framework/NonXNA/NoInputDeviceException.cs +++ b/ANX.Framework/NonXNA/NoInputDeviceException.cs @@ -59,10 +59,12 @@ namespace ANX.Framework.NonXNA { } +#if !WIN8 //TODO: search replacement for Win8 protected NoInputDeviceException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public NoInputDeviceException(string message) : base(message) diff --git a/ANX.Framework/Storage/StorageContainer.cs b/ANX.Framework/Storage/StorageContainer.cs index 2c965133..3082a32d 100644 --- a/ANX.Framework/Storage/StorageContainer.cs +++ b/ANX.Framework/Storage/StorageContainer.cs @@ -54,6 +54,8 @@ using System.Collections.Generic; namespace ANX.Framework.Storage { +#if !WIN8 //TODO: search replacement for Win8 + public class StorageContainer : IDisposable { private DirectoryInfo baseDirectory; @@ -181,4 +183,5 @@ namespace ANX.Framework.Storage IsDisposed = true; } } +#endif } diff --git a/ANX.Framework/Storage/StorageDevice.cs b/ANX.Framework/Storage/StorageDevice.cs index 4a6372b3..7603673a 100644 --- a/ANX.Framework/Storage/StorageDevice.cs +++ b/ANX.Framework/Storage/StorageDevice.cs @@ -53,6 +53,8 @@ using System.IO; namespace ANX.Framework.Storage { +#if !WIN8 //TODO: search replacement for Win8 + public sealed class StorageDevice { private static Func openDeviceDelegate = null; @@ -217,4 +219,5 @@ namespace ANX.Framework.Storage return new StorageContainer(this, this.PlayerIndex, displayName); } } +#endif } diff --git a/ANX.Framework/Storage/StorageDeviceNotConnectedException.cs b/ANX.Framework/Storage/StorageDeviceNotConnectedException.cs index 72640f28..53658815 100644 --- a/ANX.Framework/Storage/StorageDeviceNotConnectedException.cs +++ b/ANX.Framework/Storage/StorageDeviceNotConnectedException.cs @@ -60,9 +60,11 @@ namespace ANX.Framework.Storage : base() { } +#if !WIN8 //TODO: search replacement for Win8 protected StorageDeviceNotConnectedException(SerializationInfo info, StreamingContext context) : base(info, context) { } +#endif public StorageDeviceNotConnectedException(string message) : base(message) diff --git a/ANX.RenderSystem.Windows.Metro.sln b/ANX.RenderSystem.Windows.Metro.sln new file mode 100644 index 00000000..a5a90b3f --- /dev/null +++ b/ANX.RenderSystem.Windows.Metro.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 11 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.RenderSystem.Windows.Metro", "RenderSystems\ANX.RenderSystem.Windows.Metro\ANX.RenderSystem.Windows.Metro.csproj", "{FFA7FF96-572C-4284-AB4D-E8B5539565F3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.Framework", "ANX.Framework\ANX.Framework.csproj", "{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + DebugWin8|Any CPU = DebugWin8|Any CPU + Debug|Any CPU = Debug|Any CPU + ReleaseWin8|Any CPU = ReleaseWin8|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.DebugWin8|Any CPU.ActiveCfg = DebugWin8|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.DebugWin8|Any CPU.Build.0 = DebugWin8|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.ReleaseWin8|Any CPU.ActiveCfg = ReleaseWin8|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.ReleaseWin8|Any CPU.Build.0 = ReleaseWin8|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}.Release|Any CPU.Build.0 = Release|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.DebugWin8|Any CPU.ActiveCfg = Debug|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.DebugWin8|Any CPU.Build.0 = Debug|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.DebugWin8|Any CPU.Deploy.0 = Debug|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.ReleaseWin8|Any CPU.ActiveCfg = Release|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.ReleaseWin8|Any CPU.Build.0 = Release|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.ReleaseWin8|Any CPU.Deploy.0 = Release|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Release|Any CPU.Build.0 = Release|Any CPU + {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Release|Any CPU.Deploy.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.csproj b/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.csproj index 3e02a4bb..2ecc593b 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.csproj +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.csproj @@ -6,7 +6,7 @@ 8.0.30703 2.0 {FFA7FF96-572C-4284-AB4D-E8B5539565F3} - Library + appcontainerexe Properties ANX.RenderSystem.Windows.Metro ANX.RenderSystem.Windows.Metro @@ -18,23 +18,48 @@ true full false - bin\Debug\ - DEBUG;TRACE + ..\..\bin\Debug\ + TRACE;DEBUG;METRO prompt 4 + true pdbonly true - bin\Release\ - TRACE + ..\..\bin\Release\ + TRACE;METRO prompt 4 + true + + + - + + + + + + + + + + + + + + + + + + + + + ..\..\lib\SharpDX-Win8\Bin\SharpDX.dll diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.sln b/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.sln deleted file mode 100644 index 3e5b3709..00000000 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/ANX.RenderSystem.Windows.Metro.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 11 Express for Windows 8 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ANX.RenderSystem.Windows.Metro", "ANX.RenderSystem.Windows.Metro.csproj", "{FFA7FF96-572C-4284-AB4D-E8B5539565F3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FFA7FF96-572C-4284-AB4D-E8B5539565F3}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs index b36dcbc5..96620543 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/BlendState_Metro.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.Graphics; using ANX.Framework.NonXNA; @@ -56,27 +56,28 @@ using ANX.Framework.NonXNA; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class BlendState_DX10 : INativeBlendState + public class BlendState_Metro : INativeBlendState { #region Private Members - private BlendStateDescription description; - private SharpDX.Direct3D10.BlendState nativeBlendState; + private BlendStateDescription blendStateDescription; + private SharpDX.Direct3D11.BlendState nativeBlendState; private bool nativeBlendStateDirty; private SharpDX.Color4 blendFactor; private int multiSampleMask; private bool bound; + #endregion // Private Members - public BlendState_DX10() + public BlendState_Metro() { - this.description = new BlendStateDescription(); - - for (int i = 0; i < description.IsBlendEnabled.Length; i++) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - description.IsBlendEnabled[i] = (i < 4); + blendStateDescription.RenderTarget[i] = new RenderTargetBlendDescription(); + blendStateDescription.RenderTarget[i].IsBlendEnabled = (i < 4); + blendStateDescription.IndependentBlendEnable = true; } nativeBlendStateDirty = true; @@ -84,13 +85,13 @@ namespace ANX.Framework.Windows.DX10 public void Apply(GraphicsDevice graphics) { - GraphicsDeviceWindowsDX10 gdx10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = gdx10.NativeDevice; + GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro; + SharpDX.Direct3D11.DeviceContext context = gdMetro.NativeDevice; - UpdateNativeBlendState(device); + UpdateNativeBlendState(context.Device); this.bound = true; - device.OutputMerger.SetBlendState(nativeBlendState, this.blendFactor, this.multiSampleMask); + context.OutputMerger.SetBlendState(nativeBlendState, this.blendFactor, this.multiSampleMask); } public void Release() @@ -142,10 +143,14 @@ namespace ANX.Framework.Windows.DX10 { BlendOperation alphaBlendOperation = FormatConverter.Translate(value); - if (description.AlphaBlendOperation != alphaBlendOperation) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - nativeBlendStateDirty = true; - description.AlphaBlendOperation = alphaBlendOperation; + if (blendStateDescription.RenderTarget[i].AlphaBlendOperation != alphaBlendOperation) + { + nativeBlendStateDirty = true; + blendStateDescription.RenderTarget[i].AlphaBlendOperation = alphaBlendOperation; + } + } } } @@ -156,10 +161,14 @@ namespace ANX.Framework.Windows.DX10 { BlendOperation blendOperation = FormatConverter.Translate(value); - if (description.BlendOperation != blendOperation) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - nativeBlendStateDirty = true; - description.BlendOperation = blendOperation; + if (blendStateDescription.RenderTarget[i].BlendOperation != blendOperation) + { + nativeBlendStateDirty = true; + blendStateDescription.RenderTarget[i].BlendOperation = blendOperation; + } + } } } @@ -170,10 +179,14 @@ namespace ANX.Framework.Windows.DX10 { BlendOption destinationAlphaBlend = FormatConverter.Translate(value); - if (description.DestinationAlphaBlend != destinationAlphaBlend) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - nativeBlendStateDirty = true; - description.DestinationAlphaBlend = destinationAlphaBlend; + if (blendStateDescription.RenderTarget[i].DestinationAlphaBlend != destinationAlphaBlend) + { + nativeBlendStateDirty = true; + blendStateDescription.RenderTarget[i].DestinationAlphaBlend = destinationAlphaBlend; + } + } } } @@ -184,10 +197,14 @@ namespace ANX.Framework.Windows.DX10 { BlendOption destinationBlend = FormatConverter.Translate(value); - if (description.DestinationBlend != destinationBlend) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - nativeBlendStateDirty = true; - description.DestinationBlend = destinationBlend; + if (blendStateDescription.RenderTarget[i].DestinationBlend != destinationBlend) + { + nativeBlendStateDirty = true; + blendStateDescription.RenderTarget[i].DestinationBlend = destinationBlend; + } + } } } @@ -198,10 +215,12 @@ namespace ANX.Framework.Windows.DX10 { ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); - if (description.RenderTargetWriteMask[0] != renderTargetWriteMask) + //TODO: range check + + if (blendStateDescription.RenderTarget[0].RenderTargetWriteMask != renderTargetWriteMask) { nativeBlendStateDirty = true; - description.RenderTargetWriteMask[0] = renderTargetWriteMask; + blendStateDescription.RenderTarget[0].RenderTargetWriteMask = renderTargetWriteMask; } } } @@ -212,10 +231,12 @@ namespace ANX.Framework.Windows.DX10 { ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); - if (description.RenderTargetWriteMask[1] != renderTargetWriteMask) + //TODO: range check + + if (blendStateDescription.RenderTarget[1].RenderTargetWriteMask != renderTargetWriteMask) { nativeBlendStateDirty = true; - description.RenderTargetWriteMask[1] = renderTargetWriteMask; + blendStateDescription.RenderTarget[1].RenderTargetWriteMask = renderTargetWriteMask; } } } @@ -226,10 +247,12 @@ namespace ANX.Framework.Windows.DX10 { ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); - if (description.RenderTargetWriteMask[2] != renderTargetWriteMask) + //TODO: range check + + if (blendStateDescription.RenderTarget[2].RenderTargetWriteMask != renderTargetWriteMask) { nativeBlendStateDirty = true; - description.RenderTargetWriteMask[2] = renderTargetWriteMask; + blendStateDescription.RenderTarget[2].RenderTargetWriteMask = renderTargetWriteMask; } } } @@ -240,10 +263,12 @@ namespace ANX.Framework.Windows.DX10 { ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); - if (description.RenderTargetWriteMask[3] != renderTargetWriteMask) + //TODO: range check + + if (blendStateDescription.RenderTarget[3].RenderTargetWriteMask != renderTargetWriteMask) { nativeBlendStateDirty = true; - description.RenderTargetWriteMask[3] = renderTargetWriteMask; + blendStateDescription.RenderTarget[3].RenderTargetWriteMask = renderTargetWriteMask; } } } @@ -254,10 +279,14 @@ namespace ANX.Framework.Windows.DX10 { BlendOption sourceAlphaBlend = FormatConverter.Translate(value); - if (description.SourceAlphaBlend != sourceAlphaBlend) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - nativeBlendStateDirty = true; - description.SourceAlphaBlend = sourceAlphaBlend; + if (blendStateDescription.RenderTarget[i].SourceAlphaBlend != sourceAlphaBlend) + { + nativeBlendStateDirty = true; + blendStateDescription.RenderTarget[i].SourceAlphaBlend = sourceAlphaBlend; + } + } } } @@ -268,15 +297,19 @@ namespace ANX.Framework.Windows.DX10 { BlendOption sourceBlend = FormatConverter.Translate(value); - if (description.SourceBlend != sourceBlend) + for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) { - nativeBlendStateDirty = true; - description.SourceBlend = sourceBlend; + if (blendStateDescription.RenderTarget[i].SourceBlend != sourceBlend) + { + nativeBlendStateDirty = true; + blendStateDescription.RenderTarget[i].SourceBlend = sourceBlend; + } + } } } - private void UpdateNativeBlendState(SharpDX.Direct3D10.Device device) + private void UpdateNativeBlendState(SharpDX.Direct3D11.Device device) { if (this.nativeBlendStateDirty == true || this.nativeBlendState == null) { @@ -286,7 +319,7 @@ namespace ANX.Framework.Windows.DX10 this.nativeBlendState = null; } - this.nativeBlendState = new SharpDX.Direct3D10.BlendState(device, ref this.description); + this.nativeBlendState = new SharpDX.Direct3D11.BlendState(device, ref this.blendStateDescription); this.nativeBlendStateDirty = false; } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs index 505c89a1..29221df4 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Creator.cs @@ -59,13 +59,13 @@ using ANX.Framework.NonXNA.RenderSystem; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { public class Creator : IRenderSystemCreator { public string Name { - get { return "DirectX10"; } + get { return "Metro"; } } public int Priority @@ -78,7 +78,8 @@ namespace ANX.Framework.Windows.DX10 get { //TODO: this is just a very basic version of test for support - return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT; + //TODO: return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT; + throw new NotImplementedException(); } } @@ -89,31 +90,31 @@ namespace ANX.Framework.Windows.DX10 public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters) { - return new GraphicsDeviceWindowsDX10(presentationParameters); + return new GraphicsDeviceWindowsMetro(presentationParameters); } - public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, - IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage) + public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, + IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage) { - return new IndexBuffer_DX10(graphics, size, indexCount, usage); + return new IndexBuffer_Metro(graphics, size, indexCount, usage); } public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) { - return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage); + return new VertexBuffer_Metro(graphics, vertexDeclaration, vertexCount, usage); } public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { - Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode); + Effect_Metro effect = new Effect_Metro(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode); return effect; } public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, System.IO.Stream byteCode) { - Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, byteCode); + Effect_Metro effect = new Effect_Metro(graphics, managedEffect, byteCode); return effect; } @@ -124,7 +125,7 @@ namespace ANX.Framework.Windows.DX10 throw new NotImplementedException(); //GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; - //SharpDX.Direct3D10.Texture2D nativeTexture = SharpDX.Direct3D10.Texture2D.FromFile(graphicsDX10.NativeDevice, fileName); + //SharpDX.Direct3D11.Texture2D nativeTexture = SharpDX.Direct3D11.Texture2D.FromFile(graphicsDX10.NativeDevice, fileName); //Texture2D_DX10 texture = new Texture2D_DX10(graphics, nativeTexture.Description.Width, nativeTexture.Description.Height, FormatConverter.Translate(nativeTexture.Description.Format), nativeTexture.Description.MipLevels); //texture.NativeTexture = nativeTexture; @@ -133,22 +134,22 @@ namespace ANX.Framework.Windows.DX10 public INativeBlendState CreateBlendState() { - return new BlendState_DX10(); + return new BlendState_Metro(); } public INativeRasterizerState CreateRasterizerState() { - return new RasterizerState_DX10(); + return new RasterizerState_Metro(); } public INativeDepthStencilState CreateDepthStencilState() { - return new DepthStencilState_DX10(); + return new DepthStencilState_Metro(); } public INativeSamplerState CreateSamplerState() { - return new SamplerState_DX10(); + return new SamplerState_Metro(); } public byte[] GetShaderByteCode(PreDefinedShader type) @@ -241,12 +242,12 @@ namespace ANX.Framework.Windows.DX10 public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount) { - return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount); + return new Texture2D_Metro(graphics, width, height, surfaceFormat, mipCount); } public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) { - return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage); + return new RenderTarget2D_Metro(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage); } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs index 376d4e9c..84a1cb10 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/DepthStencilState_Metro.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.NonXNA; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class DepthStencilState_DX10 : INativeDepthStencilState + public class DepthStencilState_Metro : INativeDepthStencilState { #region Private Members private DepthStencilStateDescription description; - private SharpDX.Direct3D10.DepthStencilState nativeDepthStencilState; + private SharpDX.Direct3D11.DepthStencilState nativeDepthStencilState; private bool nativeDepthStencilStateDirty; private bool bound; @@ -19,22 +19,22 @@ namespace ANX.Framework.Windows.DX10 #endregion // Private Members - public DepthStencilState_DX10() + public DepthStencilState_Metro() { this.description = new DepthStencilStateDescription(); this.nativeDepthStencilStateDirty = true; } - public void Apply(Graphics.GraphicsDevice graphicsDevice) + public void Apply(ANX.Framework.Graphics.GraphicsDevice graphicsDevice) { - GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; - Device device = gdx10.NativeDevice; + GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + DeviceContext context = gdMetro.NativeDevice; - UpdateNativeDepthStencilState(device); + UpdateNativeDepthStencilState(context.Device); this.bound = true; - device.OutputMerger.SetDepthStencilState(nativeDepthStencilState, this.referenceStencil); + context.OutputMerger.SetDepthStencilState(nativeDepthStencilState, this.referenceStencil); } public void Release() @@ -59,11 +59,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.StencilOperation CounterClockwiseStencilDepthBufferFail + public ANX.Framework.Graphics.StencilOperation CounterClockwiseStencilDepthBufferFail { set { - SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + SharpDX.Direct3D11.StencilOperation operation = FormatConverter.Translate(value); if (description.BackFace.DepthFailOperation != operation) { @@ -73,11 +73,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.StencilOperation CounterClockwiseStencilFail + public ANX.Framework.Graphics.StencilOperation CounterClockwiseStencilFail { set { - SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + SharpDX.Direct3D11.StencilOperation operation = FormatConverter.Translate(value); if (description.BackFace.FailOperation != operation) { @@ -87,11 +87,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.CompareFunction CounterClockwiseStencilFunction + public ANX.Framework.Graphics.CompareFunction CounterClockwiseStencilFunction { set { - SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value); + SharpDX.Direct3D11.Comparison comparison = FormatConverter.Translate(value); if (description.BackFace.Comparison != comparison) { @@ -101,11 +101,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.StencilOperation CounterClockwiseStencilPass + public ANX.Framework.Graphics.StencilOperation CounterClockwiseStencilPass { set { - SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + SharpDX.Direct3D11.StencilOperation operation = FormatConverter.Translate(value); if (description.BackFace.PassOperation != operation) { @@ -127,11 +127,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.CompareFunction DepthBufferFunction + public ANX.Framework.Graphics.CompareFunction DepthBufferFunction { set { - SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value); + SharpDX.Direct3D11.Comparison comparison = FormatConverter.Translate(value); if (description.DepthComparison != comparison) { @@ -167,11 +167,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.StencilOperation StencilDepthBufferFail + public ANX.Framework.Graphics.StencilOperation StencilDepthBufferFail { set { - SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + SharpDX.Direct3D11.StencilOperation operation = FormatConverter.Translate(value); if (description.FrontFace.DepthFailOperation != operation) { @@ -193,11 +193,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.StencilOperation StencilFail + public ANX.Framework.Graphics.StencilOperation StencilFail { set { - SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + SharpDX.Direct3D11.StencilOperation operation = FormatConverter.Translate(value); if (description.FrontFace.FailOperation != operation) { @@ -207,11 +207,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.CompareFunction StencilFunction + public ANX.Framework.Graphics.CompareFunction StencilFunction { set { - SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value); + SharpDX.Direct3D11.Comparison comparison = FormatConverter.Translate(value); if (description.FrontFace.Comparison != comparison) { @@ -235,11 +235,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.StencilOperation StencilPass + public ANX.Framework.Graphics.StencilOperation StencilPass { set { - SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value); + SharpDX.Direct3D11.StencilOperation operation = FormatConverter.Translate(value); if (description.FrontFace.PassOperation != operation) { @@ -281,10 +281,11 @@ namespace ANX.Framework.Windows.DX10 this.nativeDepthStencilState = null; } - this.nativeDepthStencilState = new SharpDX.Direct3D10.DepthStencilState(device, ref this.description); + this.nativeDepthStencilState = new SharpDX.Direct3D11.DepthStencilState(device, ref this.description); this.nativeDepthStencilStateDirty = false; } } } } + diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs index 50a50146..72a1a963 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.NonXNA; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.Graphics; using ANX.Framework.NonXNA.RenderSystem; @@ -57,48 +57,53 @@ using ANX.Framework.NonXNA.RenderSystem; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class EffectParameter_DX10 : INativeEffectParameter + public class EffectParameter_Metro : INativeEffectParameter { - private EffectVariable nativeEffectVariable; + //private EffectVariable nativeEffectVariable; - public EffectVariable NativeParameter - { - get - { - return this.nativeEffectVariable; - } - internal set - { - this.nativeEffectVariable = value; - } - } + //public EffectVariable NativeParameter + //{ + // get + // { + // return this.nativeEffectVariable; + // } + // internal set + // { + // this.nativeEffectVariable = value; + // } + //} public void SetValue(bool value) { - nativeEffectVariable.AsScalar().Set(value); + //nativeEffectVariable.AsScalar().Set(value); + throw new NotImplementedException(); } public void SetValue(bool[] value) { - nativeEffectVariable.AsScalar().Set(value); + //nativeEffectVariable.AsScalar().Set(value); + throw new NotImplementedException(); } public void SetValue(int value) { - nativeEffectVariable.AsScalar().Set(value); + //nativeEffectVariable.AsScalar().Set(value); + throw new NotImplementedException(); } public void SetValue(int[] value) { - nativeEffectVariable.AsScalar().Set(value); + //nativeEffectVariable.AsScalar().Set(value); + throw new NotImplementedException(); } public void SetValue(Matrix value) { - SharpDX.Matrix m = new SharpDX.Matrix(value.M11, value.M12, value.M13, value.M14, value.M21, value.M22, value.M23, value.M24, value.M31, value.M32, value.M33, value.M34, value.M41, value.M42, value.M43, value.M44); - nativeEffectVariable.AsMatrix().SetMatrix(m); + //SharpDX.Matrix m = new SharpDX.Matrix(value.M11, value.M12, value.M13, value.M14, value.M21, value.M22, value.M23, value.M24, value.M31, value.M32, value.M33, value.M34, value.M41, value.M42, value.M43, value.M44); + //nativeEffectVariable.AsMatrix().SetMatrix(m); + throw new NotImplementedException(); } public void SetValue(Matrix[] value) @@ -115,13 +120,15 @@ namespace ANX.Framework.Windows.DX10 anxMatrix.M41, anxMatrix.M42, anxMatrix.M43, anxMatrix.M44); } - nativeEffectVariable.AsMatrix().SetMatrix(m); + //nativeEffectVariable.AsMatrix().SetMatrix(m); + throw new NotImplementedException(); } public void SetValue(Quaternion value) { SharpDX.Vector4 q = new SharpDX.Vector4(value.X, value.Y, value.Z, value.W); - nativeEffectVariable.AsVector().Set(q); + //nativeEffectVariable.AsVector().Set(q); + throw new NotImplementedException(); } public void SetValue(Quaternion[] value) @@ -132,23 +139,27 @@ namespace ANX.Framework.Windows.DX10 { q[i] = new SharpDX.Vector4(value[i].X, value[i].Y, value[i].Z, value[i].W); } - nativeEffectVariable.AsVector().Set(q); + //nativeEffectVariable.AsVector().Set(q); + throw new NotImplementedException(); } public void SetValue(float value) { - nativeEffectVariable.AsScalar().Set(value); + //nativeEffectVariable.AsScalar().Set(value); + throw new NotImplementedException(); } public void SetValue(float[] value) { - nativeEffectVariable.AsScalar().Set(value); + //nativeEffectVariable.AsScalar().Set(value); + throw new NotImplementedException(); } public void SetValue(Vector2 value) { SharpDX.Vector2 v = new SharpDX.Vector2(value.X, value.Y); - nativeEffectVariable.AsVector().Set(v); + //nativeEffectVariable.AsVector().Set(v); + throw new NotImplementedException(); } public void SetValue(Vector2[] value) @@ -159,7 +170,8 @@ namespace ANX.Framework.Windows.DX10 public void SetValue(Vector3 value) { SharpDX.Vector3 v = new SharpDX.Vector3(value.X, value.Y, value.Z); - nativeEffectVariable.AsVector().Set(v); + //nativeEffectVariable.AsVector().Set(v); + throw new NotImplementedException(); } public void SetValue(Vector3[] value) @@ -170,7 +182,8 @@ namespace ANX.Framework.Windows.DX10 public void SetValue(Vector4 value) { SharpDX.Vector4 v = new SharpDX.Vector4(value.X, value.Y, value.Z, value.W); - nativeEffectVariable.AsVector().Set(v); + //nativeEffectVariable.AsVector().Set(v); + throw new NotImplementedException(); } public void SetValue(Vector4[] value) @@ -181,150 +194,156 @@ namespace ANX.Framework.Windows.DX10 { q[i] = new SharpDX.Vector4(value[i].X, value[i].Y, value[i].Z, value[i].W); } - nativeEffectVariable.AsVector().Set(q); + //nativeEffectVariable.AsVector().Set(q); + throw new NotImplementedException(); } public void SetValue(Texture value) { - Texture2D_DX10 tex = value.NativeTexture as Texture2D_DX10; - GraphicsDeviceWindowsDX10 graphicsDX10 = tex.GraphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice; + Texture2D_Metro tex = value.NativeTexture as Texture2D_Metro; - nativeEffectVariable.AsShaderResource().SetResource(tex.NativeShaderResourceView); + //nativeEffectVariable.AsShaderResource().SetResource(tex.NativeShaderResourceView); + throw new NotImplementedException(); } + public void SetValue(Matrix value, bool transpose) + { + throw new NotImplementedException(); + } + public void SetValue(Matrix[] value, bool transpose) + { + throw new NotImplementedException(); + } public string Name { get { - return nativeEffectVariable.Description.Name; + //return nativeEffectVariable.Description.Name; + throw new NotImplementedException(); } - } - #region INativeEffectParameter Member + } + + #region INativeEffectParameter Member - public bool GetValueBoolean() - { - throw new NotImplementedException(); - } + public bool GetValueBoolean() + { + throw new NotImplementedException(); + } - public bool[] GetValueBooleanArray(int count) - { - throw new NotImplementedException(); - } + public bool[] GetValueBooleanArray(int count) + { + throw new NotImplementedException(); + } - public int GetValueInt32() - { - throw new NotImplementedException(); - } + public int GetValueInt32() + { + throw new NotImplementedException(); + } - public int[] GetValueInt32Array(int count) - { - throw new NotImplementedException(); - } + public int[] GetValueInt32Array(int count) + { + throw new NotImplementedException(); + } - public Matrix GetValueMatrix() - { - throw new NotImplementedException(); - } + public Matrix GetValueMatrix() + { + throw new NotImplementedException(); + } - public Matrix[] GetValueMatrixArray(int count) - { - throw new NotImplementedException(); - } + public Matrix[] GetValueMatrixArray(int count) + { + throw new NotImplementedException(); + } - public Matrix GetValueMatrixTranspose() - { - throw new NotImplementedException(); - } + public Matrix GetValueMatrixTranspose() + { + throw new NotImplementedException(); + } - public Matrix[] GetValueMatrixTransposeArray(int count) - { - throw new NotImplementedException(); - } + public Matrix[] GetValueMatrixTransposeArray(int count) + { + throw new NotImplementedException(); + } - public Quaternion GetValueQuaternion() - { - throw new NotImplementedException(); - } + public Quaternion GetValueQuaternion() + { + throw new NotImplementedException(); + } - public Quaternion[] GetValueQuaternionArray(int count) - { - throw new NotImplementedException(); - } + public Quaternion[] GetValueQuaternionArray(int count) + { + throw new NotImplementedException(); + } - public float GetValueSingle() - { - throw new NotImplementedException(); - } + public float GetValueSingle() + { + throw new NotImplementedException(); + } - public float[] GetValueSingleArray(int count) - { - throw new NotImplementedException(); - } + public float[] GetValueSingleArray(int count) + { + throw new NotImplementedException(); + } - public string GetValueString() - { - throw new NotImplementedException(); - } + public string GetValueString() + { + throw new NotImplementedException(); + } - public Graphics.Texture2D GetValueTexture2D() - { - throw new NotImplementedException(); - } + public Graphics.Texture2D GetValueTexture2D() + { + throw new NotImplementedException(); + } - public Graphics.Texture3D GetValueTexture3D() - { - throw new NotImplementedException(); - } + public Graphics.Texture3D GetValueTexture3D() + { + throw new NotImplementedException(); + } - public TextureCube GetValueTextureCube() - { - throw new NotImplementedException(); - } + public TextureCube GetValueTextureCube() + { + throw new NotImplementedException(); + } - public Vector2 GetValueVector2() - { - throw new NotImplementedException(); - } + public Vector2 GetValueVector2() + { + throw new NotImplementedException(); + } - public Vector2[] GetValueVector2Array(int count) - { - throw new NotImplementedException(); - } + public Vector2[] GetValueVector2Array(int count) + { + throw new NotImplementedException(); + } - public Vector3 GetValueVector3() - { - throw new NotImplementedException(); - } + public Vector3 GetValueVector3() + { + throw new NotImplementedException(); + } - public Vector3[] GetValueVector3Array(int count) - { - throw new NotImplementedException(); - } + public Vector3[] GetValueVector3Array(int count) + { + throw new NotImplementedException(); + } - public Vector4 GetValueVector4() - { - throw new NotImplementedException(); - } + public Vector4 GetValueVector4() + { + throw new NotImplementedException(); + } - public Vector4[] GetValueVector4Array(int count) - { - throw new NotImplementedException(); - } + public Vector4[] GetValueVector4Array(int count) + { + throw new NotImplementedException(); + } - #endregion + public void SetValue(string value) + { + throw new NotImplementedException(); + } - #region INativeEffectParameter Member - - - public void SetValue(string value) - { - throw new NotImplementedException(); - } - - #endregion + #endregion + } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs index 56743c9d..cfcdfeef 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectPass_Metro.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.NonXNA; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; #endregion // Using Statements @@ -55,29 +55,30 @@ using SharpDX.Direct3D10; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class EffectPass_DX10 : INativeEffectPass + public class EffectPass_Metro : INativeEffectPass { - private EffectPass nativePass; + //private EffectPass nativePass; - public EffectPass NativePass - { - get - { - return this.nativePass; - } - internal set - { - this.nativePass = value; - } - } + //public EffectPass NativePass + //{ + // get + // { + // return this.nativePass; + // } + // internal set + // { + // this.nativePass = value; + // } + //} public string Name { get { - return nativePass.Description.Name; + //return nativePass.Description.Name; + throw new NotImplementedException(); } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs index 6aae7fd7..9c07c14a 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectTechnique_Metro.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.NonXNA; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; #endregion // Using Statements @@ -55,40 +55,41 @@ using SharpDX.Direct3D10; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class EffectTechnique_DX10 : INativeEffectTechnique + public class EffectTechnique_Metro : INativeEffectTechnique { - private EffectTechnique nativeTechnique; + //private EffectTechnique nativeTechnique; private ANX.Framework.Graphics.Effect parentEffect; - internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect) - { - if (parentEffect == null) - { - throw new ArgumentNullException("parentEffect"); - } + //internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect) + //{ + // if (parentEffect == null) + // { + // throw new ArgumentNullException("parentEffect"); + // } - this.parentEffect = parentEffect; - } + // this.parentEffect = parentEffect; + //} - public EffectTechnique NativeTechnique - { - get - { - return this.nativeTechnique; - } - internal set - { - this.nativeTechnique = value; - } - } + //public EffectTechnique NativeTechnique + //{ + // get + // { + // return this.nativeTechnique; + // } + // internal set + // { + // this.nativeTechnique = value; + // } + //} public string Name { get { - return nativeTechnique.Description.Name; + //return nativeTechnique.Description.Name; + throw new NotImplementedException(); } } @@ -97,15 +98,19 @@ namespace ANX.Framework.Windows.DX10 { get { - for (int i = 0; i < nativeTechnique.Description.PassCount; i++) - { - EffectPass_DX10 passDx10 = new EffectPass_DX10(); - passDx10.NativePass = nativeTechnique.GetPassByIndex(i); + //TODO: implement + System.Diagnostics.Debugger.Break(); + return null; - Graphics.EffectPass pass = new Graphics.EffectPass(this.parentEffect); + //for (int i = 0; i < nativeTechnique.Description.PassCount; i++) + //{ + // EffectPass_DX10 passDx10 = new EffectPass_DX10(); + // passDx10.NativePass = nativeTechnique.GetPassByIndex(i); - yield return pass; - } + // Graphics.EffectPass pass = new Graphics.EffectPass(this.parentEffect); + + // yield return pass; + //} } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs index 55819ba7..dcc7825c 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Effect_Metro.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using SharpDX.D3DCompiler; using System.IO; using ANX.Framework.NonXNA; @@ -58,9 +58,9 @@ using ANX.Framework.Graphics; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class Effect_DX10 : INativeEffect + public class Effect_Metro : INativeEffect { private ShaderBytecode pixelShaderByteCode; private ShaderBytecode vertexShaderByteCode; @@ -68,9 +68,8 @@ namespace ANX.Framework.Windows.DX10 private PixelShader pixelShader; private ANX.Framework.Graphics.Effect managedEffect; private ShaderBytecode effectByteCode; - private SharpDX.Direct3D10.Effect nativeEffect; - public Effect_DX10(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) + public Effect_Metro(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { if (this.managedEffect == null) { @@ -83,17 +82,17 @@ namespace ANX.Framework.Windows.DX10 vertexShaderByteCode.Seek(0, SeekOrigin.Begin); } this.vertexShaderByteCode = ShaderBytecode.FromStream(vertexShaderByteCode); - this.vertexShader = new VertexShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.vertexShaderByteCode); + this.vertexShader = new VertexShader((SharpDX.Direct3D11.Device)device.NativeDevice, this.vertexShaderByteCode); if (pixelShaderByteCode.CanSeek) { pixelShaderByteCode.Seek(0, SeekOrigin.Begin); } this.pixelShaderByteCode = ShaderBytecode.FromStream(pixelShaderByteCode); - this.pixelShader = new PixelShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.pixelShaderByteCode); + this.pixelShader = new PixelShader((SharpDX.Direct3D11.Device)device.NativeDevice, this.pixelShaderByteCode); } - public Effect_DX10(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream effectByteCode) + public Effect_Metro(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream effectByteCode) { if (managedEffect == null) { @@ -106,20 +105,36 @@ namespace ANX.Framework.Windows.DX10 effectByteCode.Seek(0, SeekOrigin.Begin); } this.effectByteCode = ShaderBytecode.FromStream(effectByteCode); - this.nativeEffect = new SharpDX.Direct3D10.Effect(((GraphicsDeviceWindowsDX10)device.NativeDevice).NativeDevice, this.effectByteCode); + //this.nativeEffect = new SharpDX.Direct3D11.Effect(((GraphicsDeviceWindowsDX10)device.NativeDevice).NativeDevice, this.effectByteCode); } public void Apply(GraphicsDevice graphicsDevice) { //TODO: dummy - ((GraphicsDeviceWindowsDX10)graphicsDevice.NativeDevice).currentEffect = this; + ((GraphicsDeviceWindowsMetro)graphicsDevice.NativeDevice).currentEffect = this; } - internal SharpDX.Direct3D10.Effect NativeEffect + //internal SharpDX.Direct3D11.Effect NativeEffect + //{ + // get + // { + // return this.nativeEffect; + // } + //} + + internal SharpDX.Direct3D11.VertexShader NativeVertexShader { get { - return this.nativeEffect; + return this.vertexShader; + } + } + + internal SharpDX.Direct3D11.PixelShader NativePixelShader + { + get + { + return this.pixelShader; } } @@ -211,11 +226,11 @@ namespace ANX.Framework.Windows.DX10 this.effectByteCode = null; } - if (this.nativeEffect != null) - { - this.nativeEffect.Dispose(); - this.nativeEffect = null; - } + //if (this.nativeEffect != null) + //{ + // this.nativeEffect.Dispose(); + // this.nativeEffect = null; + //} } @@ -223,15 +238,17 @@ namespace ANX.Framework.Windows.DX10 { get { - for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++) - { - EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10(this.managedEffect); - teqDx10.NativeTechnique = nativeEffect.GetTechniqueByIndex(i); + throw new NotImplementedException(); - Graphics.EffectTechnique teq = new Graphics.EffectTechnique(this.managedEffect, teqDx10); + //for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++) + //{ + // EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10(this.managedEffect); + // teqDx10.NativeTechnique = nativeEffect.GetTechniqueByIndex(i); + + // Graphics.EffectTechnique teq = new Graphics.EffectTechnique(this.managedEffect, teqDx10); - yield return teq; - } + // yield return teq; + //} } } @@ -239,16 +256,25 @@ namespace ANX.Framework.Windows.DX10 { get { - for (int i = 0; i < nativeEffect.Description.GlobalVariableCount; i++) - { - EffectParameter_DX10 parDx10 = new EffectParameter_DX10(); - parDx10.NativeParameter = nativeEffect.GetVariableByIndex(i); + ShaderReflection shaderReflection = new ShaderReflection(this.vertexShaderByteCode); + ShaderDescription description = shaderReflection.Description; - Graphics.EffectParameter par = new Graphics.EffectParameter(); - par.NativeParameter = parDx10; + //TODO: implement - yield return par; - } + System.Diagnostics.Debugger.Break(); + + return null; + + //for (int i = 0; i < nativeEffect.Description.GlobalVariableCount; i++) + //{ + // EffectParameter_Metro parDx10 = new EffectParameter_Metro(); + // parDx10.NativeParameter = nativeEffect.GetVariableByIndex(i); + + // Graphics.EffectParameter par = new Graphics.EffectParameter(); + // par.NativeParameter = parDx10; + + // yield return par; + //} } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs index d29ee791..bc676026 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/FormatConverter.cs @@ -1,7 +1,7 @@ #region Using Statements using System; using ANX.Framework.Graphics; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using SharpDX.Direct3D; using SharpDX.DXGI; @@ -54,7 +54,7 @@ using SharpDX.DXGI; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { internal class FormatConverter { @@ -161,19 +161,19 @@ namespace ANX.Framework.Windows.DX10 throw new NotImplementedException(); } - public static SharpDX.Direct3D10.TextureAddressMode Translate(ANX.Framework.Graphics.TextureAddressMode addressMode) + public static SharpDX.Direct3D11.TextureAddressMode Translate(ANX.Framework.Graphics.TextureAddressMode addressMode) { switch (addressMode) { case Graphics.TextureAddressMode.Clamp: - return SharpDX.Direct3D10.TextureAddressMode.Clamp; + return SharpDX.Direct3D11.TextureAddressMode.Clamp; case Graphics.TextureAddressMode.Mirror: - return SharpDX.Direct3D10.TextureAddressMode.Mirror; + return SharpDX.Direct3D11.TextureAddressMode.Mirror; case Graphics.TextureAddressMode.Wrap: - return SharpDX.Direct3D10.TextureAddressMode.Wrap; + return SharpDX.Direct3D11.TextureAddressMode.Wrap; } - return SharpDX.Direct3D10.TextureAddressMode.Clamp; + return SharpDX.Direct3D11.TextureAddressMode.Clamp; } public static PrimitiveTopology Translate(PrimitiveType primitiveType) @@ -305,26 +305,26 @@ namespace ANX.Framework.Windows.DX10 return mask; } - public static SharpDX.Direct3D10.StencilOperation Translate(ANX.Framework.Graphics.StencilOperation stencilOperation) + public static SharpDX.Direct3D11.StencilOperation Translate(ANX.Framework.Graphics.StencilOperation stencilOperation) { switch (stencilOperation) { case Graphics.StencilOperation.Decrement: - return SharpDX.Direct3D10.StencilOperation.Decrement; + return SharpDX.Direct3D11.StencilOperation.Decrement; case Graphics.StencilOperation.DecrementSaturation: - return SharpDX.Direct3D10.StencilOperation.DecrementAndClamp; + return SharpDX.Direct3D11.StencilOperation.DecrementAndClamp; case Graphics.StencilOperation.Increment: - return SharpDX.Direct3D10.StencilOperation.Increment; + return SharpDX.Direct3D11.StencilOperation.Increment; case Graphics.StencilOperation.IncrementSaturation: - return SharpDX.Direct3D10.StencilOperation.IncrementAndClamp; + return SharpDX.Direct3D11.StencilOperation.IncrementAndClamp; case Graphics.StencilOperation.Invert: - return SharpDX.Direct3D10.StencilOperation.Invert; + return SharpDX.Direct3D11.StencilOperation.Invert; case Graphics.StencilOperation.Keep: - return SharpDX.Direct3D10.StencilOperation.Keep; + return SharpDX.Direct3D11.StencilOperation.Keep; case Graphics.StencilOperation.Replace: - return SharpDX.Direct3D10.StencilOperation.Replace; + return SharpDX.Direct3D11.StencilOperation.Replace; case Graphics.StencilOperation.Zero: - return SharpDX.Direct3D10.StencilOperation.Zero; + return SharpDX.Direct3D11.StencilOperation.Zero; } throw new NotImplementedException("unknown StencilOperation"); @@ -355,31 +355,31 @@ namespace ANX.Framework.Windows.DX10 throw new NotImplementedException("unknown CompareFunction"); } - public static SharpDX.Direct3D10.CullMode Translate(ANX.Framework.Graphics.CullMode cullMode) + public static SharpDX.Direct3D11.CullMode Translate(ANX.Framework.Graphics.CullMode cullMode) { if (cullMode == Graphics.CullMode.CullClockwiseFace) { - return SharpDX.Direct3D10.CullMode.Front; + return SharpDX.Direct3D11.CullMode.Front; } else if (cullMode == Graphics.CullMode.CullCounterClockwiseFace) { - return SharpDX.Direct3D10.CullMode.Back; + return SharpDX.Direct3D11.CullMode.Back; } else { - return SharpDX.Direct3D10.CullMode.None; + return SharpDX.Direct3D11.CullMode.None; } } - public static SharpDX.Direct3D10.FillMode Translate(ANX.Framework.Graphics.FillMode fillMode) + public static SharpDX.Direct3D11.FillMode Translate(ANX.Framework.Graphics.FillMode fillMode) { if (fillMode == Graphics.FillMode.WireFrame) { - return SharpDX.Direct3D10.FillMode.Wireframe; + return SharpDX.Direct3D11.FillMode.Wireframe; } else { - return SharpDX.Direct3D10.FillMode.Solid; + return SharpDX.Direct3D11.FillMode.Solid; } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs index 90319be4..e6914e9e 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/GraphicsDeviceWindowsMetro.cs @@ -8,7 +8,7 @@ using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.D3DCompiler; using ANX.Framework.NonXNA; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.Graphics; #endregion // Using Statements @@ -60,13 +60,13 @@ using ANX.Framework.Graphics; #endregion // License -using Device = SharpDX.Direct3D10.Device; -using Buffer = SharpDX.Direct3D10.Buffer; +using Device = SharpDX.Direct3D11.Device; +using Buffer = SharpDX.Direct3D11.Buffer; using System.Runtime.InteropServices; -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class GraphicsDeviceWindowsDX10 : INativeGraphicsDevice + public class GraphicsDeviceWindowsMetro : INativeGraphicsDevice { #region Constants private const float ColorMultiplier = 1f / 255f; @@ -96,24 +96,24 @@ namespace ANX.Framework.Windows.DX10 #endregion #region Private Members - private Device device; + private DeviceContext deviceContext; private SwapChain swapChain; private RenderTargetView renderView; private RenderTargetView renderTargetView; private DepthStencilView depthStencilView; - private SharpDX.Direct3D10.Texture2D depthStencilBuffer; - private SharpDX.Direct3D10.Texture2D backBuffer; - internal Effect_DX10 currentEffect; + private SharpDX.Direct3D11.Texture2D depthStencilBuffer; + private SharpDX.Direct3D11.Texture2D backBuffer; + internal Effect_Metro currentEffect; private VertexBuffer currentVertexBuffer; private IndexBuffer currentIndexBuffer; - private SharpDX.Direct3D10.Viewport currentViewport; + private SharpDX.Direct3D11.Viewport currentViewport; private uint lastClearColor; private SharpDX.Color4 clearColor; private bool vSyncEnabled; #endregion // Private Members - public GraphicsDeviceWindowsDX10(PresentationParameters presentationParameters) + public GraphicsDeviceWindowsMetro(PresentationParameters presentationParameters) { this.vSyncEnabled = true; @@ -130,12 +130,15 @@ namespace ANX.Framework.Windows.DX10 }; // Create Device and SwapChain + Device dxDevice; + #if DIRECTX_DEBUG_LAYER // http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx - Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain); + Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.Debug, desc, out dxDevice, out swapChain); #else - Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain); + Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out dxDevice, out swapChain); #endif + this.deviceContext = dxDevice.ImmediateContext; // Ignore all windows events Factory factory = swapChain.GetParent(); @@ -144,10 +147,10 @@ namespace ANX.Framework.Windows.DX10 ResizeRenderWindow(presentationParameters); // New RenderTargetView from the backbuffer - backBuffer = SharpDX.Direct3D10.Texture2D.FromSwapChain(swapChain, 0); - renderView = new RenderTargetView(device, backBuffer); + backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain(swapChain, 0); + renderView = new RenderTargetView(deviceContext.Device, backBuffer); - currentViewport = new SharpDX.Direct3D10.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); + currentViewport = new SharpDX.Direct3D11.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); // // create the depth stencil buffer @@ -155,32 +158,64 @@ namespace ANX.Framework.Windows.DX10 Format depthFormat = FormatConverter.Translate(presentationParameters.DepthStencilFormat); if (depthFormat != Format.Unknown) { - DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription() - { - Format = depthFormat, - }; - - Texture2DDescription depthStencilTextureDesc = new Texture2DDescription() - { - Width = presentationParameters.BackBufferWidth, - Height = presentationParameters.BackBufferHeight, - MipLevels = 1, - ArraySize = 1, - Format = depthFormat, - SampleDescription = new SampleDescription(1, 0), - Usage = ResourceUsage.Default, - BindFlags = BindFlags.DepthStencil, - CpuAccessFlags = CpuAccessFlags.None, - OptionFlags = ResourceOptionFlags.None - }; - this.depthStencilBuffer = new SharpDX.Direct3D10.Texture2D(device, depthStencilTextureDesc); - - this.depthStencilView = new DepthStencilView(device, this.depthStencilBuffer); - - Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472 + CreateDepthStencilBuffer(depthFormat); } } + private void CreateDepthStencilBuffer(Format depthFormat) + { + if (this.depthStencilBuffer != null && + this.depthStencilBuffer.Description.Format == depthFormat && + this.depthStencilBuffer.Description.Width == this.backBuffer.Description.Width && + this.depthStencilBuffer.Description.Height == this.backBuffer.Description.Height) + { + // a DepthStencilBuffer with the right format and the right size already exists -> nothing to do + return; + } + + if (this.depthStencilView != null) + { + this.depthStencilView.Dispose(); + this.depthStencilView = null; + } + + if (this.depthStencilBuffer != null) + { + this.depthStencilBuffer.Dispose(); + this.depthStencilBuffer = null; + } + + if (depthFormat == Format.Unknown) + { + // no DepthStencilBuffer to create... Old one was disposed already... + return; + } + + DepthStencilViewDescription depthStencilViewDesc = new DepthStencilViewDescription() + { + Format = depthFormat, + }; + + Texture2DDescription depthStencilTextureDesc = new Texture2DDescription() + { + Width = this.backBuffer.Description.Width, + Height = this.backBuffer.Description.Height, + MipLevels = 1, + ArraySize = 1, + Format = depthFormat, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + BindFlags = BindFlags.DepthStencil, + CpuAccessFlags = CpuAccessFlags.None, + OptionFlags = ResourceOptionFlags.None + }; + this.depthStencilBuffer = new SharpDX.Direct3D11.Texture2D(deviceContext.Device, depthStencilTextureDesc); + + this.depthStencilView = new DepthStencilView(deviceContext.Device, this.depthStencilBuffer); + + Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, ANX.Framework.Vector4.Zero, 1.0f, 0); //TODO: this workaround is working but maybe not the best solution to issue #472 + } + #region Clear public void Clear(ref Color color) { @@ -194,7 +229,7 @@ namespace ANX.Framework.Windows.DX10 clearColor.Alpha = color.A * ColorMultiplier; } - this.device.ClearRenderTargetView(this.renderTargetView != null ? this.renderTargetView : this.renderView, this.clearColor); + this.deviceContext.ClearRenderTargetView(this.renderTargetView != null ? this.renderTargetView : this.renderView, this.clearColor); } public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) @@ -209,7 +244,7 @@ namespace ANX.Framework.Windows.DX10 this.clearColor.Alpha = color.W; this.lastClearColor = 0; - this.device.ClearRenderTargetView(this.renderTargetView != null ? this.renderTargetView : this.renderView, this.clearColor); + this.deviceContext.ClearRenderTargetView(this.renderTargetView != null ? this.renderTargetView : this.renderView, this.clearColor); } if (this.depthStencilView != null) @@ -217,15 +252,15 @@ namespace ANX.Framework.Windows.DX10 if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options) { // Clear the stencil buffer - device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, depth, (byte)stencil); + deviceContext.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, depth, (byte)stencil); } else if ((options | ClearOptions.Stencil) == options) { - device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth, (byte)stencil); + deviceContext.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth, (byte)stencil); } else { - device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil); + deviceContext.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil); } } } @@ -243,42 +278,42 @@ namespace ANX.Framework.Windows.DX10 #region DrawPrimitives & DrawIndexedPrimitives public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount) { - SharpDX.Direct3D10.EffectPass pass; SharpDX.Direct3D10.EffectTechnique technique; ShaderBytecode passSignature; - SetupEffectForDraw(out pass, out technique, out passSignature); + //SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature; + //SetupEffectForDraw(out pass, out technique, out passSignature); - SetupInputLayout(passSignature); + //SetupInputLayout(passSignature); - // Prepare All the stages - device.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType); - device.Rasterizer.SetViewports(currentViewport); + //// Prepare All the stages + //deviceContext.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType); + //deviceContext.Rasterizer.SetViewports(currentViewport); - device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + //deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderView); - for (int i = 0; i < technique.Description.PassCount; ++i) - { - pass.Apply(); - device.DrawIndexed(CalculateVertexCount(primitiveType, primitiveCount), startIndex, baseVertex); - } + //for (int i = 0; i < technique.Description.PassCount; ++i) + //{ + // pass.Apply(); + // deviceContext.DrawIndexed(CalculateVertexCount(primitiveType, primitiveCount), startIndex, baseVertex); + //} } public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount) { - SharpDX.Direct3D10.EffectPass pass; SharpDX.Direct3D10.EffectTechnique technique; ShaderBytecode passSignature; - SetupEffectForDraw(out pass, out technique, out passSignature); + //SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature; + //SetupEffectForDraw(out pass, out technique, out passSignature); - SetupInputLayout(passSignature); + //SetupInputLayout(passSignature); - // Prepare All the stages - device.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType); - device.Rasterizer.SetViewports(currentViewport); + //// Prepare All the stages + //deviceContext.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType); + //deviceContext.Rasterizer.SetViewports(currentViewport); - device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + //deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderView); - for (int i = 0; i < technique.Description.PassCount; ++i) - { - pass.Apply(); - device.Draw(primitiveCount, vertexOffset); - } + //for (int i = 0; i < technique.Description.PassCount; ++i) + //{ + // pass.Apply(); + // deviceContext.Draw(primitiveCount, vertexOffset); + //} } #endregion // DrawPrimitives & DrawIndexedPrimitives @@ -286,7 +321,7 @@ namespace ANX.Framework.Windows.DX10 #region DrawInstancedPrimitives public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount) { - throw new NotImplementedException(); + deviceContext.DrawIndexedInstanced(numVertices, instanceCount, startIndex, baseVertex, 0); } #endregion // DrawInstancedPrimitives @@ -294,7 +329,26 @@ namespace ANX.Framework.Windows.DX10 #region DrawUserIndexedPrimitives public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration, IndexElementSize indexFormat) where T : struct, IVertexType { - throw new NotImplementedException(); + int vertexCount = vertexData.Length; + int indexCount = indexData.Length; + VertexBuffer_Metro vb11 = new VertexBuffer_Metro(this.deviceContext.Device, vertexDeclaration, vertexCount, BufferUsage.None); + vb11.SetData(null, vertexData); + + SharpDX.Direct3D11.VertexBufferBinding nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vb11.NativeBuffer, vertexDeclaration.VertexStride, 0); + + deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + + IndexBuffer_Metro idxMetro = new IndexBuffer_Metro(this.deviceContext.Device, indexFormat, indexCount, BufferUsage.None); + if (indexData.GetType() == typeof(Int16[])) + { + idxMetro.SetData(null, (short[])indexData); + } + else + { + idxMetro.SetData(null, (int[])indexData); + } + + DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount); } #endregion // DrawUserIndexedPrimitives @@ -302,40 +356,48 @@ namespace ANX.Framework.Windows.DX10 #region DrawUserPrimitives public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType { - throw new NotImplementedException(); + int vertexCount = vertexData.Length; + VertexBuffer_Metro vbMetro = new VertexBuffer_Metro(this.deviceContext.Device, vertexDeclaration, vertexCount, BufferUsage.None); + vbMetro.SetData(null, vertexData); + + SharpDX.Direct3D11.VertexBufferBinding nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding(vbMetro.NativeBuffer, vertexDeclaration.VertexStride, 0); + + deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + + DrawPrimitives(primitiveType, vertexOffset, primitiveCount); } #endregion // DrawUserPrimitives - internal Device NativeDevice + internal DeviceContext NativeDevice { get { - return this.device; + return this.deviceContext; } } - private void SetupEffectForDraw(out SharpDX.Direct3D10.EffectPass pass, out SharpDX.Direct3D10.EffectTechnique technique, out ShaderBytecode passSignature) - { - // get the current effect - //TODO: check for null and throw exception - Effect_DX10 effect = this.currentEffect; + //private void SetupEffectForDraw(out SharpDX.Direct3D11.EffectPass pass, out SharpDX.Direct3D11.EffectTechnique technique, out ShaderBytecode passSignature) + //{ + // // get the current effect + // //TODO: check for null and throw exception + // Effect_Metro effect = this.currentEffect; - // get the input semantic of the current effect / technique that is used - //TODO: check for null's and throw exceptions - technique = effect.NativeEffect.GetTechniqueByIndex(0); - pass = technique.GetPassByIndex(0); - passSignature = pass.Description.Signature; - } + // // get the input semantic of the current effect / technique that is used + // //TODO: check for null's and throw exceptions + // technique = effect.NativeEffect.GetTechniqueByIndex(0); + // pass = technique.GetPassByIndex(0); + // passSignature = pass.Description.Signature; + //} private void SetupInputLayout(ShaderBytecode passSignature) { // get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler //TODO: check for null and throw exception VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration; - var layout = CreateInputLayout(device, passSignature, vertexDeclaration); + var layout = CreateInputLayout(deviceContext.Device, passSignature, vertexDeclaration); - device.InputAssembler.InputLayout = layout; + deviceContext.InputAssembler.InputLayout = layout; } private int CalculateVertexCount(PrimitiveType type, int primitiveCount) @@ -371,11 +433,11 @@ namespace ANX.Framework.Windows.DX10 this.currentIndexBuffer = indexBuffer; - IndexBuffer_DX10 nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_DX10; + IndexBuffer_Metro nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_Metro; if (nativeIndexBuffer != null) { - device.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, FormatConverter.Translate(indexBuffer.IndexElementSize), 0); + deviceContext.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, FormatConverter.Translate(indexBuffer.IndexElementSize), 0); } else { @@ -392,15 +454,15 @@ namespace ANX.Framework.Windows.DX10 this.currentVertexBuffer = vertexBuffers[0].VertexBuffer; //TODO: hmmmmm, not nice :-) - SharpDX.Direct3D10.VertexBufferBinding[] nativeVertexBufferBindings = new SharpDX.Direct3D10.VertexBufferBinding[vertexBuffers.Length]; + SharpDX.Direct3D11.VertexBufferBinding[] nativeVertexBufferBindings = new SharpDX.Direct3D11.VertexBufferBinding[vertexBuffers.Length]; for (int i = 0; i < vertexBuffers.Length; i++) { ANX.Framework.Graphics.VertexBufferBinding anxVertexBufferBinding = vertexBuffers[i]; - VertexBuffer_DX10 nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_DX10; + VertexBuffer_Metro nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_Metro; if (nativeVertexBuffer != null) { - nativeVertexBufferBindings[i] = new SharpDX.Direct3D10.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, anxVertexBufferBinding.VertexBuffer.VertexDeclaration.VertexStride, anxVertexBufferBinding.VertexOffset); + nativeVertexBufferBindings[i] = new SharpDX.Direct3D11.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, anxVertexBufferBinding.VertexBuffer.VertexDeclaration.VertexStride, anxVertexBufferBinding.VertexOffset); } else { @@ -408,12 +470,12 @@ namespace ANX.Framework.Windows.DX10 } } - device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + deviceContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); } public void SetViewport(Graphics.Viewport viewport) { - this.currentViewport = new SharpDX.Direct3D10.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth); + this.currentViewport = new SharpDX.Direct3D11.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth); } /// @@ -472,15 +534,15 @@ namespace ANX.Framework.Windows.DX10 renderTargetView = null; } - device.OutputMerger.SetRenderTargets(1, new RenderTargetView[] { this.renderView }, this.depthStencilView); - device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + //TODO: device.OutputMerger.SetRenderTargets(1, new RenderTargetView[] { this.renderView }, this.depthStencilView); + deviceContext.OutputMerger.SetTargets(this.depthStencilView, this.renderView); } else { if (renderTargets.Length == 1) { RenderTarget2D renderTarget = renderTargets[0].RenderTarget as RenderTarget2D; - RenderTarget2D_DX10 nativeRenderTarget = renderTarget.NativeRenderTarget as RenderTarget2D_DX10; + RenderTarget2D_Metro nativeRenderTarget = renderTarget.NativeRenderTarget as RenderTarget2D_Metro; if (renderTarget != null) { if (renderTargetView != null) @@ -488,9 +550,11 @@ namespace ANX.Framework.Windows.DX10 renderTargetView.Dispose(); renderTargetView = null; } - this.renderTargetView = new RenderTargetView(device, ((Texture2D_DX10)nativeRenderTarget).NativeShaderResourceView.Resource); + this.renderTargetView = new RenderTargetView(deviceContext.Device, ((Texture2D_Metro)nativeRenderTarget).NativeShaderResourceView.Resource); DepthStencilView depthStencilView = null; - device.OutputMerger.SetRenderTargets(1,new RenderTargetView[] { this.renderTargetView }, depthStencilView); + deviceContext.OutputMerger.SetTargets(new RenderTargetView[] { this.renderTargetView }); + //deviceContext.OutputMerger.SetTargets(new RenderTargetView[] { this.renderTargetView }, depthStencilView); + //TODO: set depthStencilView } } else @@ -526,8 +590,8 @@ namespace ANX.Framework.Windows.DX10 swapChain.ResizeBuffers(swapChain.Description.BufferCount, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, Format.R8G8B8A8_UNorm, (int)swapChain.Description.Flags); - backBuffer = SharpDX.Direct3D10.Texture2D.FromSwapChain(swapChain, 0); - renderView = new RenderTargetView(device, backBuffer); + backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain(swapChain, 0); + renderView = new RenderTargetView(deviceContext.Device, backBuffer); } ResizeRenderWindow(presentationParameters); diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs index 6f7272ab..2696e541 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/IndexBuffer_Metro.cs @@ -4,10 +4,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.NonXNA; -using ANX.Framework.NonXNA.RenderSystem; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.Graphics; using System.Runtime.InteropServices; +using ANX.Framework.NonXNA.RenderSystem; #endregion // Using Statements @@ -58,36 +58,44 @@ using System.Runtime.InteropServices; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class IndexBuffer_DX10 : INativeIndexBuffer, IDisposable + public class IndexBuffer_Metro : INativeIndexBuffer, IDisposable { - private SharpDX.Direct3D10.Buffer buffer; + private SharpDX.Direct3D11.Buffer buffer; private IndexElementSize size; - public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) + public IndexBuffer_Metro(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) { this.size = size; //TODO: translate and use usage - GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; + GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro; + SharpDX.Direct3D11.DeviceContext context = gdMetro != null ? gdMetro.NativeDevice as SharpDX.Direct3D11.DeviceContext : null; - if (device != null) + InitializeBuffer(context.Device, size, indexCount, usage); + } + + internal IndexBuffer_Metro(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage) + { + this.size = size; + + InitializeBuffer(device, size, indexCount, usage); + } + + private void InitializeBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage) + { + BufferDescription description = new BufferDescription() { - BufferDescription description = new BufferDescription() - { - Usage = ResourceUsage.Dynamic, - SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount, - BindFlags = BindFlags.IndexBuffer, - CpuAccessFlags = CpuAccessFlags.Write, - OptionFlags = ResourceOptionFlags.None - }; + Usage = ResourceUsage.Dynamic, + SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount, + BindFlags = BindFlags.IndexBuffer, + CpuAccessFlags = CpuAccessFlags.Write, + OptionFlags = ResourceOptionFlags.None + }; - this.buffer = new SharpDX.Direct3D10.Buffer(device, description); - this.buffer.Unmap(); - } + this.buffer = new SharpDX.Direct3D11.Buffer(device, description); } public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct @@ -97,36 +105,43 @@ namespace ANX.Framework.Windows.DX10 public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct { - if (startIndex > 0 || elementCount < data.Length) - { - throw new NotImplementedException("currently starIndex and elementCount of SetData are not implemented"); - } + GraphicsDeviceWindowsMetro metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + DeviceContext context = metroGraphicsDevice.NativeDevice; //TODO: check offsetInBytes parameter for bounds etc. - GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); + GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr dataPointer = pinnedArray.AddrOfPinnedObject(); int dataLength = Marshal.SizeOf(typeof(T)) * data.Length; unsafe { - using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, false)) + using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, true)) { if (offsetInBytes > 0) { vData.Seek(offsetInBytes / (size == IndexElementSize.SixteenBits ? 2 : 4), System.IO.SeekOrigin.Begin); } - using (var d = buffer.Map(MapMode.WriteDiscard)) + SharpDX.DataStream stream; + SharpDX.DataBox box = context.MapSubresource(this.buffer, MapMode.WriteDiscard, MapFlags.None, out stream); + if (startIndex > 0 || elementCount < data.Length) { - vData.CopyTo(d); - buffer.Unmap(); + for (int i = startIndex; i < startIndex + elementCount; i++) + { + vData.Write(data[i]); + } } + else + { + vData.CopyTo(stream); + } + context.UnmapSubresource(this.buffer, 0); } } - pinnedArray.Free(); + pinnedArray.Free(); } public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct @@ -134,7 +149,7 @@ namespace ANX.Framework.Windows.DX10 SetData(graphicsDevice, 0, data, startIndex, elementCount); } - public SharpDX.Direct3D10.Buffer NativeBuffer + public SharpDX.Direct3D11.Buffer NativeBuffer { get { diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs deleted file mode 100644 index 7f23c917..00000000 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Dieser Code wurde von einem Tool generiert. -// Laufzeitversion:4.0.30319.239 -// -// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn -// der Code erneut generiert wird. -// -//------------------------------------------------------------------------------ - -namespace ANX.Framework.Windows.DX10 { - using System; - - - /// - /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. - /// - // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert - // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. - // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen - // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Metadata { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Metadata() { - } - - /// - /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ANX.Framework.Windows.DX10.Metadata", typeof(Metadata).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle - /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Sucht eine lokalisierte Zeichenfolge, die Win32NT ähnelt. - /// - public static string SupportedPlatforms { - get { - return ResourceManager.GetString("SupportedPlatforms", resourceCulture); - } - } - } -} diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx b/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx deleted file mode 100644 index c90f8c84..00000000 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Metadata.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Win32NT - - \ No newline at end of file diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs index 3ccb27a8..57412df7 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/NativeMethods.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Security; -using System.Drawing; #endregion // Using Statements @@ -56,65 +55,10 @@ using System.Drawing; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { internal sealed class NativeMethods { - [SuppressUnmanagedCodeSecurity, DllImport("user32.dll", CharSet = CharSet.Auto)] - internal static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags); - - // Nested Types - [StructLayout(LayoutKind.Sequential)] - public struct Message - { - public IntPtr hWnd; - public NativeMethods.WindowMessage msg; - public IntPtr wParam; - public IntPtr lParam; - public uint time; - public Point p; - } - - internal enum WindowMessage : uint - { - ActivateApplication = 0x1c, - Character = 0x102, - Close = 0x10, - Destroy = 2, - EnterMenuLoop = 0x211, - EnterSizeMove = 0x231, - ExitMenuLoop = 530, - ExitSizeMove = 0x232, - GetMinMax = 0x24, - KeyDown = 0x100, - KeyUp = 0x101, - LeftButtonDoubleClick = 0x203, - LeftButtonDown = 0x201, - LeftButtonUp = 0x202, - MiddleButtonDoubleClick = 0x209, - MiddleButtonDown = 0x207, - MiddleButtonUp = 520, - MouseFirst = 0x201, - MouseLast = 0x20d, - MouseMove = 0x200, - MouseWheel = 0x20a, - NonClientHitTest = 0x84, - Paint = 15, - PowerBroadcast = 0x218, - Quit = 0x12, - RightButtonDoubleClick = 0x206, - RightButtonDown = 0x204, - RightButtonUp = 0x205, - SetCursor = 0x20, - Size = 5, - SystemCharacter = 0x106, - SystemCommand = 0x112, - SystemKeyDown = 260, - SystemKeyUp = 0x105, - XButtonDoubleClick = 0x20d, - XButtonDown = 0x20b, - XButtonUp = 0x20c - } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Properties/AssemblyInfo.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Properties/AssemblyInfo.cs index 9e41f1e4..5171f797 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Properties/AssemblyInfo.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("ANX.Framework Team")] [assembly: AssemblyProduct("ANX.RenderSystem.Windows.Metro")] -[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")] +[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011, 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -24,5 +24,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.1.0")] -[assembly: AssemblyFileVersion("0.0.1.0")] +[assembly: AssemblyVersion("0.0.3.0")] +[assembly: AssemblyFileVersion("0.0.3.0")] diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs index 9fc88785..ea71956e 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/RasterizerState_Metro.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.Graphics; using ANX.Framework.NonXNA; @@ -56,13 +56,13 @@ using ANX.Framework.NonXNA; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class RasterizerState_DX10 : INativeRasterizerState + public class RasterizerState_Metro : INativeRasterizerState { #region Private Members private RasterizerStateDescription description; - private SharpDX.Direct3D10.RasterizerState nativeRasterizerState; + private SharpDX.Direct3D11.RasterizerState nativeRasterizerState; private bool nativeRasterizerStateDirty; private bool bound; @@ -70,7 +70,7 @@ namespace ANX.Framework.Windows.DX10 #endregion // Private Members - public RasterizerState_DX10() + public RasterizerState_Metro() { this.description = new RasterizerStateDescription(); @@ -79,15 +79,15 @@ namespace ANX.Framework.Windows.DX10 this.nativeRasterizerStateDirty = true; } - public void Apply(Graphics.GraphicsDevice graphicsDevice) + public void Apply(ANX.Framework.Graphics.GraphicsDevice graphicsDevice) { - GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; - Device device = gdx10.NativeDevice; + GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + DeviceContext context = gdMetro.NativeDevice; - UpdateNativeRasterizerState(device); + UpdateNativeRasterizerState(context.Device); this.bound = true; - device.Rasterizer.State = this.nativeRasterizerState; + context.Rasterizer.State = this.nativeRasterizerState; } public void Release() @@ -112,11 +112,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.CullMode CullMode + public ANX.Framework.Graphics.CullMode CullMode { set { - SharpDX.Direct3D10.CullMode cullMode = FormatConverter.Translate(value); + SharpDX.Direct3D11.CullMode cullMode = FormatConverter.Translate(value); if (description.CullMode != cullMode) { @@ -143,11 +143,11 @@ namespace ANX.Framework.Windows.DX10 } } - public Graphics.FillMode FillMode + public ANX.Framework.Graphics.FillMode FillMode { set { - SharpDX.Direct3D10.FillMode fillMode = FormatConverter.Translate(value); + SharpDX.Direct3D11.FillMode fillMode = FormatConverter.Translate(value); if (description.FillMode != fillMode) { @@ -203,10 +203,11 @@ namespace ANX.Framework.Windows.DX10 this.nativeRasterizerState = null; } - this.nativeRasterizerState = new SharpDX.Direct3D10.RasterizerState(device, ref this.description); + this.nativeRasterizerState = new SharpDX.Direct3D11.RasterizerState(device, ref this.description); this.nativeRasterizerStateDirty = false; } } } } + diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs index b518dd4f..ada8f98a 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/RenderTarget2D_Metro.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using ANX.Framework.Graphics; using ANX.Framework.NonXNA.RenderSystem; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; #endregion // Using Statements @@ -56,15 +56,15 @@ using SharpDX.Direct3D10; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class RenderTarget2D_DX10 : Texture2D_DX10, INativeRenderTarget2D, INativeTexture2D + public class RenderTarget2D_Metro : Texture2D_Metro, INativeRenderTarget2D, INativeTexture2D { #region Private Members #endregion // Private Members - public RenderTarget2D_DX10(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) + public RenderTarget2D_Metro(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) : base(graphics) { if (mipMap) @@ -74,10 +74,10 @@ namespace ANX.Framework.Windows.DX10 this.surfaceFormat = surfaceFormat; - GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice; + GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + SharpDX.Direct3D11.DeviceContext device = graphicsMetro.NativeDevice; - SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription() + SharpDX.Direct3D11.Texture2DDescription description = new SharpDX.Direct3D11.Texture2DDescription() { Width = width, Height = height, @@ -85,13 +85,13 @@ namespace ANX.Framework.Windows.DX10 ArraySize = 1, Format = FormatConverter.Translate(preferredFormat), SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), - Usage = SharpDX.Direct3D10.ResourceUsage.Default, - BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource | SharpDX.Direct3D10.BindFlags.RenderTarget, - CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.None, - OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None, + Usage = SharpDX.Direct3D11.ResourceUsage.Default, + BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource | SharpDX.Direct3D11.BindFlags.RenderTarget, + CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.None, + OptionFlags = SharpDX.Direct3D11.ResourceOptionFlags.None, }; - this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description); - this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture); + this.nativeTexture = new SharpDX.Direct3D11.Texture2D(graphicsMetro.NativeDevice.Device, description); + this.nativeShaderResourceView = new SharpDX.Direct3D11.ShaderResourceView(graphicsMetro.NativeDevice.Device, this.nativeTexture); // description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx // more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs index eefd5fa0..fbf190f7 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/SamplerState_Metro.cs @@ -2,7 +2,7 @@ using System; using ANX.Framework.Graphics; using ANX.Framework.NonXNA; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; #endregion // Using Statements @@ -53,19 +53,19 @@ using SharpDX.Direct3D10; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class SamplerState_DX10 : INativeSamplerState + public class SamplerState_Metro : INativeSamplerState { #region Private Members private SamplerStateDescription description; - private SharpDX.Direct3D10.SamplerState nativeSamplerState; + private SharpDX.Direct3D11.SamplerState nativeSamplerState; private bool nativeSamplerStateDirty; private bool bound; #endregion // Private Members - public SamplerState_DX10() + public SamplerState_Metro() { this.description = new SamplerStateDescription(); @@ -74,13 +74,15 @@ namespace ANX.Framework.Windows.DX10 public void Apply(GraphicsDevice graphicsDevice, int index) { - GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; - Device device = gdx10.NativeDevice; + throw new NotImplementedException(); - UpdateNativeSamplerState(device); - this.bound = true; + //GraphicsDeviceWindowsMetro gdm = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + //Device device = gdm.NativeDevice; - device.PixelShader.SetSampler(index, this.nativeSamplerState); + //UpdateNativeSamplerState(device); + //this.bound = true; + + //device.PixelShader.SetSampler(index, this.nativeSamplerState); } public void Release() @@ -100,7 +102,7 @@ namespace ANX.Framework.Windows.DX10 { set { - SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value); + SharpDX.Direct3D11.TextureAddressMode mode = FormatConverter.Translate(value); if (description.AddressU != mode) { @@ -114,7 +116,7 @@ namespace ANX.Framework.Windows.DX10 { set { - SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value); + SharpDX.Direct3D11.TextureAddressMode mode = FormatConverter.Translate(value); if (description.AddressV != mode) { @@ -128,7 +130,7 @@ namespace ANX.Framework.Windows.DX10 { set { - SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value); + SharpDX.Direct3D11.TextureAddressMode mode = FormatConverter.Translate(value); if (description.AddressW != mode) { @@ -142,7 +144,7 @@ namespace ANX.Framework.Windows.DX10 { set { - SharpDX.Direct3D10.Filter filter = FormatConverter.Translate(value); + SharpDX.Direct3D11.Filter filter = FormatConverter.Translate(value); if (description.Filter != filter) { @@ -207,7 +209,7 @@ namespace ANX.Framework.Windows.DX10 this.nativeSamplerState = null; } - this.nativeSamplerState = new SharpDX.Direct3D10.SamplerState(device, ref this.description); + this.nativeSamplerState = new SharpDX.Direct3D11.SamplerState(device, ref this.description); this.nativeSamplerStateDirty = false; } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs index db0e54a2..b7bb1c90 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/ShaderByteCode.cs @@ -47,7 +47,7 @@ using System; // particular purpose and non-infringement. #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { internal static class ShaderByteCode { diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs index 5e119609..4dc6df98 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/Texture2D_Metro.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.Graphics; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.NonXNA.RenderSystem; using System.IO; using System.Runtime.InteropServices; @@ -58,25 +58,25 @@ using System.Runtime.InteropServices; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class Texture2D_DX10 : INativeTexture2D + public class Texture2D_Metro : INativeTexture2D { #region Private Members - protected internal SharpDX.Direct3D10.Texture2D nativeTexture; - protected internal SharpDX.Direct3D10.ShaderResourceView nativeShaderResourceView; + protected internal SharpDX.Direct3D11.Texture2D nativeTexture; + protected internal SharpDX.Direct3D11.ShaderResourceView nativeShaderResourceView; protected internal int formatSize; protected internal SurfaceFormat surfaceFormat; protected internal GraphicsDevice graphicsDevice; #endregion // Private Members - internal Texture2D_DX10(GraphicsDevice graphicsDevice) + internal Texture2D_Metro(GraphicsDevice graphicsDevice) { this.graphicsDevice = graphicsDevice; } - public Texture2D_DX10(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount) + public Texture2D_Metro(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount) { if (mipCount > 1) { @@ -86,10 +86,10 @@ namespace ANX.Framework.Windows.DX10 this.graphicsDevice = graphicsDevice; this.surfaceFormat = surfaceFormat; - GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice; + GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + SharpDX.Direct3D11.DeviceContext context = graphicsMetro.NativeDevice; - SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription() + SharpDX.Direct3D11.Texture2DDescription description = new SharpDX.Direct3D11.Texture2DDescription() { Width = width, Height = height, @@ -97,13 +97,13 @@ namespace ANX.Framework.Windows.DX10 ArraySize = mipCount, Format = FormatConverter.Translate(surfaceFormat), SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), - Usage = SharpDX.Direct3D10.ResourceUsage.Dynamic, - BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource, - CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.Write, - OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None, + Usage = SharpDX.Direct3D11.ResourceUsage.Dynamic, + BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource, + CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.Write, + OptionFlags = SharpDX.Direct3D11.ResourceOptionFlags.None, }; - this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description); - this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture); + this.nativeTexture = new SharpDX.Direct3D11.Texture2D(context.Device, description); + this.nativeShaderResourceView = new SharpDX.Direct3D11.ShaderResourceView(context.Device, this.nativeTexture); // description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx // more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx @@ -116,7 +116,7 @@ namespace ANX.Framework.Windows.DX10 return NativeTexture.NativePointer.ToInt32(); } - internal SharpDX.Direct3D10.Texture2D NativeTexture + internal SharpDX.Direct3D11.Texture2D NativeTexture { get { @@ -136,7 +136,7 @@ namespace ANX.Framework.Windows.DX10 } } - internal SharpDX.Direct3D10.ShaderResourceView NativeShaderResourceView + internal SharpDX.Direct3D11.ShaderResourceView NativeShaderResourceView { get { @@ -172,11 +172,14 @@ namespace ANX.Framework.Windows.DX10 //TODO: handle startIndex parameter //TODO: handle elementCount parameter + GraphicsDeviceWindowsMetro metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + DeviceContext context = metroGraphicsDevice.NativeDevice; + if (this.surfaceFormat == SurfaceFormat.Color) { - int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1); - SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None); - int rowPitch = rectangle.Pitch; + int subresource = SharpDX.Direct3D11.Texture2D.CalculateSubResourceIndex(0, 0, 1); + SharpDX.DataBox rectangle = context.MapSubresource(this.nativeTexture, subresource, MapMode.WriteDiscard, MapFlags.None); + int rowPitch = rectangle.RowPitch; unsafe { @@ -203,7 +206,7 @@ namespace ANX.Framework.Windows.DX10 handle.Free(); } - this.nativeTexture.Unmap(subresource); + context.UnmapSubresource(this.nativeTexture, subresource); } else if (surfaceFormat == SurfaceFormat.Dxt5 || surfaceFormat == SurfaceFormat.Dxt3 || surfaceFormat == SurfaceFormat.Dxt1) { @@ -216,10 +219,10 @@ namespace ANX.Framework.Windows.DX10 int h = (Height + 3) >> 2; formatSize = (surfaceFormat == SurfaceFormat.Dxt1) ? 8 : 16; - int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1); - SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None); + int subresource = SharpDX.Direct3D11.Texture2D.CalculateSubResourceIndex(0, 0, 1); + SharpDX.DataBox rectangle = context.MapSubresource(this.nativeTexture, subresource, MapMode.WriteDiscard, MapFlags.None); SharpDX.DataStream ds = new SharpDX.DataStream(rectangle.DataPointer, Width * Height * 4 * 2, true, true); - int pitch = rectangle.Pitch; + int pitch = rectangle.RowPitch; int col = 0; int index = 0; // startIndex int count = data.Length; // elementCount @@ -238,8 +241,6 @@ namespace ANX.Framework.Windows.DX10 { ds.WriteByte(colorData[idx]); } - //ds.WriteRange(colorDataArray, index, count); - break; } @@ -247,7 +248,6 @@ namespace ANX.Framework.Windows.DX10 { ds.WriteByte(colorData[idx]); } - //ds.WriteRange(colorDataArray, index, actWidth); index += actWidth; count -= actWidth; @@ -255,7 +255,7 @@ namespace ANX.Framework.Windows.DX10 handle.Free(); - this.nativeTexture.Unmap(subresource); + context.UnmapSubresource(this.nativeTexture, subresource); } } else diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs index 49280e50..36699de4 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/VertexBuffer_Metro.cs @@ -4,10 +4,10 @@ using System.Collections.Generic; using System.Linq; using System.Text; using ANX.Framework.NonXNA; -using ANX.Framework.NonXNA.RenderSystem; -using SharpDX.Direct3D10; +using SharpDX.Direct3D11; using ANX.Framework.Graphics; using System.Runtime.InteropServices; +using ANX.Framework.NonXNA.RenderSystem; #endregion // Using Statements @@ -58,21 +58,31 @@ using System.Runtime.InteropServices; #endregion // License -namespace ANX.Framework.Windows.DX10 +namespace ANX.Framework.Windows.Metro { - public class VertexBuffer_DX10 : INativeVertexBuffer, IDisposable + public class VertexBuffer_Metro : INativeVertexBuffer, IDisposable { - SharpDX.Direct3D10.Buffer buffer; + SharpDX.Direct3D11.Buffer buffer; int vertexStride; - public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + public VertexBuffer_Metro(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro; + SharpDX.Direct3D11.DeviceContext context = gdMetro != null ? gdMetro.NativeDevice as SharpDX.Direct3D11.DeviceContext : null; + + InitializeBuffer(context.Device, vertexDeclaration, vertexCount, usage); + } + + internal VertexBuffer_Metro(SharpDX.Direct3D11.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + } + + private void InitializeBuffer(SharpDX.Direct3D11.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) { this.vertexStride = vertexDeclaration.VertexStride; //TODO: translate and use usage - - GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; - SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; if (device != null) { @@ -85,48 +95,49 @@ namespace ANX.Framework.Windows.DX10 OptionFlags = ResourceOptionFlags.None }; - this.buffer = new SharpDX.Direct3D10.Buffer(device, description); - this.buffer.Unmap(); + this.buffer = new SharpDX.Direct3D11.Buffer(device, description); } } public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct { + GraphicsDeviceWindowsMetro metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; + DeviceContext context = metroGraphicsDevice.NativeDevice; + //TODO: check offsetInBytes parameter for bounds etc. - GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); + GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); IntPtr dataPointer = pinnedArray.AddrOfPinnedObject(); int dataLength = Marshal.SizeOf(typeof(T)) * data.Length; unsafe { - using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, false)) + using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, true)) { if (offsetInBytes > 0) { vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin); } - using (var d = buffer.Map(MapMode.WriteDiscard)) + SharpDX.DataStream stream; + SharpDX.DataBox box = context.MapSubresource(this.buffer, MapMode.WriteDiscard, MapFlags.None, out stream); + if (startIndex > 0 || elementCount < data.Length) { - if (startIndex > 0 || elementCount < data.Length) + for (int i = startIndex; i < startIndex + elementCount; i++) { - for (int i = startIndex; i < startIndex + elementCount; i++) - { - d.Write(data[i]); - } + vData.Write(data[i]); } - else - { - vData.CopyTo(d); - } - buffer.Unmap(); } + else + { + vData.CopyTo(stream); + } + context.UnmapSubresource(this.buffer, 0); } } - pinnedArray.Free(); + pinnedArray.Free(); } public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct @@ -139,7 +150,7 @@ namespace ANX.Framework.Windows.DX10 SetData(graphicsDevice, 0, data, startIndex, elementCount); } - public SharpDX.Direct3D10.Buffer NativeBuffer + public SharpDX.Direct3D11.Buffer NativeBuffer { get { diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs index f0712769..b89107ab 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameHost.cs @@ -3,9 +3,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Windows.Forms; -using ANX.Framework.Windows.DX10; +using ANX.Framework.Windows.Metro; using ANX.Framework.Input; +using Windows.ApplicationModel.Infrastructure; #endregion // Using Statements @@ -58,7 +58,7 @@ using ANX.Framework.Input; namespace ANX.Framework { - public class WindowsGameHost : GameHost + public class WindowsGameHost : GameHost, IViewProviderFactory { private Game game; private WindowsGameWindow gameWindow; @@ -68,30 +68,18 @@ namespace ANX.Framework : base(game) { this.game = game; - //this.LockThreadToProcessor(); this.gameWindow = new WindowsGameWindow(); - Mouse.WindowHandle = this.gameWindow.Handle; //TODO: find a way to initialize all InputSystems with one Handle - Keyboard.WindowHandle = this.gameWindow.Handle; - //TouchPanel.WindowHandle = this.gameWindow.Handle; - //this.gameWindow.IsMouseVisible = game.IsMouseVisible; - this.gameWindow.Activated += new EventHandler(this.GameWindowActivated); - this.gameWindow.Deactivated += new EventHandler(this.GameWindowDeactivated); - //this.gameWindow.Suspend += new EventHandler(this.GameWindowSuspend); - //this.gameWindow.Resume += new EventHandler(this.GameWindowResume); - + } + + public IViewProvider CreateViewProvider() + { + return gameWindow; } public override void Run() { - Application.Idle += new EventHandler(this.ApplicationIdle); - Application.Run(this.gameWindow.Form); - Application.Idle -= this.ApplicationIdle; - } - - public void RunOneFrame() - { - //this.gameWindow.Tick(); - base.OnIdle(); + //Windows.ApplicationModel.Core.CoreApplication.Run(this); + throw new NotImplementedException(); } public override GameWindow Window @@ -106,31 +94,81 @@ namespace ANX.Framework { this.exitRequested = true; } - - private void GameWindowActivated(object sender, EventArgs e) - { - base.OnActivated(); - } - - private void GameWindowDeactivated(object sender, EventArgs e) - { - base.OnDeactivated(); - } - - private void ApplicationIdle(object sender, EventArgs e) - { - NativeMethods.Message message; - while (!NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 0)) - { - if (this.exitRequested) - { - this.gameWindow.Close(); - } - else - { - this.RunOneFrame(); - } - } - } } + + //public class WindowsGameHost : GameHost, IViewProvider + //{ + // private Game game; + // private WindowsGameWindow gameWindow; + // private bool exitRequested; + + // public WindowsGameHost(Game game) + // : base(game) + // { + // this.game = game; + // //this.LockThreadToProcessor(); + // this.gameWindow = new WindowsGameWindow(); + // Mouse.WindowHandle = this.gameWindow.Handle; //TODO: find a way to initialize all InputSystems with one Handle + // Keyboard.WindowHandle = this.gameWindow.Handle; + // //TouchPanel.WindowHandle = this.gameWindow.Handle; + // //this.gameWindow.IsMouseVisible = game.IsMouseVisible; + // this.gameWindow.Activated += new EventHandler(this.GameWindowActivated); + // this.gameWindow.Deactivated += new EventHandler(this.GameWindowDeactivated); + // //this.gameWindow.Suspend += new EventHandler(this.GameWindowSuspend); + // //this.gameWindow.Resume += new EventHandler(this.GameWindowResume); + + // } + + // public override void Run() + // { + // Application.Idle += new EventHandler(this.ApplicationIdle); + // Application.Run(this.gameWindow.Form); + // Application.Idle -= this.ApplicationIdle; + // } + + // public void RunOneFrame() + // { + // //this.gameWindow.Tick(); + // base.OnIdle(); + // } + + // public override GameWindow Window + // { + // get + // { + // return this.gameWindow; + // } + // } + + // public override void Exit() + // { + // this.exitRequested = true; + // } + + // private void GameWindowActivated(object sender, EventArgs e) + // { + // base.OnActivated(); + // } + + // private void GameWindowDeactivated(object sender, EventArgs e) + // { + // base.OnDeactivated(); + // } + + // private void ApplicationIdle(object sender, EventArgs e) + // { + // NativeMethods.Message message; + // while (!NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 0)) + // { + // if (this.exitRequested) + // { + // this.gameWindow.Close(); + // } + // else + // { + // this.RunOneFrame(); + // } + // } + // } + //} } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs index 7493657f..7eaa16fa 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/WindowsGameWindow.cs @@ -3,8 +3,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Windows.Forms; -using SharpDX.Windows; +using Windows.ApplicationModel.Core; +using Windows.ApplicationModel.Infrastructure; +using Windows.UI.Core; #endregion // Using Statements @@ -57,22 +58,42 @@ using SharpDX.Windows; namespace ANX.Framework { - internal class WindowsGameWindow : GameWindow + internal class WindowsGameWindow : GameWindow, IViewProvider { #region Private Members - private RenderForm gameWindow; + private CoreWindow gameWindow; #endregion // Private Members internal WindowsGameWindow() { - this.gameWindow = new RenderForm("ANX.Framework"); + //this.gameWindow = new RenderForm("ANX.Framework"); - this.gameWindow.Width = 800; - this.gameWindow.Height = 480; + //this.gameWindow.Width = 800; + //this.gameWindow.Height = 480; + + //this.gameWindow.MaximizeBox = false; + //this.gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D; + } + + public void Initialize(CoreWindow window, CoreApplicationView applicationView) + { + this.gameWindow = window; + } + + public void Load(string entryPoint) + { + + } + + public void Run() + { + System.Diagnostics.Debugger.Break(); + } + + public void Uninitialize() + { - this.gameWindow.MaximizeBox = false; - this.gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D; } public void Close() @@ -83,7 +104,7 @@ namespace ANX.Framework } } - public Form Form + public CoreWindow Form { get { @@ -95,7 +116,7 @@ namespace ANX.Framework { get { - return gameWindow.Handle; + return IntPtr.Zero; } } @@ -103,7 +124,8 @@ namespace ANX.Framework { get { - return gameWindow.WindowState == FormWindowState.Minimized; + //TODO: return gameWindow.WindowState == FormWindowState.Minimized; + return false; } } @@ -119,25 +141,19 @@ namespace ANX.Framework protected override void SetTitle(string title) { - this.gameWindow.Text = title; + //TODO: this.gameWindow.Text = title; } public override bool AllowUserResizing { get { - return gameWindow.FormBorderStyle == FormBorderStyle.Sizable; + //return gameWindow.FormBorderStyle == FormBorderStyle.Sizable; + return false; } set { - if (value) - { - gameWindow.FormBorderStyle = FormBorderStyle.Sizable; - } - else - { - gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D; - } + throw new NotSupportedException("AllowUserResizing can not be changed in RenderSystem Metro"); } } @@ -145,7 +161,12 @@ namespace ANX.Framework { get { - return new Rectangle(this.gameWindow.ClientRectangle.Left, this.gameWindow.ClientRectangle.Top, this.gameWindow.ClientRectangle.Width, this.gameWindow.ClientRectangle.Height); + //TODO: cache this to prevent four castings on every access + //TODO: check if double type bounds are really castable to int + return new Rectangle((int)this.gameWindow.Bounds.Left, + (int)this.gameWindow.Bounds.Top, + (int)this.gameWindow.Bounds.Width, + (int)this.gameWindow.Bounds.Height); } } diff --git a/Samples/MultiRenderTarget/Game1.cs b/Samples/MultiRenderTarget/Game1.cs index 282a4014..e1aaea56 100644 --- a/Samples/MultiRenderTarget/Game1.cs +++ b/Samples/MultiRenderTarget/Game1.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; +using ANX.Framework; +using ANX.Framework.Content; +using ANX.Framework.Graphics; +using ANX.Framework.Input; #endregion #region License @@ -57,7 +57,7 @@ using Microsoft.Xna.Framework.Input; namespace MultiRenderTarget { - public class Game1 : Microsoft.Xna.Framework.Game + public class Game1 : ANX.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; @@ -65,8 +65,6 @@ namespace MultiRenderTarget Effect effect; RenderTarget2D[] renderTargets; - Color[] backgroundColors = new Color[] { Color.Red, Color.Green, Color.Blue, Color.DarkMagenta }; - VertexPositionColor[] primitives; public Game1() diff --git a/Samples/MultiRenderTarget/MultiRenderTarget.csproj b/Samples/MultiRenderTarget/MultiRenderTarget.csproj index d322b4e9..7f5e96c0 100644 --- a/Samples/MultiRenderTarget/MultiRenderTarget.csproj +++ b/Samples/MultiRenderTarget/MultiRenderTarget.csproj @@ -60,10 +60,6 @@ true - - - - @@ -106,9 +102,29 @@ - - {97185A92-077D-4498-8B6A-8BFF04079044} - ANX.MediaSystem.Windows.OpenAL + + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35} + ANX.Framework + + + {60D08399-244F-46A3-91F1-4CFD26D961A3} + ANX.InputDevices.Windows.XInput + + + {49066074-3B7B-4A55-B122-6BD33AB73558} + ANX.InputSystem.Standard + + + {5BE49183-2F6F-4527-AC90-D816911FCF90} + ANX.Framework.Windows.DX10 + + + {B30DE9C2-0926-46B6-8351-9AF276C472D5} + ANX.RenderSystem.Windows.DX11 + + + {6A582788-C4D2-410C-96CD-177F75712D65} + ANX.SoundSystem.Windows.XAudio {FA6E229D-4504-47B1-8A23-2D3FCC13F778} diff --git a/Samples/SampleContent/Effects/MRT.fx b/Samples/SampleContent/Effects/MRT.fx index 4f9a0fae..9220a4a9 100644 --- a/Samples/SampleContent/Effects/MRT.fx +++ b/Samples/SampleContent/Effects/MRT.fx @@ -54,10 +54,10 @@ struct VertexShaderOutput struct PixelShaderOutput { - float4 Color0 : COLOR0; - float4 Color1 : COLOR1; - float4 Color2 : COLOR2; - float4 Color3 : COLOR3; + float4 Color0 : SV_TARGET0; + float4 Color1 : SV_TARGET1; + float4 Color2 : SV_TARGET2; + float4 Color3 : SV_TARGET3; }; VertexShaderOutput VertexShaderFunction(VertexShaderInput input) @@ -79,13 +79,13 @@ PixelShaderOutput PixelShaderFunction(VertexShaderOutput input) return output; } -technique Technique1 +technique10 Technique1 { pass Pass1 { // TODO: Stellen Sie Renderstates hier ein. - VertexShader = compile vs_2_0 VertexShaderFunction(); - PixelShader = compile ps_2_0 PixelShaderFunction(); + VertexShader = compile vs_4_0 VertexShaderFunction(); + PixelShader = compile ps_4_0 PixelShaderFunction(); } } diff --git a/Samples/SampleContent/SampleContent.contentproj b/Samples/SampleContent/SampleContent.contentproj index c89fa710..329b7afa 100644 --- a/Samples/SampleContent/SampleContent.contentproj +++ b/Samples/SampleContent/SampleContent.contentproj @@ -115,7 +115,8 @@ MRT EffectImporter - EffectProcessor + AnxEffectProcessor + DX10_HLSL