Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'xna4-work'

  • Loading branch information...
commit d5f9892d20bdca1168c5e5718c410d38bc4deeb9 2 parents 5ac0606 + c9a5f0c
Geoff Norton authored
View
55 MonoGame.Framework/Graphics/ColorWriteChannels.cs
@@ -0,0 +1,55 @@
+// #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
+{
+ [Flags]
+ public enum ColorWriteChannels
+ {
+ None = 0,
+ Red = 1,
+ Green = 2,
+ Blue = 4,
+ Alpha = 8,
+ All = 15
+ }
+}
View
106 MonoGame.Framework/Graphics/DirectionalLight.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 Microsoft.Xna.Framework.Graphics;
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+ public sealed class DirectionalLight
+ {
+ EffectParameter diffuseColorParameter;
+ EffectParameter directionParameter;
+ EffectParameter specularColorParameter;
+
+ Vector3 diffuseColor;
+ Vector3 direction;
+ Vector3 specularColor;
+ bool enabled;
+
+ public DirectionalLight (EffectParameter directionParameter, EffectParameter diffuseColorParameter, EffectParameter specularColorParameter, DirectionalLight cloneSource)
+ {
+ if (cloneSource != null) {
+ this.diffuseColorParameter = cloneSource.diffuseColorParameter;
+ this.directionParameter = cloneSource.directionParameter;
+ this.specularColorParameter = cloneSource.specularColorParameter;
+
+ this.diffuseColor = cloneSource.diffuseColor;
+ this.direction = cloneSource.direction;
+ this.specularColor = cloneSource.specularColor;
+ this.enabled = cloneSource.enabled;
+ } else {
+ this.diffuseColorParameter = diffuseColorParameter;
+ this.directionParameter = directionParameter;
+ this.specularColorParameter = specularColorParameter;
+ }
+ }
+
+ public Vector3 DiffuseColor {
+ get {
+ return diffuseColor;
+ }
+ set {
+ diffuseColor = value;
+ diffuseColorParameter.SetValue (diffuseColor);
+ }
+ }
+
+ public Vector3 Direction {
+ get {
+ return direction;
+ }
+ set {
+ direction = value;
+ directionParameter.SetValue (direction);
+ }
+ }
+
+ public Vector3 SpecularColor {
+ get {
+ return specularColor;
+ }
+ set {
+ specularColor = value;
+ specularColorParameter.SetValue (specularColor);
+ }
+ }
+ }
+}
+
View
7 MonoGame.Framework/Graphics/Effect.cs
@@ -47,12 +47,11 @@
namespace Microsoft.Xna.Framework.Graphics
{
- public class Effect : IDisposable
+ public class Effect : GraphicsResource
{
public EffectParameterCollection Parameters { get; set; }
public EffectTechniqueCollection Techniques { get; set; }
- private GraphicsDevice graphicsDevice;
private int fragment_handle;
private int vertex_handle;
private bool fragment;
@@ -169,10 +168,6 @@ public virtual Effect Clone(GraphicsDevice device)
return f;
}
- public void Dispose()
- {
- }
-
public void End()
{
}
View
85 MonoGame.Framework/Graphics/Effect/BasicEffect.cs
@@ -7,7 +7,7 @@
namespace Microsoft.Xna.Framework.Graphics
{
- public class BasicEffect : Effect
+ public class BasicEffect : Effect, IEffectMatrices, IEffectLights, IEffectFog
{
Texture2D _texture = null;
@@ -130,6 +130,89 @@ private void setTexture(Texture2D texture)
public Texture2D Texture {
get { return _texture; }
set { _texture = value; setTexture(value); }
+ }
+
+ public Vector3 DiffuseColor {
+ get; set;
+ }
+
+ public float Alpha {
+ get; set;
}
+
+ #region IEffectMatrices implementation
+ Matrix IEffectMatrices.Projection {
+ get; set;
+ }
+
+ Matrix IEffectMatrices.View {
+ get; set;
+ }
+
+ Matrix IEffectMatrices.World {
+ get; set;
+ }
+ #endregion
+
+ #region IEffectLights implementation
+ void IEffectLights.EnableDefaultLighting ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ Vector3 IEffectLights.AmbientLightColor {
+ get; set;
+ }
+
+ DirectionalLight IEffectLights.DirectionalLight0 {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ DirectionalLight IEffectLights.DirectionalLight1 {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ DirectionalLight IEffectLights.DirectionalLight2 {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ bool IEffectLights.LightingEnabled {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ #endregion
+
+ #region IEffectFog implementation
+ Vector3 IEffectFog.FogColor {
+ get; set;
+ }
+
+ bool IEffectFog.FogEnabled {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ float IEffectFog.FogEnd {
+ get; set;
+ }
+
+ float IEffectFog.FogStart {
+ get; set;
+ }
+ #endregion
}
}
View
53 MonoGame.Framework/Graphics/Effect/IEffectFog.cs
@@ -0,0 +1,53 @@
+// #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 interface IEffectFog
+ {
+ Vector3 FogColor { get; set; }
+ bool FogEnabled { get; set; }
+ float FogEnd { get; set; }
+ float FogStart { get; set; }
+ }
+}
+
View
56 MonoGame.Framework/Graphics/Effect/IEffectLights.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.Graphics
+{
+ public interface IEffectLights
+ {
+ Vector3 AmbientLightColor { get; set; }
+ DirectionalLight DirectionalLight0 { get; }
+ DirectionalLight DirectionalLight1 { get; }
+ DirectionalLight DirectionalLight2 { get; }
+ bool LightingEnabled { get; set; }
+
+ void EnableDefaultLighting ();
+ }
+}
+
View
52 MonoGame.Framework/Graphics/Effect/IEffectMatrices.cs
@@ -0,0 +1,52 @@
+// #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 interface IEffectMatrices
+ {
+ Matrix Projection { get; set; }
+ Matrix View { get; set; }
+ Matrix World { get; set; }
+ }
+}
+
View
6 MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -62,9 +62,9 @@ public class GraphicsDevice : IDisposable
private VertexBuffer _vertexBuffer = null;
private IndexBuffer _indexBuffer = null;
- public static RasterizerState RasterizerState { get; set; }
- public static DepthStencilState DepthStencilState { get; set; }
-
+ public RasterizerState RasterizerState { get; set; }
+ public DepthStencilState DepthStencilState { get; set; }
+ public BlendState BlendState { get; set; }
internal All PreferedFilter
{
View
30 MonoGame.Framework/Graphics/GraphicsResource.cs
@@ -42,7 +42,11 @@
namespace Microsoft.Xna.Framework.Graphics
{
public abstract class GraphicsResource : IDisposable
- {
+ {
+ private bool disposed;
+
+ internal GraphicsDevice graphicsDevice;
+
public GraphicsResource ()
{
}
@@ -51,6 +55,8 @@ protected virtual void DoDisposing(EventArgs e)
{
if (Disposing != null)
Disposing(this, e);
+
+ disposed = true;
}
public void Dispose()
@@ -58,7 +64,27 @@ public void Dispose()
DoDisposing(EventArgs.Empty);
}
- public event EventHandler<EventArgs> Disposing;
+ 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
54 MonoGame.Framework/Graphics/States/BlendState.cs
@@ -43,11 +43,57 @@
namespace Microsoft.Xna.Framework.Graphics
{
public class BlendState : GraphicsResource
- {
- public BlendState()
- {
+ {
+ public float Alpha { get; set; }
+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; }
+
+ static BlendState additiveState;
+
+ public static readonly BlendState Additive;
+ public static readonly BlendState AlphaBlend;
+ public static readonly BlendState NonPremultiplied;
+ public static readonly BlendState Opaque;
+
+ static BlendState () {
+ Additive = new BlendState () {
+ ColorSourceBlend = Blend.One,
+ AlphaSourceBlend = Blend.One,
+ ColorDestinationBlend = Blend.InverseSourceAlpha,
+ AlphaDestinationBlend = Blend.InverseSourceAlpha
+ };
- }
+ 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
+ };
+ }
}
}
View
44 MonoGame.Framework/Graphics/States/DepthStencilState.cs
@@ -25,6 +25,50 @@ public DepthStencilState ()
DepthBufferEnable = true;
DepthBufferWriteEnable = true;
}
+
+ static DepthStencilState defaultState;
+
+ public static DepthStencilState Default {
+ get {
+ if (defaultState == null) {
+ defaultState = new DepthStencilState () {
+ DepthBufferEnable = true,
+ DepthBufferWriteEnable = true
+ };
+ }
+
+ return defaultState;
+ }
+ }
+
+ static DepthStencilState depthReadState;
+
+ public static DepthStencilState DepthRead {
+ get {
+ if (depthReadState == null) {
+ depthReadState = new DepthStencilState () {
+ DepthBufferEnable = true,
+ DepthBufferWriteEnable = false
+ };
+ }
+
+ return depthReadState;
+ }
+ }
+
+ static DepthStencilState noneState;
+ public static DepthStencilState None {
+ get {
+ if (noneState == null) {
+ noneState = new DepthStencilState () {
+ DepthBufferEnable = false,
+ DepthBufferWriteEnable = false
+ };
+ }
+
+ return noneState;
+ }
+ }
}
}
View
23 MonoGame.Framework/Graphics/States/RasterizerState.cs
@@ -8,12 +8,23 @@ public class RasterizerState : GraphicsResource
public FillMode FillMode { get; set; }
public bool MultiSampleAntiAlias { get; set; }
public bool ScissorTestEnable { get; set; }
- public float SlopeScaleDepthBias { get; set; }
-
- public RasterizerState ()
+ public float SlopeScaleDepthBias { get; set; }
+
+ public static readonly RasterizerState CullClockwise;
+ public static readonly RasterizerState CullCounterClockwise;
+ public static readonly RasterizerState CullNone;
+
+ static RasterizerState ()
{
-
+ CullClockwise = new RasterizerState () {
+ CullMode = CullMode.CullClockwiseFace
+ };
+ CullCounterClockwise = new RasterizerState () {
+ CullMode = CullMode.CullCounterClockwiseFace
+ };
+ CullNone = new RasterizerState () {
+ CullMode = CullMode.None
+ };
}
}
-}
-
+}
View
6 MonoGame.Framework/Matrix.cs
@@ -309,7 +309,11 @@ public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix re
{
throw new NotImplementedException();
}
-
+
+ public static Matrix CreateFromYawPitchRoll (float yaw, float pitch, float roll)
+ {
+ throw new NotImplementedException ();
+ }
public static Matrix CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector)
{
Please sign in to comment.
Something went wrong with that request. Please try again.