1
0
mirror of https://github.com/Memorix101/UnityXNA/ synced 2024-12-30 15:25:35 +01:00

-additional classes added

-SpriteBatch update to support more drawing functions
-Components added
This commit is contained in:
F.Fischer 2012-07-10 00:29:01 +02:00
parent 6fe889760d
commit 84e019207b
33 changed files with 1326 additions and 7 deletions

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b5d2568b352f8554d9f166fb8089199b

View File

@ -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<EventArgs> DrawOrderChanged;
public event EventHandler<EventArgs> 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
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4f5da85797380c147bc9b2325bbf9f77
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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)
{

View File

@ -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<GameComponent>, IDisposable
{
Game _game;
int _updateOrder;
bool _enabled;
public event EventHandler<EventArgs> UpdateOrderChanged;
public event EventHandler<EventArgs> 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<EventArgs> 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)
{
}
/// <summary>
/// Shuts down the component.
/// </summary>
protected virtual void Dispose(bool disposing)
{
}
/// <summary>
/// Shuts down the component.
/// </summary>
public virtual void Dispose()
{
Dispose(true);
}
#region IComparable<GameComponent> Members
public int CompareTo(GameComponent other)
{
return other.UpdateOrder - this.UpdateOrder;
}
#endregion
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6effffe4d4b43174bbec9f73f7159caf
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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<IGameComponent>
{
public event EventHandler<GameComponentCollectionEventArgs> ComponentAdded;
public event EventHandler<GameComponentCollectionEventArgs> 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();
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 98c482b2094b63a4883be38d30f3e1e7
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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;
}
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 90c5eeb40cf5ab54abd604dfbcb717e3
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1bc05554bc1744041a5be8169895e0c1

View File

@ -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;
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d2e4facfb8a731f4e94e64dd64525246
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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<EventArgs> Disposing;
public GraphicsDevice GraphicsDevice
{
get
{
return graphicsDevice;
}
}
public bool IsDisposed
{
get
{
return disposed;
}
}
public string Name { get; set; }
public Object Tag { get; set; }
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f37e48495b25fa341a6cb54c0a207312
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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<Rectangle> 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<Rectangle> 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<Rectangle> source, Color color)
{
graphicsDevice.DrawQueue.EnqueueSprite(new DrawSpriteCall(texture2D, position, source, color.ToVector4(), Vector2.Zero, SpriteEffects.None));
}
//TODO:
internal void Draw (Texture2D texture, Nullable<Rectangle> 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<Rectangle> 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)
{

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f20fbbe0311148647b9c5587258d26d1

View File

@ -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);
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 20ab82e73bf7a0346bd3019540d9f860
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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
};
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ce475ce415377b54d9116017c80b66f5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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
};
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7ce6468537e613541a85f13a5f30ebc1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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; }
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 09c3811cfff3651419fafccd28345455
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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<EventArgs> DrawOrderChanged;
event EventHandler<EventArgs> VisibleChanged;
void Draw(GameTime gameTime);
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be1658b7499774d4594a5d6f050db40c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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();
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 09658c538e74a4847a7cbc34d894478a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -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<EventArgs> EnabledChanged;
event EventHandler<EventArgs> UpdateOrderChanged;
#endregion
#region Properties
bool Enabled { get; }
int UpdateOrder { get; }
#endregion
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e3d411493a1a54949a935697d7c32d0f
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: de54928d99a4fca44ad2178d0e40e4c3