From 84e019207b5827b16c949cab3c782b408955788d Mon Sep 17 00:00:00 2001 From: "F.Fischer" Date: Tue, 10 Jul 2012 00:29:01 +0200 Subject: [PATCH] -additional classes added -SpriteBatch update to support more drawing functions -Components added --- .../Microsoft Permissive License.rtf.meta | 2 + .../XNAEmulator/DrawableGameComponent.cs | 116 ++++++++++++++ .../XNAEmulator/DrawableGameComponent.cs.meta | 7 + Assets/Scripts/XNAEmulator/Game/Game.cs | 13 +- Assets/Scripts/XNAEmulator/GameComponent.cs | 142 ++++++++++++++++++ .../Scripts/XNAEmulator/GameComponent.cs.meta | 7 + .../XNAEmulator/GameComponentCollection.cs | 106 +++++++++++++ .../GameComponentCollection.cs.meta | 7 + .../GameComponentCollectionEventArgs.cs | 63 ++++++++ .../GameComponentCollectionEventArgs.cs.meta | 7 + .../Scripts/XNAEmulator/Graphics/Effect.meta | 2 + .../XNAEmulator/Graphics/Effect/Effect.cs | 60 ++++++++ .../Graphics/Effect/Effect.cs.meta | 7 + .../XNAEmulator/Graphics/GraphicsResource.cs | 86 +++++++++++ .../Graphics/GraphicsResource.cs.meta | 7 + .../XNAEmulator/Graphics/SpriteBatch.cs | 105 ++++++++++++- .../Scripts/XNAEmulator/Graphics/States.meta | 2 + .../XNAEmulator/Graphics/States/BlendState.cs | 138 +++++++++++++++++ .../Graphics/States/BlendState.cs.meta | 7 + .../Graphics/States/DepthStencilState.cs | 74 +++++++++ .../Graphics/States/DepthStencilState.cs.meta | 7 + .../Graphics/States/RasterizerState.cs | 46 ++++++ .../Graphics/States/RasterizerState.cs.meta | 7 + .../Graphics/States/SamplerState.cs | 116 ++++++++++++++ .../Graphics/States/SamplerState.cs.meta | 7 + Assets/Scripts/XNAEmulator/IDrawable.cs | 56 +++++++ Assets/Scripts/XNAEmulator/IDrawable.cs.meta | 7 + Assets/Scripts/XNAEmulator/IGameComponent.cs | 48 ++++++ .../XNAEmulator/IGameComponent.cs.meta | 7 + Assets/Scripts/XNAEmulator/IUpdateable.cs | 65 ++++++++ .../Scripts/XNAEmulator/IUpdateable.cs.meta | 7 + .../Microsoft Permissive License.rtf.meta | 2 + ProjectSettings/ProjectSettings.asset | Bin 11164 -> 11536 bytes 33 files changed, 1326 insertions(+), 7 deletions(-) create mode 100644 Assets/Resources/Content/Microsoft Permissive License.rtf.meta create mode 100644 Assets/Scripts/XNAEmulator/DrawableGameComponent.cs create mode 100644 Assets/Scripts/XNAEmulator/DrawableGameComponent.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/GameComponent.cs create mode 100644 Assets/Scripts/XNAEmulator/GameComponent.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/GameComponentCollection.cs create mode 100644 Assets/Scripts/XNAEmulator/GameComponentCollection.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs create mode 100644 Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/Effect.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs create mode 100644 Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs create mode 100644 Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs create mode 100644 Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/IDrawable.cs create mode 100644 Assets/Scripts/XNAEmulator/IDrawable.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/IGameComponent.cs create mode 100644 Assets/Scripts/XNAEmulator/IGameComponent.cs.meta create mode 100644 Assets/Scripts/XNAEmulator/IUpdateable.cs create mode 100644 Assets/Scripts/XNAEmulator/IUpdateable.cs.meta create mode 100644 Assets/Scripts/XNAGame/Microsoft Permissive License.rtf.meta diff --git a/Assets/Resources/Content/Microsoft Permissive License.rtf.meta b/Assets/Resources/Content/Microsoft Permissive License.rtf.meta new file mode 100644 index 0000000..b8d8dad --- /dev/null +++ b/Assets/Resources/Content/Microsoft Permissive License.rtf.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: b5d2568b352f8554d9f166fb8089199b diff --git a/Assets/Scripts/XNAEmulator/DrawableGameComponent.cs b/Assets/Scripts/XNAEmulator/DrawableGameComponent.cs new file mode 100644 index 0000000..4e1f44e --- /dev/null +++ b/Assets/Scripts/XNAEmulator/DrawableGameComponent.cs @@ -0,0 +1,116 @@ +#region License +/* +Microsoft Public License (Ms-PL) +MonoGame - Copyright © 2009 The MonoGame Team + +All rights reserved. + +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 + +using System; + +namespace Microsoft.Xna.Framework +{ + public class DrawableGameComponent : GameComponent, IDrawable + { + private bool _isInitialized; + private bool _isVisible; + private int _drawOrder; + + public event EventHandler DrawOrderChanged; + public event EventHandler VisibleChanged; + + public DrawableGameComponent(Game game) + : base(game) + { + Visible = true; + } + + public override void Initialize() + { + if (!_isInitialized) + { + _isInitialized = true; + LoadContent(); + } + } + + protected virtual void LoadContent() + { + } + + protected virtual void UnloadContent() + { + } + + #region IDrawable Members + + public int DrawOrder + { + get { return _drawOrder; } + set + { + _drawOrder = value; + if(DrawOrderChanged != null) + DrawOrderChanged(this, null); + + OnDrawOrderChanged(this, null); + } + } + + public bool Visible + { + get { return _isVisible; } + set + { + if (_isVisible != value) + { + _isVisible = value; + + var handler = VisibleChanged; + if (handler != null) + handler(this, EventArgs.Empty); + + OnVisibleChanged(this, EventArgs.Empty); + } + } + } + + public virtual void Draw(GameTime gameTime) { } + protected virtual void OnVisibleChanged(object sender, EventArgs args) { } + protected virtual void OnDrawOrderChanged(object sender, EventArgs args) { } + + #endregion + } +} diff --git a/Assets/Scripts/XNAEmulator/DrawableGameComponent.cs.meta b/Assets/Scripts/XNAEmulator/DrawableGameComponent.cs.meta new file mode 100644 index 0000000..55a3cc1 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/DrawableGameComponent.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4f5da85797380c147bc9b2325bbf9f77 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Game/Game.cs b/Assets/Scripts/XNAEmulator/Game/Game.cs index 352abbb..f2c1382 100644 --- a/Assets/Scripts/XNAEmulator/Game/Game.cs +++ b/Assets/Scripts/XNAEmulator/Game/Game.cs @@ -9,6 +9,7 @@ namespace Microsoft.Xna.Framework { public class Game : IDisposable { + private GameComponentCollection _components; Content.ContentManager content; GraphicsDevice graphicsDevice; DrawQueue drawQueue; @@ -43,12 +44,20 @@ namespace Microsoft.Xna.Framework { content = new ContentManager(null, ""); + _components = new GameComponentCollection(); } protected virtual void Update(GameTime gameTime) - { - + { } + + public GameComponentCollection Components + { + get + { + return this._components; + } + } protected virtual void Draw(GameTime gameTime) { diff --git a/Assets/Scripts/XNAEmulator/GameComponent.cs b/Assets/Scripts/XNAEmulator/GameComponent.cs new file mode 100644 index 0000000..71fbf7f --- /dev/null +++ b/Assets/Scripts/XNAEmulator/GameComponent.cs @@ -0,0 +1,142 @@ +#region License +/* +Microsoft Public License (Ms-PL) +MonoGame - Copyright © 2009 The MonoGame Team + +All rights reserved. + +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 + +using System; + +namespace Microsoft.Xna.Framework +{ + public class GameComponent : IGameComponent, IUpdateable, IComparable, IDisposable + { + Game _game; + int _updateOrder; + bool _enabled; + public event EventHandler UpdateOrderChanged; + public event EventHandler EnabledChanged; + public GameComponent(Game game) + { + _game = game; + Enabled = true; + } + + public Game Game + { + get + { + return _game; + } + } + + public virtual void Initialize() + { + } + + public virtual void Update(GameTime gameTime) + { + } + + public Graphics.GraphicsDevice GraphicsDevice + { + get + { + return _game.GraphicsDevice; + } + } + + public bool Enabled + { + get { return _enabled; } + set + { + _enabled = value; + Raise(EnabledChanged, EventArgs.Empty); + OnEnabledChanged(this, null); + } + } + + public int UpdateOrder + { + get { return _updateOrder; } + set + { + _updateOrder = value; + Raise(UpdateOrderChanged, EventArgs.Empty); + OnUpdateOrderChanged(this, null); + } + } + + private void Raise(EventHandler handler, EventArgs e) + { + if (handler != null) + handler(this, e); + } + + protected virtual void OnUpdateOrderChanged(object sender, EventArgs args) + { + } + + protected virtual void OnEnabledChanged(object sender, EventArgs args) + { + } + + /// + /// Shuts down the component. + /// + protected virtual void Dispose(bool disposing) + { + } + + /// + /// Shuts down the component. + /// + public virtual void Dispose() + { + Dispose(true); + } + + #region IComparable Members + + public int CompareTo(GameComponent other) + { + return other.UpdateOrder - this.UpdateOrder; + } + + #endregion + } +} diff --git a/Assets/Scripts/XNAEmulator/GameComponent.cs.meta b/Assets/Scripts/XNAEmulator/GameComponent.cs.meta new file mode 100644 index 0000000..ba1ca6b --- /dev/null +++ b/Assets/Scripts/XNAEmulator/GameComponent.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6effffe4d4b43174bbec9f73f7159caf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/GameComponentCollection.cs b/Assets/Scripts/XNAEmulator/GameComponentCollection.cs new file mode 100644 index 0000000..cb5f484 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/GameComponentCollection.cs @@ -0,0 +1,106 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// 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 + +using System; +using System.Collections.ObjectModel; + +namespace Microsoft.Xna.Framework +{ + public sealed class GameComponentCollection : Collection + { + public event EventHandler ComponentAdded; + + public event EventHandler ComponentRemoved; + + protected override void ClearItems() + { + for (int i = 0; i < base.Count; i++) + { + this.OnComponentRemoved(new GameComponentCollectionEventArgs(base[i])); + } + base.ClearItems(); + } + + protected override void InsertItem(int index, IGameComponent item) + { + if (base.IndexOf(item) != -1) + { + throw new ArgumentException("Cannot Add Same Component Multiple Times"); + } + base.InsertItem(index, item); + if (item != null) + { + this.OnComponentAdded(new GameComponentCollectionEventArgs(item)); + } + } + + private void OnComponentAdded(GameComponentCollectionEventArgs eventArgs) + { + if (this.ComponentAdded != null) + { + this.ComponentAdded(this, eventArgs); + } + } + + private void OnComponentRemoved(GameComponentCollectionEventArgs eventArgs) + { + if (this.ComponentRemoved != null) + { + this.ComponentRemoved(this, eventArgs); + } + } + + protected override void RemoveItem(int index) + { + IGameComponent gameComponent = base[index]; + base.RemoveItem(index); + if (gameComponent != null) + { + this.OnComponentRemoved(new GameComponentCollectionEventArgs(gameComponent)); + } + } + + protected override void SetItem(int index, IGameComponent item) + { + throw new NotSupportedException(); + } + } +} + diff --git a/Assets/Scripts/XNAEmulator/GameComponentCollection.cs.meta b/Assets/Scripts/XNAEmulator/GameComponentCollection.cs.meta new file mode 100644 index 0000000..f4ab894 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/GameComponentCollection.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 98c482b2094b63a4883be38d30f3e1e7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs b/Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs new file mode 100644 index 0000000..be2c140 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs @@ -0,0 +1,63 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// 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 + +using System; + +namespace Microsoft.Xna.Framework +{ + public class GameComponentCollectionEventArgs : EventArgs + { + private IGameComponent _gameComponent; + + public GameComponentCollectionEventArgs(IGameComponent gameComponent) + { + _gameComponent = gameComponent; + } + + public IGameComponent GameComponent + { + get + { + return _gameComponent; + } + } + } +} + diff --git a/Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs.meta b/Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs.meta new file mode 100644 index 0000000..c5fa50c --- /dev/null +++ b/Assets/Scripts/XNAEmulator/GameComponentCollectionEventArgs.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 90c5eeb40cf5ab54abd604dfbcb717e3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Graphics/Effect.meta b/Assets/Scripts/XNAEmulator/Graphics/Effect.meta new file mode 100644 index 0000000..d33257d --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/Effect.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1bc05554bc1744041a5be8169895e0c1 diff --git a/Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs b/Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs new file mode 100644 index 0000000..1041c76 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs @@ -0,0 +1,60 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// 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 +// +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Linq; +using System.Reflection; + +namespace Microsoft.Xna.Framework.Graphics +{ + public class Effect : GraphicsResource + { + internal Effect(GraphicsDevice graphicsDevice) + { + if (graphicsDevice == null) + throw new ArgumentNullException ("Graphics Device Cannot Be Null"); + + this.graphicsDevice = graphicsDevice; + } + } +} diff --git a/Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs.meta b/Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs.meta new file mode 100644 index 0000000..da8a26b --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/Effect/Effect.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d2e4facfb8a731f4e94e64dd64525246 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs b/Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs new file mode 100644 index 0000000..05fe62f --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs @@ -0,0 +1,86 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// 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 +// +using System; +namespace Microsoft.Xna.Framework.Graphics +{ + public abstract class GraphicsResource : IDisposable + { + private bool disposed; + + protected GraphicsDevice graphicsDevice; + + protected virtual void DoDisposing(EventArgs e) + { + if (Disposing != null) + Disposing(this, e); + + disposed = true; + } + + public virtual void Dispose() + { + DoDisposing(EventArgs.Empty); + } + + public event EventHandler Disposing; + + public GraphicsDevice GraphicsDevice + { + get + { + return graphicsDevice; + } + } + + public bool IsDisposed + { + get + { + return disposed; + } + } + + public string Name { get; set; } + + public Object Tag { get; set; } + } +} + diff --git a/Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs.meta b/Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs.meta new file mode 100644 index 0000000..6a5c2f3 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/GraphicsResource.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f37e48495b25fa341a6cb54c0a207312 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Graphics/SpriteBatch.cs b/Assets/Scripts/XNAEmulator/Graphics/SpriteBatch.cs index 2ca0f69..879c2c6 100644 --- a/Assets/Scripts/XNAEmulator/Graphics/SpriteBatch.cs +++ b/Assets/Scripts/XNAEmulator/Graphics/SpriteBatch.cs @@ -5,29 +5,124 @@ using System.Text; namespace Microsoft.Xna.Framework.Graphics { - public class SpriteBatch + public class SpriteBatch : GraphicsResource { private GraphicsDevice graphicsDevice; + + Vector2 texCoordTL = new Vector2 (0,0); + Vector2 texCoordBR = new Vector2 (0,0); + Rectangle tempRect = new Rectangle (0,0,0,0); public SpriteBatch(GraphicsDevice graphicsDevice) { + if (graphicsDevice == null) { + throw new ArgumentException ("graphicsDevice"); + } + // TODO: Complete member initialization this.graphicsDevice = graphicsDevice; } - internal void Begin() - { + + public void Begin () + { + Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity); + } - } + public void Begin (SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect, Matrix transformMatrix) + { +/* + // defaults + _sortMode = sortMode; + _blendState = blendState ?? BlendState.AlphaBlend; + _samplerState = samplerState ?? SamplerState.LinearClamp; + _depthStencilState = depthStencilState ?? DepthStencilState.None; + _rasterizerState = rasterizerState ?? RasterizerState.CullCounterClockwise; + + _effect = effect; + + _matrix = transformMatrix; + + + if (sortMode == SpriteSortMode.Immediate) { + //setup things now so a user can chage them + Setup(); + } +*/ + } + + public void Begin (SpriteSortMode sortMode, BlendState blendState) + { + Begin (sortMode, blendState, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, null, Matrix.Identity); + } + + public void Begin (SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState) + { + Begin (sortMode, blendState, samplerState, depthStencilState, rasterizerState, null, Matrix.Identity); + } + + public void Begin (SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect) + { + Begin (sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, Matrix.Identity); + } internal void End() { - } internal void Draw(Texture2D texture2D, Vector2 position, Nullable source, Color color, float p, Vector2 Origin, float p_2, SpriteEffects spriteEffects, float p_3) { graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture2D, position, source, color.ToVector4(), Origin, spriteEffects)); } + + //TODO: Draw stretching + internal void Draw(Texture2D texture2D, Nullable source, Color color) + { + graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture2D, Vector2.Zero, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None)); + } + + //Draw texture section + internal void Draw(Texture2D texture2D, Vector2 position, Nullable source, Color color) + { + graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture2D, position, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None)); + } + + //TODO: + internal void Draw (Texture2D texture, Nullable source, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effect, float depth) + { +/* + if (sourceRectangle.HasValue) { + tempRect = sourceRectangle.Value; + } else { + tempRect.X = 0; + tempRect.Y = 0; + tempRect.Width = texture.Width; + tempRect.Height = texture.Height; + } + + texCoordTL.X = tempRect.X / (float)texture.Width; + texCoordTL.Y = tempRect.Y / (float)texture.Height; + texCoordBR.X = (tempRect.X + tempRect.Width) / (float)texture.Width; + texCoordBR.Y = (tempRect.Y + tempRect.Height) / (float)texture.Height; + + if ((effect & SpriteEffects.FlipVertically) != 0) { + float temp = texCoordBR.Y; + texCoordBR.Y = texCoordTL.Y; + texCoordTL.Y = temp; + } + if ((effect & SpriteEffects.FlipHorizontally) != 0) { + float temp = texCoordBR.X; + texCoordBR.X = texCoordTL.X; + texCoordTL.X = temp; + } +*/ + graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture, Vector2.Zero, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None)); + } + + //TODO: + internal void Draw (Texture2D texture, Nullable source, Rectangle? sourceRectangle, Color color) + { + graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture, Vector2.Zero, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None)); + } internal void Draw(Texture2D texture2D, Vector2 position, Color color) { diff --git a/Assets/Scripts/XNAEmulator/Graphics/States.meta b/Assets/Scripts/XNAEmulator/Graphics/States.meta new file mode 100644 index 0000000..74b2bb4 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f20fbbe0311148647b9c5587258d26d1 diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs b/Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs new file mode 100644 index 0000000..9c4e50b --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs @@ -0,0 +1,138 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// 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 +// +using System; +using System.Diagnostics; + +namespace Microsoft.Xna.Framework.Graphics +{ + public class BlendState : GraphicsResource + { + // TODO: We should be asserting if the state has + // been changed after it has been bound to the device! + + public BlendFunction AlphaBlendFunction { get; set; } + public Blend AlphaDestinationBlend { get; set; } + public Blend AlphaSourceBlend { get; set; } + public Color BlendFactor { get; set; } + public BlendFunction ColorBlendFunction { get; set; } + public Blend ColorDestinationBlend { get; set; } + public Blend ColorSourceBlend { get; set; } + public ColorWriteChannels ColorWriteChannels { get; set; } + public ColorWriteChannels ColorWriteChannels1 { get; set; } + public ColorWriteChannels ColorWriteChannels2 { get; set; } + public ColorWriteChannels ColorWriteChannels3 { get; set; } + public int MultiSampleMask { get; set; } + + public static readonly BlendState Additive; + public static readonly BlendState AlphaBlend; + public static readonly BlendState NonPremultiplied; + public static readonly BlendState Opaque; + + public BlendState() + { + AlphaBlendFunction = BlendFunction.Add; + AlphaDestinationBlend = Blend.Zero; + AlphaSourceBlend = Blend.One; + BlendFactor = Color.White; + ColorBlendFunction = BlendFunction.Add; + ColorDestinationBlend = Blend.Zero; + ColorSourceBlend = Blend.One; + ColorWriteChannels = ColorWriteChannels.All; + ColorWriteChannels1 = ColorWriteChannels.All; + ColorWriteChannels2 = ColorWriteChannels.All; + ColorWriteChannels3 = ColorWriteChannels.All; + MultiSampleMask = Int32.MaxValue; + } + + static BlendState() + { + Additive = new BlendState() + { + ColorSourceBlend = Blend.SourceAlpha, + AlphaSourceBlend = Blend.SourceAlpha, + ColorDestinationBlend = Blend.One, + AlphaDestinationBlend = Blend.One + }; + + AlphaBlend = new BlendState() + { + ColorSourceBlend = Blend.One, + AlphaSourceBlend = Blend.One, + ColorDestinationBlend = Blend.InverseSourceAlpha, + AlphaDestinationBlend = Blend.InverseSourceAlpha + }; + + NonPremultiplied = new BlendState() + { + ColorSourceBlend = Blend.SourceAlpha, + AlphaSourceBlend = Blend.SourceAlpha, + ColorDestinationBlend = Blend.InverseSourceAlpha, + AlphaDestinationBlend = Blend.InverseSourceAlpha + }; + + Opaque = new BlendState() + { + ColorSourceBlend = Blend.One, + AlphaSourceBlend = Blend.One, + ColorDestinationBlend = Blend.Zero, + AlphaDestinationBlend = Blend.Zero + }; + } + + public override string ToString () + { + string blendStateName; + + if(this == BlendState.Additive) + blendStateName = "Additive"; + else if (this == BlendState.AlphaBlend) + blendStateName = "AlphaBlend"; + else if (this == BlendState.NonPremultiplied) + blendStateName = "NonPremultiplied"; + else + blendStateName = "Opaque"; + + + return string.Format("{0}.{1}", base.ToString(), blendStateName); + } + } +} + diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs.meta b/Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs.meta new file mode 100644 index 0000000..92e373e --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/BlendState.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 20ab82e73bf7a0346bd3019540d9f860 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs b/Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs new file mode 100644 index 0000000..ef2a099 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs @@ -0,0 +1,74 @@ +using System; +using System.Diagnostics; + +namespace Microsoft.Xna.Framework.Graphics +{ + public class DepthStencilState : GraphicsResource + { + // TODO: We should be asserting if the state has + // been changed after it has been bound to the device! + + public bool DepthBufferEnable { get; set; } + public bool DepthBufferWriteEnable { get; set; } + public StencilOperation CounterClockwiseStencilDepthBufferFail { get; set; } + public StencilOperation CounterClockwiseStencilFail { get; set; } + public CompareFunction CounterClockwiseStencilFunction { get; set; } + public StencilOperation CounterClockwiseStencilPass { get; set; } + public CompareFunction DepthBufferFunction { get; set; } + public int ReferenceStencil { get; set; } + public StencilOperation StencilDepthBufferFail { get; set; } + public bool StencilEnable { get; set; } + public StencilOperation StencilFail { get; set; } + public CompareFunction StencilFunction { get; set; } + public int StencilMask { get; set; } + public StencilOperation StencilPass { get; set; } + public int StencilWriteMask { get; set; } + public bool TwoSidedStencilMode { get; set; } + + public DepthStencilState () + { + DepthBufferEnable = true; + DepthBufferWriteEnable = true; + DepthBufferFunction = CompareFunction.LessEqual; + StencilEnable = false; + StencilFunction = CompareFunction.Always; + StencilPass = StencilOperation.Keep; + StencilFail = StencilOperation.Keep; + StencilDepthBufferFail = StencilOperation.Keep; + TwoSidedStencilMode = false; + CounterClockwiseStencilFunction = CompareFunction.Always; + CounterClockwiseStencilFail = StencilOperation.Keep; + CounterClockwiseStencilPass = StencilOperation.Keep; + CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep; + StencilMask = Int32.MaxValue; + StencilWriteMask = Int32.MaxValue; + ReferenceStencil = 0; + } + + public static readonly DepthStencilState Default; + public static readonly DepthStencilState DepthRead; + public static readonly DepthStencilState None; + + static DepthStencilState () + { + Default = new DepthStencilState () + { + DepthBufferEnable = true, + DepthBufferWriteEnable = true + }; + + DepthRead = new DepthStencilState () + { + DepthBufferEnable = true, + DepthBufferWriteEnable = false + }; + + None = new DepthStencilState () + { + DepthBufferEnable = false, + DepthBufferWriteEnable = false + }; + } + } +} + diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs.meta b/Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs.meta new file mode 100644 index 0000000..37720ed --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/DepthStencilState.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ce475ce415377b54d9116017c80b66f5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs b/Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs new file mode 100644 index 0000000..a70611e --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs @@ -0,0 +1,46 @@ +using System; +using System.Diagnostics; + + +namespace Microsoft.Xna.Framework.Graphics +{ + public class RasterizerState : GraphicsResource + { + // TODO: We should be asserting if the state has + // been changed after it has been bound to the device! + + public CullMode CullMode { get; set; } + public float DepthBias { get; set; } + public FillMode FillMode { get; set; } + public bool MultiSampleAntiAlias { get; set; } + public bool ScissorTestEnable { get; set; } + public float SlopeScaleDepthBias { get; set; } + + public static readonly RasterizerState CullClockwise; + public static readonly RasterizerState CullCounterClockwise; + public static readonly RasterizerState CullNone; + + public RasterizerState () + { + CullMode = CullMode.CullCounterClockwiseFace; + FillMode = FillMode.Solid; + DepthBias = 0; + MultiSampleAntiAlias = true; + ScissorTestEnable = false; + SlopeScaleDepthBias = 0; + } + + static RasterizerState () + { + CullClockwise = new RasterizerState () { + CullMode = CullMode.CullClockwiseFace + }; + CullCounterClockwise = new RasterizerState () { + CullMode = CullMode.CullCounterClockwiseFace + }; + CullNone = new RasterizerState () { + CullMode = CullMode.None + }; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs.meta b/Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs.meta new file mode 100644 index 0000000..1ae9f0c --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/RasterizerState.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7ce6468537e613541a85f13a5f30ebc1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs b/Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs new file mode 100644 index 0000000..9dcc153 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs @@ -0,0 +1,116 @@ +// #region License +// /* +// Microsoft Public License (Ms-PL) +// XnaTouch - Copyright © 2009 The XnaTouch Team +// +// All rights reserved. +// +// 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 +// +using System; +using System.Diagnostics; + +namespace Microsoft.Xna.Framework.Graphics +{ + public class SamplerState : GraphicsResource + { + static SamplerState () + { + AnisotropicClamp = new SamplerState () + { + Filter = TextureFilter.Anisotropic, + AddressU = TextureAddressMode.Clamp, + AddressV = TextureAddressMode.Clamp, + AddressW = TextureAddressMode.Clamp, + }; + + AnisotropicWrap = new SamplerState () + { + Filter = TextureFilter.Anisotropic, + AddressU = TextureAddressMode.Wrap, + AddressV = TextureAddressMode.Wrap, + AddressW = TextureAddressMode.Wrap, + }; + + LinearClamp = new SamplerState () + { + Filter = TextureFilter.Linear, + AddressU = TextureAddressMode.Clamp, + AddressV = TextureAddressMode.Clamp, + AddressW = TextureAddressMode.Clamp, + }; + + LinearWrap = new SamplerState () + { + Filter = TextureFilter.Linear, + AddressU = TextureAddressMode.Wrap, + AddressV = TextureAddressMode.Wrap, + AddressW = TextureAddressMode.Wrap, + }; + + PointClamp = new SamplerState () + { + Filter = TextureFilter.Point, + AddressU = TextureAddressMode.Clamp, + AddressV = TextureAddressMode.Clamp, + AddressW = TextureAddressMode.Clamp, + }; + + PointWrap = new SamplerState () + { + Filter = TextureFilter.Point, + AddressU = TextureAddressMode.Wrap, + AddressV = TextureAddressMode.Wrap, + AddressW = TextureAddressMode.Wrap, + }; + } + + public static readonly SamplerState AnisotropicClamp; + public static readonly SamplerState AnisotropicWrap; + public static readonly SamplerState LinearClamp; + public static readonly SamplerState LinearWrap; + public static readonly SamplerState PointClamp; + public static readonly SamplerState PointWrap; + + public TextureAddressMode AddressU { get; set; } + public TextureAddressMode AddressV { get; set; } + public TextureAddressMode AddressW { get; set; } + public TextureFilter Filter { get; set; } + + public int MaxAnisotropy { get; set; } + public int MaxMipLevel { get; set; } + public float MipMapLevelOfDetailBias { get; set; } + } +} + diff --git a/Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs.meta b/Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs.meta new file mode 100644 index 0000000..e5bd151 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/Graphics/States/SamplerState.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 09c3811cfff3651419fafccd28345455 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/IDrawable.cs b/Assets/Scripts/XNAEmulator/IDrawable.cs new file mode 100644 index 0000000..398b802 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/IDrawable.cs @@ -0,0 +1,56 @@ +#region License +/* +Microsoft Public License (Ms-PL) +MonoGame - Copyright © 2009 The MonoGame Team + +All rights reserved. + +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 + +using System; + +namespace Microsoft.Xna.Framework +{ + public interface IDrawable + { + int DrawOrder { get; } + bool Visible { get; } + + event EventHandler DrawOrderChanged; + event EventHandler VisibleChanged; + + void Draw(GameTime gameTime); + } +} + diff --git a/Assets/Scripts/XNAEmulator/IDrawable.cs.meta b/Assets/Scripts/XNAEmulator/IDrawable.cs.meta new file mode 100644 index 0000000..4fb89ff --- /dev/null +++ b/Assets/Scripts/XNAEmulator/IDrawable.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: be1658b7499774d4594a5d6f050db40c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/IGameComponent.cs b/Assets/Scripts/XNAEmulator/IGameComponent.cs new file mode 100644 index 0000000..88c6802 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/IGameComponent.cs @@ -0,0 +1,48 @@ +#region License +/* +Microsoft Public License (Ms-PL) +MonoGame - Copyright © 2009 The MonoGame Team + +All rights reserved. + +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 Microsoft.Xna.Framework +{ + public interface IGameComponent + { + void Initialize(); + } +} + diff --git a/Assets/Scripts/XNAEmulator/IGameComponent.cs.meta b/Assets/Scripts/XNAEmulator/IGameComponent.cs.meta new file mode 100644 index 0000000..7d4d520 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/IGameComponent.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 09658c538e74a4847a7cbc34d894478a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAEmulator/IUpdateable.cs b/Assets/Scripts/XNAEmulator/IUpdateable.cs new file mode 100644 index 0000000..de18c1b --- /dev/null +++ b/Assets/Scripts/XNAEmulator/IUpdateable.cs @@ -0,0 +1,65 @@ +#region License +// /* +// Microsoft Public License (Ms-PL) +// MonoGame - Copyright © 2009 The MonoGame Team +// +// All rights reserved. +// +// 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 + +#region Statemenents +using System; +#endregion + +namespace Microsoft.Xna.Framework +{ + public interface IUpdateable + { + #region Methods + void Update(GameTime gameTime); + #endregion + + #region Events + event EventHandler EnabledChanged; + + event EventHandler UpdateOrderChanged; + #endregion + + #region Properties + bool Enabled { get; } + + int UpdateOrder { get; } + #endregion + } +} diff --git a/Assets/Scripts/XNAEmulator/IUpdateable.cs.meta b/Assets/Scripts/XNAEmulator/IUpdateable.cs.meta new file mode 100644 index 0000000..6fbfb59 --- /dev/null +++ b/Assets/Scripts/XNAEmulator/IUpdateable.cs.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e3d411493a1a54949a935697d7c32d0f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} diff --git a/Assets/Scripts/XNAGame/Microsoft Permissive License.rtf.meta b/Assets/Scripts/XNAGame/Microsoft Permissive License.rtf.meta new file mode 100644 index 0000000..5447d26 --- /dev/null +++ b/Assets/Scripts/XNAGame/Microsoft Permissive License.rtf.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: de54928d99a4fca44ad2178d0e40e4c3 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 2573006422aaebfcff904e192b7394165d50ddb8..3f478c50ec43cc4f2aee61d08d0546d49c31cdb3 100644 GIT binary patch delta 1359 zcmY+Ed2AGA7{=!TnzC%^PCL`x>Fn7~v0a2ht(X}9@gN5NkQ9h9A;z$=i)=ynm!o9Odxf5V3MA!3!^-1W*x`;;n$zBY2=ezkQr;;{37uz4LpX_kF+j`!d}( zbj}EC+UOmcHdfa(&8OCf)xTC>JE69IR()4^0^FXddZ4ALwWT@T+~#Uf^hPO3gnH-e z{-K4FGPlg0mUd;Jv|N@OjnY@9%R(cDR(aZ}#$2gWzw@MSsF5T7Ohc-1(2+H4xKy=K zHJ_>rMg$9FYJnj$O}|`j8o1SqDsUTD%gi`#myT)&?NS$YaEJ0$NM+EJ@k0uw+Z+){ z&B>(PDXFHk_K$k*q;?Uti*s6Jy?!o62kYO(`gil~O~DxMq2pfZ2|8H9n#Y4S?voW^ zTSkUTaXeADG`p<(uxt%E1&^q4K~@<-83_5Xl-Y``ARZORszoR3 zcd`Cs%(2Z1K;)`~E&Y~_$609^J9&cM>&v5fQrz+}cq+$ak3B=8wvBE@EorcWSfLKb zkajzYm2|ISpR3tt4{MZ#qgX?>mYLTv^U`oJ)~h{M;Tf`L>3fd8=jl`PEppRpgN@wa z2Ff;4wu!RMl=VeQ@d8txi-fR+su!u+O4Un)$)qc4pqKn*@@?eX^E??du!DRj`7ZL^ z&^ci)?3UmUitbG!?B;ynM4S0v!i#|(Yx&EJ$96>h~Ry)17ruu4tdN! za(Zj3A=NgUv+JYoa84&n98>hNVjQ7zOQnUQ`R@BGV>rfWZ;37yP8mMnmHCiY<|8_m zI~I;pv)_r~V`e_V4nAQApHelmdW6iWD#d5yC&~NCPkG!gg`-OFIr$glUy^^7_pcsh z;A`@4$iF53F3+#Hs2JaqpC&&;e%9l9(KRhiO_Tq-JU>wOBV_}W{p86K_?he%vR`vd zE=ihlp*n$cgM+bK-Fo%eNzYr5Zk#l6;`B^=`ns#NVe0&T86TR8d!(nCBJB9eDPo`Go Gt^Wl>Uzkw< delta 1226 zcmY+ESxggQ5XX0*D`E{@y4!ZyLTPCMTaY74qEC|e;vUN?26-K0GrDe>_s&r;iVSP{VtJ$@ajs}$ ziA+2uDuVNEGR@(jD2F_CHaiu;<4TC&cAHAY+~n|53D+lkX)b4md#IFy$(qiFaH&0t z=7G-#F9Tnozhy3vCAK=8w2<4BWDeRDE>sj+1lFNOa<#)o<;Y#kLCs4`P}Qtzw3Ity zHO^M8v1f!EJ=wvH&a-15MXbSg; zA}@E^X&YBNGq_VL=W(%dRD-Nq?61zKW+}{@T_jA;E6Ef7=+Ab2r#{+&sCsDcg!V2> zxGc_0yTSH=HGu6!-7uGx_Mv~{oYGwq?MGxIA`c+)AXL&_5q!%vln#L(20sGc1U@ZZ zrlVlTz?#91qe_lbR$PIytb4rBfk)joU(}(UWn%THFpg1J>`3 zr?aq9JSv^zT*<*xJt~iND_r5x=zQoTFZ_3s7on9QilQ+u6I(nEb|pCI61u&NZd=gp z73}0}f{m_%T?4xgb^~mJSE8F>tzfsnZey3dUX|{I`nLL9)W(^sFB|4}JviBf+-;m`>pTZeogSj?Qp$DK3K_3~E9_tOo@#rKgJptT=U_cxFTi?rmO?M#e+B<*_}?JMG%T9lg7tyD1A7lvJIqcWz&?U~0{g7LWuD=; zaJE01zJvx)?N{k*Xw~ZX(YMfQP#~VZBX4vdiTYs`2fXwHR%1Y-R6ZB*a8HV