diff --git a/ANX.Framework/Graphics/BlendState.cs b/ANX.Framework/Graphics/BlendState.cs index d5ee40a2..9ef27e88 100644 --- a/ANX.Framework/Graphics/BlendState.cs +++ b/ANX.Framework/Graphics/BlendState.cs @@ -35,6 +35,11 @@ namespace ANX.Framework.Graphics #endregion // Private Members + public static readonly BlendState Opaque; + public static readonly BlendState AlphaBlend; + public static readonly BlendState Additive; + public static readonly BlendState NonPremultiplied; + public BlendState() { this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator().CreateBlendState(); @@ -53,11 +58,6 @@ namespace ANX.Framework.Graphics this.MultiSampleMask = -1; } - public static readonly BlendState Opaque; - public static readonly BlendState AlphaBlend; - public static readonly BlendState Additive; - public static readonly BlendState NonPremultiplied; - private BlendState(Blend sourceBlend, Blend destinationBlend, string name) { this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator().CreateBlendState(); @@ -96,16 +96,10 @@ namespace ANX.Framework.Graphics public BlendFunction AlphaBlendFunction { - get - { - return this.alphaBlendFunction; - } + get { return this.alphaBlendFunction; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.alphaBlendFunction = value; this.nativeBlendState.AlphaBlendFunction = value; @@ -114,16 +108,10 @@ namespace ANX.Framework.Graphics public Blend AlphaDestinationBlend { - get - { - return this.alphaDestinationBlend; - } + get { return this.alphaDestinationBlend; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.alphaDestinationBlend = value; this.nativeBlendState.AlphaDestinationBlend = value; @@ -132,16 +120,10 @@ namespace ANX.Framework.Graphics public Blend AlphaSourceBlend { - get - { - return this.alphaSourceBlend; - } + get { return this.alphaSourceBlend; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.alphaSourceBlend = value; this.nativeBlendState.AlphaSourceBlend = value; @@ -150,16 +132,10 @@ namespace ANX.Framework.Graphics public Color BlendFactor { - get - { - return this.blendFactor; - } + get { return this.blendFactor; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.blendFactor = value; this.nativeBlendState.BlendFactor = value; @@ -168,16 +144,10 @@ namespace ANX.Framework.Graphics public BlendFunction ColorBlendFunction { - get - { - return this.colorBlendFunction; - } + get { return this.colorBlendFunction; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorBlendFunction = value; this.nativeBlendState.ColorBlendFunction = value; @@ -186,16 +156,10 @@ namespace ANX.Framework.Graphics public Blend ColorDestinationBlend { - get - { - return this.colorDestinationBlend; - } + get { return this.colorDestinationBlend; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorDestinationBlend = value; this.nativeBlendState.ColorDestinationBlend = value; @@ -204,16 +168,10 @@ namespace ANX.Framework.Graphics public Blend ColorSourceBlend { - get - { - return this.colorSourceBlend; - } + get { return this.colorSourceBlend; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorSourceBlend = value; this.nativeBlendState.ColorSourceBlend = value; @@ -222,16 +180,10 @@ namespace ANX.Framework.Graphics public ColorWriteChannels ColorWriteChannels { - get - { - return this.colorWriteChannels0; - } + get { return this.colorWriteChannels0; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorWriteChannels0 = value; this.nativeBlendState.ColorWriteChannels = value; @@ -240,16 +192,10 @@ namespace ANX.Framework.Graphics public ColorWriteChannels ColorWriteChannels1 { - get - { - return this.colorWriteChannels1; - } + get { return this.colorWriteChannels1; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorWriteChannels1 = value; this.nativeBlendState.ColorWriteChannels1 = value; @@ -258,16 +204,10 @@ namespace ANX.Framework.Graphics public ColorWriteChannels ColorWriteChannels2 { - get - { - return this.colorWriteChannels2; - } + get { return this.colorWriteChannels2; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorWriteChannels2 = value; this.nativeBlendState.ColorWriteChannels2 = value; @@ -276,16 +216,10 @@ namespace ANX.Framework.Graphics public ColorWriteChannels ColorWriteChannels3 { - get - { - return this.colorWriteChannels3; - } + get { return this.colorWriteChannels3; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.colorWriteChannels3 = value; this.nativeBlendState.ColorWriteChannels3 = value; @@ -294,22 +228,23 @@ namespace ANX.Framework.Graphics public int MultiSampleMask { - get - { - return this.multiSampleMask; - } + get { return this.multiSampleMask; } set { - if (this.nativeBlendState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.multiSampleMask = value; this.nativeBlendState.MultiSampleMask = value; } } + private void ThrowIfBound() + { + if (nativeBlendState.IsBound) + throw new InvalidOperationException( + "You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); + } + public override void Dispose() { if (this.nativeBlendState != null) diff --git a/ANX.Framework/Graphics/DepthStencilState.cs b/ANX.Framework/Graphics/DepthStencilState.cs index f553e049..144d9c2d 100644 --- a/ANX.Framework/Graphics/DepthStencilState.cs +++ b/ANX.Framework/Graphics/DepthStencilState.cs @@ -114,16 +114,10 @@ namespace ANX.Framework.Graphics public StencilOperation CounterClockwiseStencilDepthBufferFail { - get - { - return this.counterClockwiseStencilDepthBufferFail; - } + get { return this.counterClockwiseStencilDepthBufferFail; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.counterClockwiseStencilDepthBufferFail = value; this.nativeDepthStencilState.CounterClockwiseStencilDepthBufferFail = value; @@ -132,16 +126,10 @@ namespace ANX.Framework.Graphics public StencilOperation CounterClockwiseStencilFail { - get - { - return this.counterClockwiseStencilFail; - } + get { return this.counterClockwiseStencilFail; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.counterClockwiseStencilFail = value; this.nativeDepthStencilState.CounterClockwiseStencilFail = value; @@ -150,16 +138,10 @@ namespace ANX.Framework.Graphics public CompareFunction CounterClockwiseStencilFunction { - get - { - return this.counterClockwiseStencilFunction; - } + get { return this.counterClockwiseStencilFunction; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.counterClockwiseStencilFunction = value; this.nativeDepthStencilState.CounterClockwiseStencilFunction = value; @@ -168,16 +150,10 @@ namespace ANX.Framework.Graphics public StencilOperation CounterClockwiseStencilPass { - get - { - return this.counterClockwiseStencilPass; - } + get { return this.counterClockwiseStencilPass; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.counterClockwiseStencilPass = value; this.nativeDepthStencilState.CounterClockwiseStencilPass = value; @@ -186,16 +162,10 @@ namespace ANX.Framework.Graphics public bool DepthBufferEnable { - get - { - return this.depthBufferEnable; - } + get { return this.depthBufferEnable; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.depthBufferEnable = value; this.nativeDepthStencilState.DepthBufferEnable = value; @@ -204,16 +174,10 @@ namespace ANX.Framework.Graphics public CompareFunction DepthBufferFunction { - get - { - return this.depthBufferFunction; - } + get { return this.depthBufferFunction; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.depthBufferFunction = value; this.nativeDepthStencilState.DepthBufferFunction = value; @@ -222,16 +186,10 @@ namespace ANX.Framework.Graphics public bool DepthBufferWriteEnable { - get - { - return this.depthBufferWriteEnable; - } + get { return this.depthBufferWriteEnable; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.depthBufferWriteEnable = value; this.nativeDepthStencilState.DepthBufferWriteEnable = value; @@ -240,16 +198,10 @@ namespace ANX.Framework.Graphics public int ReferenceStencil { - get - { - return this.referenceStencil; - } + get { return this.referenceStencil; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.referenceStencil = value; this.nativeDepthStencilState.ReferenceStencil = value; @@ -258,16 +210,10 @@ namespace ANX.Framework.Graphics public StencilOperation StencilDepthBufferFail { - get - { - return this.stencilDepthBufferFail; - } + get { return this.stencilDepthBufferFail; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilDepthBufferFail = value; this.nativeDepthStencilState.StencilDepthBufferFail = value; @@ -276,16 +222,10 @@ namespace ANX.Framework.Graphics public bool StencilEnable { - get - { - return this.stencilEnable; - } + get { return this.stencilEnable; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilEnable = value; this.nativeDepthStencilState.StencilEnable = value; @@ -294,16 +234,10 @@ namespace ANX.Framework.Graphics public StencilOperation StencilFail { - get - { - return this.stencilFail; - } + get { return this.stencilFail; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilFail = value; this.nativeDepthStencilState.StencilFail = value; @@ -312,16 +246,10 @@ namespace ANX.Framework.Graphics public CompareFunction StencilFunction { - get - { - return this.stencilFunction; - } + get { return this.stencilFunction; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilFunction = value; this.nativeDepthStencilState.StencilFunction = value; @@ -330,16 +258,10 @@ namespace ANX.Framework.Graphics public int StencilMask { - get - { - return this.stencilMask; - } + get { return this.stencilMask; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilMask = value; this.nativeDepthStencilState.StencilMask = value; @@ -348,16 +270,10 @@ namespace ANX.Framework.Graphics public StencilOperation StencilPass { - get - { - return this.stencilPass; - } + get { return this.stencilPass; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilPass = value; this.nativeDepthStencilState.StencilPass = value; @@ -366,16 +282,10 @@ namespace ANX.Framework.Graphics public int StencilWriteMask { - get - { - return this.stencilWriteMask; - } + get { return this.stencilWriteMask; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.stencilWriteMask = value; this.nativeDepthStencilState.StencilWriteMask = value; @@ -384,22 +294,23 @@ namespace ANX.Framework.Graphics public bool TwoSidedStencilMode { - get - { - return this.twoSidedStencilMode; - } + get { return this.twoSidedStencilMode; } set { - if (this.nativeDepthStencilState.IsBound) - { - throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); - } + ThrowIfBound(); this.twoSidedStencilMode = value; this.nativeDepthStencilState.TwoSidedStencilMode = value; } } + private void ThrowIfBound() + { + if (nativeDepthStencilState.IsBound) + throw new InvalidOperationException( + "You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); + } + public override void Dispose() { if (this.nativeDepthStencilState != null) diff --git a/ANX.Framework/Graphics/DisplayModeCollection.cs b/ANX.Framework/Graphics/DisplayModeCollection.cs index 781bb3fe..61c21488 100644 --- a/ANX.Framework/Graphics/DisplayModeCollection.cs +++ b/ANX.Framework/Graphics/DisplayModeCollection.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using ANX.Framework.NonXNA.Development; #endregion // Using Statements @@ -12,43 +13,33 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { - [PercentageComplete(30)] - [Developer("Glatzemann")] + [PercentageComplete(100)] + [Developer("AstrorEnales")] [TestState(TestStateAttribute.TestState.Untested)] public class DisplayModeCollection : IEnumerable, IEnumerable { - private List displayModes = new List(); - - public IEnumerator GetEnumerator() - { - throw new NotImplementedException(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); - } + private readonly List displayModes; public IEnumerable this[SurfaceFormat format] { get { - foreach (DisplayMode mode in displayModes) - { - if (mode.Format == format) - { - yield return mode; - } - } - } - set - { - foreach (DisplayMode mode in value) - { - displayModes.Add(mode); - } + return displayModes.Where(current => current.Format == format).ToList(); } } + internal DisplayModeCollection(List displayModes) + { + this.displayModes = displayModes; + } + + public IEnumerator GetEnumerator() + { + return displayModes.GetEnumerator(); + } + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } } } diff --git a/ANX.Framework/Graphics/DynamicIndexBuffer.cs b/ANX.Framework/Graphics/DynamicIndexBuffer.cs index 97b7a55b..7b01baea 100644 --- a/ANX.Framework/Graphics/DynamicIndexBuffer.cs +++ b/ANX.Framework/Graphics/DynamicIndexBuffer.cs @@ -25,13 +25,13 @@ namespace ANX.Framework.Graphics public DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage) : base(graphicsDevice, indexElementSize, indexCount, usage) { - graphicsDevice.DeviceReset += new EventHandler(graphicsDevice_DeviceReset); + graphicsDevice.DeviceReset += graphicsDevice_DeviceReset; } public DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage) : base(graphicsDevice, indexType, indexCount, usage) { - graphicsDevice.DeviceReset += new EventHandler(graphicsDevice_DeviceReset); + graphicsDevice.DeviceReset += graphicsDevice_DeviceReset; } ~DynamicIndexBuffer() diff --git a/ANX.Framework/Graphics/DynamicVertexBuffer.cs b/ANX.Framework/Graphics/DynamicVertexBuffer.cs index fc077244..8ee8fa28 100644 --- a/ANX.Framework/Graphics/DynamicVertexBuffer.cs +++ b/ANX.Framework/Graphics/DynamicVertexBuffer.cs @@ -25,13 +25,13 @@ namespace ANX.Framework.Graphics public DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsage usage) : base(graphicsDevice, vertexType, vertexCount, usage) { - graphicsDevice.DeviceReset += new EventHandler(graphicsDevice_DeviceReset); + graphicsDevice.DeviceReset += graphicsDevice_DeviceReset; } public DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) : base(graphicsDevice, vertexDeclaration, vertexCount, usage) { - graphicsDevice.DeviceReset += new EventHandler(graphicsDevice_DeviceReset); + graphicsDevice.DeviceReset += graphicsDevice_DeviceReset; } ~DynamicVertexBuffer() diff --git a/ANX.Framework/Graphics/Effect.cs b/ANX.Framework/Graphics/Effect.cs index 660aa5f6..bf669190 100644 --- a/ANX.Framework/Graphics/Effect.cs +++ b/ANX.Framework/Graphics/Effect.cs @@ -10,17 +10,14 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { - [PercentageComplete(90)] + [PercentageComplete(100)] [Developer("Glatzemann")] [TestState(TestStateAttribute.TestState.Untested)] public class Effect : GraphicsResource, IGraphicsResource { #region Private private INativeEffect nativeEffect; - private EffectTechniqueCollection techniqueCollection; - private EffectTechnique currentTechnique; - private EffectParameterCollection parameterCollection; - private byte[] byteCode; + private readonly byte[] byteCode; private EffectSourceLanguage sourceLanguage; #endregion @@ -38,34 +35,10 @@ namespace ANX.Framework.Graphics } } - public EffectTechnique CurrentTechnique - { - get - { - return this.currentTechnique; - } - set - { - this.currentTechnique = value; - } - } - - public EffectParameterCollection Parameters - { - get - { - return this.parameterCollection; - } - } - - public EffectTechniqueCollection Techniques - { - get - { - return this.techniqueCollection; - } - } - #endregion + public EffectTechnique CurrentTechnique { get; set; } + public EffectParameterCollection Parameters { get; private set; } + public EffectTechniqueCollection Techniques { get; private set; } + #endregion #region Constructor protected Effect(Effect cloneSource) @@ -89,7 +62,7 @@ namespace ANX.Framework.Graphics CreateNativeEffect(sourceLanguage); - this.currentTechnique = this.techniqueCollection[0]; + this.CurrentTechnique = this.Techniques[0]; this.sourceLanguage = sourceLanguage; } @@ -126,10 +99,10 @@ namespace ANX.Framework.Graphics } #endregion - #region Clone (TODO) + #region Clone public virtual Effect Clone() { - throw new NotImplementedException(); + return new Effect(this); } #endregion @@ -142,7 +115,7 @@ namespace ANX.Framework.Graphics } #endregion - #region Dispose (TODO) + #region Dispose public override void Dispose() { if (nativeEffect != null) @@ -154,7 +127,14 @@ namespace ANX.Framework.Graphics protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) { - throw new NotImplementedException(); + try + { + Dispose(); + } + finally + { + base.Dispose(false); + } } #endregion @@ -166,8 +146,8 @@ namespace ANX.Framework.Graphics if (creator.IsLanguageSupported(sourceLanguage)) { this.nativeEffect = creator.CreateEffect(GraphicsDevice, this, new MemoryStream(this.byteCode, false)); - this.techniqueCollection = new EffectTechniqueCollection(this, this.nativeEffect); - this.parameterCollection = new EffectParameterCollection(this, this.nativeEffect); + this.Techniques = new EffectTechniqueCollection(this, this.nativeEffect); + this.Parameters = new EffectParameterCollection(this, this.nativeEffect); } else throw new InvalidOperationException("couldn't create " + sourceLanguage + " native effect using RenderSystem " + diff --git a/ANX.Framework/Graphics/EffectAnnotationCollection.cs b/ANX.Framework/Graphics/EffectAnnotationCollection.cs index bb4f7949..3b93ae92 100644 --- a/ANX.Framework/Graphics/EffectAnnotationCollection.cs +++ b/ANX.Framework/Graphics/EffectAnnotationCollection.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections; +using System.Linq; using ANX.Framework.NonXNA.Development; #endregion // Using Statements @@ -12,48 +13,46 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { - [PercentageComplete(10)] - [Developer("Glatzemann")] + [PercentageComplete(100)] + [Developer("AstrorEnales")] [TestState(TestStateAttribute.TestState.Untested)] public sealed class EffectAnnotationCollection : IEnumerable { + private readonly List annotations; + + public int Count + { + get { return annotations.Count; } + } + public EffectAnnotation this[int index] { - get - { - throw new NotImplementedException(); - } + get { return index >= 0 && index < annotations.Count ? annotations[index] : null; } } public EffectAnnotation this[string name] { - get - { - throw new NotImplementedException(); - } + get { return annotations.FirstOrDefault(annotation => annotation.Name == name); } + } + + internal EffectAnnotationCollection() + { + annotations = new List(); } IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + return annotations.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { - throw new NotImplementedException(); + return annotations.GetEnumerator(); } public List.Enumerator GetEnumerator() { - throw new NotImplementedException(); - } - - public int Count - { - get - { - throw new NotImplementedException(); - } + return annotations.GetEnumerator(); } } } diff --git a/ANX.Framework/Graphics/EffectParameter.cs b/ANX.Framework/Graphics/EffectParameter.cs index c5bbe33b..0f694740 100644 --- a/ANX.Framework/Graphics/EffectParameter.cs +++ b/ANX.Framework/Graphics/EffectParameter.cs @@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { - [PercentageComplete(60)] + [PercentageComplete(80)] [TestState(TestStateAttribute.TestState.Untested)] [Developer("Glatzemann")] public sealed class EffectParameter @@ -25,69 +25,51 @@ namespace ANX.Framework.Graphics } } + public EffectParameterCollection Elements + { + get + { + throw new NotImplementedException(); + } + } + + public EffectParameterCollection StructureMembers + { + get + { + throw new NotImplementedException(); + } + } + public int ColumnCount { - get - { - throw new NotImplementedException(); - } + get { return NativeParameter.ColumnCount; } } - public EffectParameterCollection Elements - { - get - { - throw new NotImplementedException(); - } - } + public string Name + { + get { return NativeParameter.Name; } + } - public string Name - { - get - { - return this.NativeParameter.Name; - } - } + public EffectParameterClass ParameterClass + { + get { return NativeParameter.ParameterClass; } + } - public EffectParameterClass ParameterClass - { - get - { - throw new NotImplementedException(); - } - } + public EffectParameterType ParameterType + { + get { return NativeParameter.ParameterType; } + } - public EffectParameterType ParameterType - { - get - { - throw new NotImplementedException(); - } - } + public int RowCount + { + get { return NativeParameter.RowCount; } + } - public int RowCount - { - get - { - throw new NotImplementedException(); - } - } - - public string Semantic - { - get - { - return this.NativeParameter.Semantic; - } - } - - public EffectParameterCollection StructureMembers - { - get - { - throw new NotImplementedException(); - } - } + public string Semantic + { + get { return NativeParameter.Semantic; } + } #endregion #region GetValue diff --git a/ANX.Framework/Graphics/EffectParameterClass.cs b/ANX.Framework/Graphics/EffectParameterClass.cs index b471593b..837141bd 100644 --- a/ANX.Framework/Graphics/EffectParameterClass.cs +++ b/ANX.Framework/Graphics/EffectParameterClass.cs @@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics { [PercentageComplete(100)] [Developer("Glatzemann")] - [TestState(TestStateAttribute.TestState.Untested)] + [TestState(TestStateAttribute.TestState.Tested)] public enum EffectParameterClass { Scalar, diff --git a/ANX.Framework/Graphics/EffectParameterCollection.cs b/ANX.Framework/Graphics/EffectParameterCollection.cs index 968bfa94..601826c1 100644 --- a/ANX.Framework/Graphics/EffectParameterCollection.cs +++ b/ANX.Framework/Graphics/EffectParameterCollection.cs @@ -1,6 +1,7 @@ #region Using Statements using System; using System.Collections.Generic; +using System.Linq; using ANX.Framework.NonXNA; using System.Collections; using ANX.Framework.NonXNA.Development; @@ -24,6 +25,21 @@ namespace ANX.Framework.Graphics private List parameters; #endregion + public EffectParameter this[int index] + { + get { return index >= 0 && index < parameters.Count ? parameters[index] : null; } + } + + public EffectParameter this[string name] + { + get { return parameters.FirstOrDefault(t => t.Name == name); } + } + + public int Count + { + get { return parameters.Count; } + } + internal EffectParameterCollection(Effect parentEffect, INativeEffect nativeEffect) { this.parentEffect = parentEffect; @@ -36,35 +52,6 @@ namespace ANX.Framework.Graphics } } - public EffectParameter this[int index] - { - get - { - if (index >= parameters.Count) - { - throw new ArgumentOutOfRangeException("index"); - } - - return parameters[index]; - } - } - - public EffectParameter this[string name] - { - get - { - for (int i = 0; i < parameters.Count; i++) - { - if (parameters[i].Name == name) - { - return parameters[i]; - } - } - - return null; - } - } - public EffectParameter GetParameterBySemantic(string semantic) { foreach (EffectParameter parameter in parameters) @@ -92,13 +79,5 @@ namespace ANX.Framework.Graphics { return parameters.GetEnumerator(); } - - public int Count - { - get - { - return this.parameters.Count; - } - } } } diff --git a/ANX.Framework/Graphics/EffectPassCollection.cs b/ANX.Framework/Graphics/EffectPassCollection.cs index 85dbee6d..bbfd374c 100644 --- a/ANX.Framework/Graphics/EffectPassCollection.cs +++ b/ANX.Framework/Graphics/EffectPassCollection.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections; +using System.Linq; using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.Development; @@ -14,7 +15,7 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { [PercentageComplete(100)] - [Developer("Glatzemann")] + [Developer("Glatzemann, AstrorEnales")] [TestState(TestStateAttribute.TestState.Untested)] public sealed class EffectPassCollection : IEnumerable { @@ -22,10 +23,25 @@ namespace ANX.Framework.Graphics private Effect parentEffect; private INativeEffect nativeEffect; private INativeEffectTechnique parentTechnique; - private List passes; + private readonly List passes; #endregion // Private Members + public EffectPass this[int index] + { + get { return index >= 0 && index < passes.Count ? passes[index] : null; } + } + + public EffectPass this[string name] + { + get { return passes.FirstOrDefault(pass => pass.Name == name); } + } + + public int Count + { + get { return passes.Count; } + } + internal EffectPassCollection(Effect parentEffect, INativeEffect nativeEffect, INativeEffectTechnique parentTechnique) { this.parentEffect = parentEffect; @@ -39,48 +55,19 @@ namespace ANX.Framework.Graphics } } - public EffectPass this[int index] - { - get - { - if (index >= passes.Count) - { - throw new ArgumentOutOfRangeException("index"); - } - - return passes[index]; - } - } - - public EffectPass this[string name] - { - get - { - throw new NotImplementedException(); - } - } - IEnumerator IEnumerable.GetEnumerator() { - return (IEnumerator)this.passes.GetEnumerator(); + return passes.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { - return (IEnumerator)this.passes.GetEnumerator(); + return passes.GetEnumerator(); } public List.Enumerator GetEnumerator() { - return this.passes.GetEnumerator(); + return passes.GetEnumerator(); } - - public int Count - { - get - { - return this.passes.Count; - } - } } } diff --git a/ANX.Framework/Graphics/EffectTechniqueCollection.cs b/ANX.Framework/Graphics/EffectTechniqueCollection.cs index de34f6e5..fd59ca39 100644 --- a/ANX.Framework/Graphics/EffectTechniqueCollection.cs +++ b/ANX.Framework/Graphics/EffectTechniqueCollection.cs @@ -16,7 +16,7 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { [PercentageComplete(100)] - [Developer("Glatzemann")] + [Developer("Glatzemann, AstrorEnales")] [TestState(TestStateAttribute.TestState.Untested)] public sealed class EffectTechniqueCollection : IEnumerable, IEnumerable { @@ -27,6 +27,21 @@ namespace ANX.Framework.Graphics #endregion // Private Members + public EffectTechnique this[int index] + { + get { return index >= 0 && index < techniques.Count ? techniques[index] : null; } + } + + public EffectTechnique this[string name] + { + get { return techniques.FirstOrDefault(t => t.Name == name); } + } + + public int Count + { + get { return techniques.Count; } + } + internal EffectTechniqueCollection(Effect parentEffect, INativeEffect nativeEffect) { this.parentEffect = parentEffect; @@ -39,58 +54,19 @@ namespace ANX.Framework.Graphics } } - public EffectTechnique this[int index] - { - get - { - if (index >= techniques.Count) - { - throw new ArgumentOutOfRangeException("index"); - } - - return techniques[index]; - } - } - - public EffectTechnique this[string name] - { - get - { - foreach (EffectTechnique teq in techniques) - { - if (teq.Name.Equals(name)) - { - return teq; - } - } - - throw new ArgumentException("No technique with name '" + name + "' found."); - } - } - IEnumerator IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); + { + return techniques.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); + { + return techniques.GetEnumerator(); } public List.Enumerator GetEnumerator() - { - throw new NotImplementedException(); - } - - public int Count { - get - { - return this.techniques.Count; - } - } - - + return techniques.GetEnumerator(); + } } } diff --git a/ANX.Framework/Graphics/ModelBoneCollection.cs b/ANX.Framework/Graphics/ModelBoneCollection.cs index 48f5a077..b3a992eb 100644 --- a/ANX.Framework/Graphics/ModelBoneCollection.cs +++ b/ANX.Framework/Graphics/ModelBoneCollection.cs @@ -1,8 +1,9 @@ #region Using Statements using System; -using System.Collections.ObjectModel; using System.Collections; using System.Collections.Generic; +using System.Collections.ObjectModel; +using ANX.Framework.NonXNA.Development; #endregion // Using Statements @@ -12,9 +13,12 @@ using System.Collections.Generic; namespace ANX.Framework.Graphics { + [PercentageComplete(100)] + [Developer("???, AstrorEnales")] + [TestState(TestStateAttribute.TestState.Untested)] public sealed class ModelBoneCollection : ReadOnlyCollection { - private ModelBone[] modelBones; + private readonly ModelBone[] modelBones; internal ModelBoneCollection(ModelBone[] modelBones) : base(modelBones) @@ -29,23 +33,25 @@ namespace ANX.Framework.Graphics public struct Enumerator : IEnumerator, IDisposable, IEnumerator { - private ModelBone[] wrappedArray; + private readonly ModelBone[] wrappedArray; private int position; + public ModelBone Current + { + get { return this.wrappedArray[this.position]; } + } + + object IEnumerator.Current + { + get { return this.Current; } + } + internal Enumerator(ModelBone[] wrappedArray) { this.wrappedArray = wrappedArray; this.position = -1; } - public ModelBone Current - { - get - { - return this.wrappedArray[this.position]; - } - } - public bool MoveNext() { this.position++; @@ -65,26 +71,36 @@ namespace ANX.Framework.Graphics public void Dispose() { } - - object IEnumerator.Current - { - get - { - return this.Current; - } - } } - public bool TryGetValue (string boneName, out ModelBone value) + public bool TryGetValue(string boneName, out ModelBone value) { - throw new NotImplementedException(); + if (String.IsNullOrEmpty(boneName)) + throw new ArgumentNullException("boneName"); + + for (int index = 0; index < Items.Count; index++) + { + ModelBone modelBone = Items[index]; + if (String.Compare(modelBone.Name, boneName, StringComparison.Ordinal) == 0) + { + value = modelBone; + return true; + } + } + + value = null; + return false; } public ModelBone this[string boneName] { get { - throw new NotImplementedException(); + ModelBone result; + if (TryGetValue(boneName, out result) == false) + throw new KeyNotFoundException(); + + return result; } } diff --git a/ANX.Framework/Graphics/ModelEffectCollection.cs b/ANX.Framework/Graphics/ModelEffectCollection.cs index d742aa18..8f18ebca 100644 --- a/ANX.Framework/Graphics/ModelEffectCollection.cs +++ b/ANX.Framework/Graphics/ModelEffectCollection.cs @@ -3,6 +3,7 @@ using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Collections; +using ANX.Framework.NonXNA.Development; #endregion // Using Statements @@ -12,9 +13,12 @@ using System.Collections; namespace ANX.Framework.Graphics { + [PercentageComplete(100)] + [Developer("???")] + [TestState(TestStateAttribute.TestState.Untested)] public sealed class ModelEffectCollection : ReadOnlyCollection { - private List effects; + private readonly List effects; internal ModelEffectCollection() : base(new List()) @@ -39,7 +43,7 @@ namespace ANX.Framework.Graphics public struct Enumerator : IEnumerator, IDisposable, IEnumerator { - private List wrappedArray; + private readonly List wrappedArray; private int position; internal Enumerator(List wrappedArray) diff --git a/ANX.Framework/Graphics/ModelMeshCollection.cs b/ANX.Framework/Graphics/ModelMeshCollection.cs index 628dbf2a..03fdb314 100644 --- a/ANX.Framework/Graphics/ModelMeshCollection.cs +++ b/ANX.Framework/Graphics/ModelMeshCollection.cs @@ -3,6 +3,7 @@ using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Collections; +using ANX.Framework.NonXNA.Development; #endregion // Using Statements @@ -12,9 +13,12 @@ using System.Collections; namespace ANX.Framework.Graphics { + [PercentageComplete(100)] + [Developer("???, AstrorEnales")] + [TestState(TestStateAttribute.TestState.Untested)] public sealed class ModelMeshCollection : ReadOnlyCollection { - private ModelMesh[] modelMeshes; + private readonly ModelMesh[] modelMeshes; internal ModelMeshCollection(ModelMesh[] modelMeshes) : base(modelMeshes) @@ -29,7 +33,7 @@ namespace ANX.Framework.Graphics public struct Enumerator : IEnumerator, IDisposable, IEnumerator { - private ModelMesh[] wrappedArray; + private readonly ModelMesh[] wrappedArray; private int position; internal Enumerator(ModelMesh[] wrappedArray) @@ -77,16 +81,34 @@ namespace ANX.Framework.Graphics public bool TryGetValue(string meshName, out ModelMesh value) { - throw new NotImplementedException(); + if (String.IsNullOrEmpty(meshName)) + throw new ArgumentNullException("meshName"); + + for (int index = 0; index < Items.Count; index++) + { + ModelMesh modelMesh = Items[index]; + if (String.Compare(modelMesh.Name, meshName, StringComparison.Ordinal) == 0) + { + value = modelMesh; + return true; + } + } + + value = null; + return false; } public ModelMesh this[string meshName] { get { - throw new NotImplementedException(); + ModelMesh result; + if (TryGetValue(meshName, out result) == false) + { + throw new KeyNotFoundException(); + } + return result; } } - } } diff --git a/ANX.Framework/Graphics/ModelMeshPartCollection.cs b/ANX.Framework/Graphics/ModelMeshPartCollection.cs index 61a1308d..955b56b6 100644 --- a/ANX.Framework/Graphics/ModelMeshPartCollection.cs +++ b/ANX.Framework/Graphics/ModelMeshPartCollection.cs @@ -14,7 +14,7 @@ namespace ANX.Framework.Graphics [TestState(TestStateAttribute.TestState.Untested)] public sealed class ModelMeshPartCollection : ReadOnlyCollection { - private ModelMeshPart[] modelMeshParts; + private readonly ModelMeshPart[] modelMeshParts; internal ModelMeshPartCollection(ModelMeshPart[] modelMeshParts) : base(modelMeshParts) @@ -29,7 +29,7 @@ namespace ANX.Framework.Graphics public struct Enumerator : IEnumerator, IDisposable, IEnumerator { - private ModelMeshPart[] wrappedArray; + private readonly ModelMeshPart[] wrappedArray; private int position; public ModelMeshPart Current diff --git a/ANX.Framework/Graphics/SamplerStateCollection.cs b/ANX.Framework/Graphics/SamplerStateCollection.cs index 48e9d577..d9ef9298 100644 --- a/ANX.Framework/Graphics/SamplerStateCollection.cs +++ b/ANX.Framework/Graphics/SamplerStateCollection.cs @@ -1,3 +1,4 @@ +using System; using ANX.Framework.NonXNA.Development; // This file is part of the ANX.Framework created by the @@ -6,11 +7,12 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Graphics { - [PercentageComplete(100)] + [PercentageComplete(100)] + [TestState(TestStateAttribute.TestState.Untested)] public sealed class SamplerStateCollection { - private SamplerState[] samplerStates; - private GraphicsDevice graphics; + private readonly SamplerState[] samplerStates; + private readonly GraphicsDevice graphics; public SamplerStateCollection(GraphicsDevice graphics, int maxSamplers) { @@ -25,6 +27,9 @@ namespace ANX.Framework.Graphics { get { + if (index < 0 || index >= samplerStates.Length) + throw new ArgumentOutOfRangeException("index"); + return samplerStates[index]; } set diff --git a/ANX.Framework/NonXNA/RenderSystem/INativeEffectParameter.cs b/ANX.Framework/NonXNA/RenderSystem/INativeEffectParameter.cs index 11ac3b64..2942a6ba 100644 --- a/ANX.Framework/NonXNA/RenderSystem/INativeEffectParameter.cs +++ b/ANX.Framework/NonXNA/RenderSystem/INativeEffectParameter.cs @@ -17,8 +17,11 @@ namespace ANX.Framework.NonXNA public interface INativeEffectParameter { string Name { get; } - string Semantic { get; } + int ColumnCount { get; } + int RowCount { get; } + EffectParameterClass ParameterClass { get; } + EffectParameterType ParameterType { get; } #region GetValue bool GetValueBoolean(); diff --git a/RenderSystems/ANX.Framework.GL3/Creator.cs b/RenderSystems/ANX.Framework.GL3/Creator.cs index 1bf675c5..c77525ea 100644 --- a/RenderSystems/ANX.Framework.GL3/Creator.cs +++ b/RenderSystems/ANX.Framework.GL3/Creator.cs @@ -255,12 +255,11 @@ namespace ANX.RenderSystem.GL3 var result = new List(); foreach (DisplayDevice device in DisplayDevice.AvailableDisplays) - { - var displayModeCollection = new DisplayModeCollection(); + { + var resultingModes = new List(); foreach (string format in Enum.GetNames(typeof(SurfaceFormat))) { - SurfaceFormat surfaceFormat = - (SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format); + SurfaceFormat surfaceFormat = (SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format); // TODO: device.BitsPerPixel if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false) @@ -268,12 +267,10 @@ namespace ANX.RenderSystem.GL3 continue; } - var modes = new List(); - foreach (DisplayResolution res in device.AvailableResolutions) { float aspect = (float)res.Width / (float)res.Height; - modes.Add(new DisplayMode + resultingModes.Add(new DisplayMode { AspectRatio = aspect, Width = res.Width, @@ -282,13 +279,11 @@ namespace ANX.RenderSystem.GL3 Format = surfaceFormat, }); } - - displayModeCollection[surfaceFormat] = modes.ToArray(); } - GraphicsAdapter newAdapter = new GraphicsAdapter + var newAdapter = new GraphicsAdapter { - SupportedDisplayModes = displayModeCollection, + SupportedDisplayModes = new DisplayModeCollection(resultingModes), IsDefaultAdapter = device.IsPrimary, // TODO: diff --git a/RenderSystems/ANX.Framework.GL3/EffectParameterGL3.cs b/RenderSystems/ANX.Framework.GL3/EffectParameterGL3.cs index 08e6356f..934fb4ef 100644 --- a/RenderSystems/ANX.Framework.GL3/EffectParameterGL3.cs +++ b/RenderSystems/ANX.Framework.GL3/EffectParameterGL3.cs @@ -20,31 +20,40 @@ namespace ANX.RenderSystem.GL3 #endregion #region Public - /// - /// The name of the effect parameter. - /// - public string Name - { - get; - private set; - } + /// + /// The name of the effect parameter. + /// + public string Name { get; private set; } + + /// + /// The index of the uniform. + /// + public int UniformIndex { get; private set; } public string Semantic { - get - { - throw new NotSupportedException(); - } + get { throw new NotSupportedException(); } } - /// - /// The index of the uniform. - /// - public int UniformIndex - { - get; - private set; - } + public int ColumnCount + { + get { throw new NotImplementedException(); } + } + + public int RowCount + { + get { throw new NotImplementedException(); } + } + + public EffectParameterClass ParameterClass + { + get { throw new NotImplementedException(); } + } + + public EffectParameterType ParameterType + { + get { throw new NotImplementedException(); } + } #endregion #region Constructor diff --git a/RenderSystems/ANX.RenderSystem.DX.SharedSources/DxFormatConverter.cs b/RenderSystems/ANX.RenderSystem.DX.SharedSources/DxFormatConverter.cs index 3a0ebf2f..8d388dfb 100644 --- a/RenderSystems/ANX.RenderSystem.DX.SharedSources/DxFormatConverter.cs +++ b/RenderSystems/ANX.RenderSystem.DX.SharedSources/DxFormatConverter.cs @@ -1,6 +1,7 @@ #region Using Statements using System; using ANX.Framework.Graphics; +using SharpDX.D3DCompiler; using SharpDX.Direct3D; using SharpDX.DXGI; @@ -174,29 +175,32 @@ namespace ANX.RenderSystem.Windows.DX11 #region Translate (VertexElement) public static string Translate(ref VertexElement element) { - //TODO: map the other Usages + //TODO: map the other Usages if (element.VertexElementUsage == VertexElementUsage.TextureCoordinate) return "TEXCOORD"; - else - return element.VertexElementUsage.ToString().ToUpperInvariant(); + + return element.VertexElementUsage.ToString().ToUpperInvariant(); } - #endregion + #endregion #region CalculateVertexCount public static int CalculateVertexCount(PrimitiveType type, int primitiveCount) { - if (type == PrimitiveType.TriangleList) - return primitiveCount * 3; - else if (type == PrimitiveType.LineList) - return primitiveCount * 2; - else if (type == PrimitiveType.LineStrip) - return primitiveCount + 1; - else if (type == PrimitiveType.TriangleStrip) - return primitiveCount + 2; + switch (type) + { + case PrimitiveType.TriangleList: + return primitiveCount * 3; + case PrimitiveType.LineList: + return primitiveCount * 2; + case PrimitiveType.LineStrip: + return primitiveCount + 1; + case PrimitiveType.TriangleStrip: + return primitiveCount + 2; + } - throw new NotImplementedException("Couldn't calculate vertex count for PrimitiveType '" + type + "'."); + throw new NotImplementedException("Couldn't calculate vertex count for PrimitiveType '" + type + "'."); } - #endregion + #endregion #region ConvertVertexElementFormat public static Format ConvertVertexElementFormat(VertexElementFormat format) @@ -222,6 +226,57 @@ namespace ANX.RenderSystem.Windows.DX11 throw new Exception("Can't map '" + format + "' to DXGI.Format in Dx10 CreateInputElementFromVertexElement."); } - #endregion + #endregion + + #region Translate (ShaderVariableType) + public static EffectParameterType Translate(ShaderVariableType type) + { + switch (type) + { + case ShaderVariableType.Bool: + return EffectParameterType.Bool; + case ShaderVariableType.Texture1D: + return EffectParameterType.Texture1D; + case ShaderVariableType.Texture2D: + return EffectParameterType.Texture2D; + case ShaderVariableType.Texture3D: + return EffectParameterType.Texture3D; + case ShaderVariableType.Texture: + return EffectParameterType.Texture; + case ShaderVariableType.Void: + return EffectParameterType.Void; + case ShaderVariableType.Int: + return EffectParameterType.Int32; + case ShaderVariableType.Float: + return EffectParameterType.Single; + case ShaderVariableType.String: + return EffectParameterType.String; + case ShaderVariableType.TextureCube: + return EffectParameterType.TextureCube; + } + + return EffectParameterType.Void; + } + #endregion + + #region Translate (ShaderVariableType) + public static EffectParameterClass Translate(ShaderVariableClass type) + { + switch (type) + { + case ShaderVariableClass.Scalar: + return EffectParameterClass.Scalar; + case ShaderVariableClass.Vector: + return EffectParameterClass.Vector; + case ShaderVariableClass.Struct: + return EffectParameterClass.Struct; + case ShaderVariableClass.MatrixRows: + case ShaderVariableClass.MatrixColumns: + return EffectParameterClass.Matrix; + } + + return EffectParameterClass.Object; + } + #endregion } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs index 661109f3..a6e61d56 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs @@ -172,10 +172,10 @@ namespace ANX.RenderSystem.Windows.DX10 { PreventSystemChange(); - SharpDX.DXGI.Factory factory = new Factory(); + var factory = new Factory(); - List adapterList = new List(); - DisplayModeCollection displayModeCollection = new DisplayModeCollection(); + var adapterList = new List(); + var resultingModes = new List(); for (int i = 0; i < factory.GetAdapterCount(); i++) { @@ -196,7 +196,8 @@ namespace ANX.RenderSystem.Windows.DX10 using (Output adapterOutput = adapter.Outputs[0]) { - var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced); + var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, + DisplayModeEnumerationFlags.Interlaced); foreach (ModeDescription modeDescription in modeList) { DisplayMode displayMode = new DisplayMode() @@ -208,11 +209,11 @@ namespace ANX.RenderSystem.Windows.DX10 TitleSafeArea = new Rectangle(0, 0, modeDescription.Width, modeDescription.Height), //TODO: calculate this for real }; - displayModeCollection[displayMode.Format] = new DisplayMode[] { displayMode }; + resultingModes.Add(displayMode); } } - ga.SupportedDisplayModes = displayModeCollection; + ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes); adapterList.Add(ga); } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/EffectParameter_DX10.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/EffectParameter_DX10.cs index dbe68337..3fb58479 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/EffectParameter_DX10.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/EffectParameter_DX10.cs @@ -11,34 +11,44 @@ using ANX.Framework.NonXNA.Development; namespace ANX.RenderSystem.Windows.DX10 { - [PercentageComplete(70)] + [PercentageComplete(50)] [TestState(TestStateAttribute.TestState.Untested)] [Developer("Glatzemann")] public class EffectParameter_DX10 : INativeEffectParameter { #region Public - public Dx10.EffectVariable NativeParameter - { - get; - internal set; - } + public Dx10.EffectVariable NativeParameter { get; internal set; } - public string Name - { - get - { - return NativeParameter.Description.Name; - } - } + public string Name + { + get { return NativeParameter.Description.Name; } + } public string Semantic { - get - { - return NativeParameter.Description.Semantic; - } + get { return NativeParameter.Description.Semantic; } } - #endregion + + public int ColumnCount + { + get { return NativeParameter.TypeInfo.Description.Columns; } + } + + public int RowCount + { + get { return NativeParameter.TypeInfo.Description.Rows; } + } + + public EffectParameterClass ParameterClass + { + get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Class); } + } + + public EffectParameterType ParameterType + { + get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Type); } + } + #endregion #region SetValue (bool) public void SetValue(bool value) diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs index 0bda4be8..5e0bd478 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs @@ -8,6 +8,7 @@ using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.RenderSystem; using SharpDX.DXGI; using ANX.Framework.NonXNA.Development; +using System.Collections.ObjectModel; #endregion @@ -160,14 +161,14 @@ namespace ANX.RenderSystem.Windows.DX11 #endregion #region GetAdapterList - public System.Collections.ObjectModel.ReadOnlyCollection GetAdapterList() + public ReadOnlyCollection GetAdapterList() { PreventSystemChange(); var factory = new Factory(); - List adapterList = new List(); - DisplayModeCollection displayModeCollection = new DisplayModeCollection(); + var adapterList = new List(); + var resultingModes = new List(); for (int i = 0; i < factory.GetAdapterCount(); i++) { @@ -190,7 +191,7 @@ namespace ANX.RenderSystem.Windows.DX11 { foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced)) { - DisplayMode displayMode = new DisplayMode() + var displayMode = new DisplayMode { Format = DxFormatConverter.Translate(modeDescription.Format), Width = modeDescription.Width, @@ -199,13 +200,13 @@ namespace ANX.RenderSystem.Windows.DX11 TitleSafeArea = new Rectangle(0, 0, modeDescription.Width, modeDescription.Height), //TODO: calculate this for real }; - displayModeCollection[displayMode.Format] = new DisplayMode[] { displayMode }; + resultingModes.Add(displayMode); } break; //TODO: for the moment only adapter output 0 is interesting... } - ga.SupportedDisplayModes = displayModeCollection; + ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes); adapterList.Add(ga); } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/EffectParameter_DX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/EffectParameter_DX11.cs index cbd3602f..80c8d670 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/EffectParameter_DX11.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/EffectParameter_DX11.cs @@ -11,34 +11,44 @@ using ANX.Framework.NonXNA.Development; namespace ANX.RenderSystem.Windows.DX11 { - [PercentageComplete(60)] + [PercentageComplete(50)] [TestState(TestStateAttribute.TestState.Untested)] [Developer("Glatzemann")] public class EffectParameter_DX11 : INativeEffectParameter { #region Public - public Dx11.EffectVariable NativeParameter - { - get; - internal set; - } + public Dx11.EffectVariable NativeParameter { get; internal set; } - public string Name - { - get - { - return NativeParameter.Description.Name; - } - } + public string Name + { + get { return NativeParameter.Description.Name; } + } public string Semantic { - get - { - return NativeParameter.Description.Semantic; - } + get { return NativeParameter.Description.Semantic; } } - #endregion + + public int ColumnCount + { + get { return NativeParameter.TypeInfo.Description.Columns; } + } + + public int RowCount + { + get { return NativeParameter.TypeInfo.Description.Rows; } + } + + public EffectParameterClass ParameterClass + { + get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Class); } + } + + public EffectParameterType ParameterType + { + get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Type); } + } + #endregion #region SetValue (bool) public void SetValue(bool value) @@ -283,5 +293,5 @@ namespace ANX.RenderSystem.Windows.DX11 throw new NotImplementedException(); } #endregion - } + } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs index 93ee9268..7e2dbd81 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.Metro/EffectParameter_Metro.cs @@ -33,6 +33,26 @@ namespace ANX.RenderSystem.Windows.Metro throw new NotSupportedException(); } } + + public int ColumnCount + { + get { throw new NotImplementedException(); } + } + + public int RowCount + { + get { throw new NotImplementedException(); } + } + + public EffectParameterClass ParameterClass + { + get { throw new NotImplementedException(); } + } + + public EffectParameterType ParameterType + { + get { throw new NotImplementedException(); } + } #endregion #region Constructor diff --git a/Samples/SampleCatalog.xml b/Samples/SampleCatalog.xml index 3dcfe31f..43f3a0a3 100644 --- a/Samples/SampleCatalog.xml +++ b/Samples/SampleCatalog.xml @@ -86,15 +86,15 @@ - - BasicEffectSample - A Sample demonstrating all possible uses of the BasicEffect class. - BasicEffectSample\bin\x86\Debug\BasicEffectSample.exe - Rendering - - 3D - - + + BasicEffectSample + A Sample demonstrating all possible uses of the BasicEffect class. + BasicEffectSample\bin\x86\Debug\BasicEffectSample.exe + Rendering + + 3D + + SpriteSample