- Changed access modifiers in DisplayModeCollection to match Xna signature and fixed the usage of that class

- Implemented Properties of EffectParameter
- Fixed OutOfRange behaviour in multiple collection files in graphics to match xna behaviour (which just returns null)
- Implemented some methods in collection classes
This commit is contained in:
SND\AstrorEnales_cp 2012-10-13 10:51:27 +00:00 committed by Konstantin Koch
parent 085fb42ba6
commit db82358d24
27 changed files with 525 additions and 634 deletions

View File

@ -35,6 +35,11 @@ namespace ANX.Framework.Graphics
#endregion // Private Members #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() public BlendState()
{ {
this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateBlendState(); this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateBlendState();
@ -53,11 +58,6 @@ namespace ANX.Framework.Graphics
this.MultiSampleMask = -1; 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) private BlendState(Blend sourceBlend, Blend destinationBlend, string name)
{ {
this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateBlendState(); this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateBlendState();
@ -96,16 +96,10 @@ namespace ANX.Framework.Graphics
public BlendFunction AlphaBlendFunction public BlendFunction AlphaBlendFunction
{ {
get get { return this.alphaBlendFunction; }
{
return this.alphaBlendFunction;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.alphaBlendFunction = value; this.alphaBlendFunction = value;
this.nativeBlendState.AlphaBlendFunction = value; this.nativeBlendState.AlphaBlendFunction = value;
@ -114,16 +108,10 @@ namespace ANX.Framework.Graphics
public Blend AlphaDestinationBlend public Blend AlphaDestinationBlend
{ {
get get { return this.alphaDestinationBlend; }
{
return this.alphaDestinationBlend;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.alphaDestinationBlend = value; this.alphaDestinationBlend = value;
this.nativeBlendState.AlphaDestinationBlend = value; this.nativeBlendState.AlphaDestinationBlend = value;
@ -132,16 +120,10 @@ namespace ANX.Framework.Graphics
public Blend AlphaSourceBlend public Blend AlphaSourceBlend
{ {
get get { return this.alphaSourceBlend; }
{
return this.alphaSourceBlend;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.alphaSourceBlend = value; this.alphaSourceBlend = value;
this.nativeBlendState.AlphaSourceBlend = value; this.nativeBlendState.AlphaSourceBlend = value;
@ -150,16 +132,10 @@ namespace ANX.Framework.Graphics
public Color BlendFactor public Color BlendFactor
{ {
get get { return this.blendFactor; }
{
return this.blendFactor;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.blendFactor = value; this.blendFactor = value;
this.nativeBlendState.BlendFactor = value; this.nativeBlendState.BlendFactor = value;
@ -168,16 +144,10 @@ namespace ANX.Framework.Graphics
public BlendFunction ColorBlendFunction public BlendFunction ColorBlendFunction
{ {
get get { return this.colorBlendFunction; }
{
return this.colorBlendFunction;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorBlendFunction = value; this.colorBlendFunction = value;
this.nativeBlendState.ColorBlendFunction = value; this.nativeBlendState.ColorBlendFunction = value;
@ -186,16 +156,10 @@ namespace ANX.Framework.Graphics
public Blend ColorDestinationBlend public Blend ColorDestinationBlend
{ {
get get { return this.colorDestinationBlend; }
{
return this.colorDestinationBlend;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorDestinationBlend = value; this.colorDestinationBlend = value;
this.nativeBlendState.ColorDestinationBlend = value; this.nativeBlendState.ColorDestinationBlend = value;
@ -204,16 +168,10 @@ namespace ANX.Framework.Graphics
public Blend ColorSourceBlend public Blend ColorSourceBlend
{ {
get get { return this.colorSourceBlend; }
{
return this.colorSourceBlend;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorSourceBlend = value; this.colorSourceBlend = value;
this.nativeBlendState.ColorSourceBlend = value; this.nativeBlendState.ColorSourceBlend = value;
@ -222,16 +180,10 @@ namespace ANX.Framework.Graphics
public ColorWriteChannels ColorWriteChannels public ColorWriteChannels ColorWriteChannels
{ {
get get { return this.colorWriteChannels0; }
{
return this.colorWriteChannels0;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorWriteChannels0 = value; this.colorWriteChannels0 = value;
this.nativeBlendState.ColorWriteChannels = value; this.nativeBlendState.ColorWriteChannels = value;
@ -240,16 +192,10 @@ namespace ANX.Framework.Graphics
public ColorWriteChannels ColorWriteChannels1 public ColorWriteChannels ColorWriteChannels1
{ {
get get { return this.colorWriteChannels1; }
{
return this.colorWriteChannels1;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorWriteChannels1 = value; this.colorWriteChannels1 = value;
this.nativeBlendState.ColorWriteChannels1 = value; this.nativeBlendState.ColorWriteChannels1 = value;
@ -258,16 +204,10 @@ namespace ANX.Framework.Graphics
public ColorWriteChannels ColorWriteChannels2 public ColorWriteChannels ColorWriteChannels2
{ {
get get { return this.colorWriteChannels2; }
{
return this.colorWriteChannels2;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorWriteChannels2 = value; this.colorWriteChannels2 = value;
this.nativeBlendState.ColorWriteChannels2 = value; this.nativeBlendState.ColorWriteChannels2 = value;
@ -276,16 +216,10 @@ namespace ANX.Framework.Graphics
public ColorWriteChannels ColorWriteChannels3 public ColorWriteChannels ColorWriteChannels3
{ {
get get { return this.colorWriteChannels3; }
{
return this.colorWriteChannels3;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.colorWriteChannels3 = value; this.colorWriteChannels3 = value;
this.nativeBlendState.ColorWriteChannels3 = value; this.nativeBlendState.ColorWriteChannels3 = value;
@ -294,22 +228,23 @@ namespace ANX.Framework.Graphics
public int MultiSampleMask public int MultiSampleMask
{ {
get get { return this.multiSampleMask; }
{
return this.multiSampleMask;
}
set set
{ {
if (this.nativeBlendState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change BlendState properties while it is bound to the GraphicsDevice.");
}
this.multiSampleMask = value; this.multiSampleMask = value;
this.nativeBlendState.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() public override void Dispose()
{ {
if (this.nativeBlendState != null) if (this.nativeBlendState != null)

View File

@ -114,16 +114,10 @@ namespace ANX.Framework.Graphics
public StencilOperation CounterClockwiseStencilDepthBufferFail public StencilOperation CounterClockwiseStencilDepthBufferFail
{ {
get get { return this.counterClockwiseStencilDepthBufferFail; }
{
return this.counterClockwiseStencilDepthBufferFail;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.counterClockwiseStencilDepthBufferFail = value; this.counterClockwiseStencilDepthBufferFail = value;
this.nativeDepthStencilState.CounterClockwiseStencilDepthBufferFail = value; this.nativeDepthStencilState.CounterClockwiseStencilDepthBufferFail = value;
@ -132,16 +126,10 @@ namespace ANX.Framework.Graphics
public StencilOperation CounterClockwiseStencilFail public StencilOperation CounterClockwiseStencilFail
{ {
get get { return this.counterClockwiseStencilFail; }
{
return this.counterClockwiseStencilFail;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.counterClockwiseStencilFail = value; this.counterClockwiseStencilFail = value;
this.nativeDepthStencilState.CounterClockwiseStencilFail = value; this.nativeDepthStencilState.CounterClockwiseStencilFail = value;
@ -150,16 +138,10 @@ namespace ANX.Framework.Graphics
public CompareFunction CounterClockwiseStencilFunction public CompareFunction CounterClockwiseStencilFunction
{ {
get get { return this.counterClockwiseStencilFunction; }
{
return this.counterClockwiseStencilFunction;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.counterClockwiseStencilFunction = value; this.counterClockwiseStencilFunction = value;
this.nativeDepthStencilState.CounterClockwiseStencilFunction = value; this.nativeDepthStencilState.CounterClockwiseStencilFunction = value;
@ -168,16 +150,10 @@ namespace ANX.Framework.Graphics
public StencilOperation CounterClockwiseStencilPass public StencilOperation CounterClockwiseStencilPass
{ {
get get { return this.counterClockwiseStencilPass; }
{
return this.counterClockwiseStencilPass;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.counterClockwiseStencilPass = value; this.counterClockwiseStencilPass = value;
this.nativeDepthStencilState.CounterClockwiseStencilPass = value; this.nativeDepthStencilState.CounterClockwiseStencilPass = value;
@ -186,16 +162,10 @@ namespace ANX.Framework.Graphics
public bool DepthBufferEnable public bool DepthBufferEnable
{ {
get get { return this.depthBufferEnable; }
{
return this.depthBufferEnable;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.depthBufferEnable = value; this.depthBufferEnable = value;
this.nativeDepthStencilState.DepthBufferEnable = value; this.nativeDepthStencilState.DepthBufferEnable = value;
@ -204,16 +174,10 @@ namespace ANX.Framework.Graphics
public CompareFunction DepthBufferFunction public CompareFunction DepthBufferFunction
{ {
get get { return this.depthBufferFunction; }
{
return this.depthBufferFunction;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.depthBufferFunction = value; this.depthBufferFunction = value;
this.nativeDepthStencilState.DepthBufferFunction = value; this.nativeDepthStencilState.DepthBufferFunction = value;
@ -222,16 +186,10 @@ namespace ANX.Framework.Graphics
public bool DepthBufferWriteEnable public bool DepthBufferWriteEnable
{ {
get get { return this.depthBufferWriteEnable; }
{
return this.depthBufferWriteEnable;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.depthBufferWriteEnable = value; this.depthBufferWriteEnable = value;
this.nativeDepthStencilState.DepthBufferWriteEnable = value; this.nativeDepthStencilState.DepthBufferWriteEnable = value;
@ -240,16 +198,10 @@ namespace ANX.Framework.Graphics
public int ReferenceStencil public int ReferenceStencil
{ {
get get { return this.referenceStencil; }
{
return this.referenceStencil;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.referenceStencil = value; this.referenceStencil = value;
this.nativeDepthStencilState.ReferenceStencil = value; this.nativeDepthStencilState.ReferenceStencil = value;
@ -258,16 +210,10 @@ namespace ANX.Framework.Graphics
public StencilOperation StencilDepthBufferFail public StencilOperation StencilDepthBufferFail
{ {
get get { return this.stencilDepthBufferFail; }
{
return this.stencilDepthBufferFail;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilDepthBufferFail = value; this.stencilDepthBufferFail = value;
this.nativeDepthStencilState.StencilDepthBufferFail = value; this.nativeDepthStencilState.StencilDepthBufferFail = value;
@ -276,16 +222,10 @@ namespace ANX.Framework.Graphics
public bool StencilEnable public bool StencilEnable
{ {
get get { return this.stencilEnable; }
{
return this.stencilEnable;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilEnable = value; this.stencilEnable = value;
this.nativeDepthStencilState.StencilEnable = value; this.nativeDepthStencilState.StencilEnable = value;
@ -294,16 +234,10 @@ namespace ANX.Framework.Graphics
public StencilOperation StencilFail public StencilOperation StencilFail
{ {
get get { return this.stencilFail; }
{
return this.stencilFail;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilFail = value; this.stencilFail = value;
this.nativeDepthStencilState.StencilFail = value; this.nativeDepthStencilState.StencilFail = value;
@ -312,16 +246,10 @@ namespace ANX.Framework.Graphics
public CompareFunction StencilFunction public CompareFunction StencilFunction
{ {
get get { return this.stencilFunction; }
{
return this.stencilFunction;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilFunction = value; this.stencilFunction = value;
this.nativeDepthStencilState.StencilFunction = value; this.nativeDepthStencilState.StencilFunction = value;
@ -330,16 +258,10 @@ namespace ANX.Framework.Graphics
public int StencilMask public int StencilMask
{ {
get get { return this.stencilMask; }
{
return this.stencilMask;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilMask = value; this.stencilMask = value;
this.nativeDepthStencilState.StencilMask = value; this.nativeDepthStencilState.StencilMask = value;
@ -348,16 +270,10 @@ namespace ANX.Framework.Graphics
public StencilOperation StencilPass public StencilOperation StencilPass
{ {
get get { return this.stencilPass; }
{
return this.stencilPass;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilPass = value; this.stencilPass = value;
this.nativeDepthStencilState.StencilPass = value; this.nativeDepthStencilState.StencilPass = value;
@ -366,16 +282,10 @@ namespace ANX.Framework.Graphics
public int StencilWriteMask public int StencilWriteMask
{ {
get get { return this.stencilWriteMask; }
{
return this.stencilWriteMask;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.stencilWriteMask = value; this.stencilWriteMask = value;
this.nativeDepthStencilState.StencilWriteMask = value; this.nativeDepthStencilState.StencilWriteMask = value;
@ -384,22 +294,23 @@ namespace ANX.Framework.Graphics
public bool TwoSidedStencilMode public bool TwoSidedStencilMode
{ {
get get { return this.twoSidedStencilMode; }
{
return this.twoSidedStencilMode;
}
set set
{ {
if (this.nativeDepthStencilState.IsBound) ThrowIfBound();
{
throw new InvalidOperationException("You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice.");
}
this.twoSidedStencilMode = value; this.twoSidedStencilMode = value;
this.nativeDepthStencilState.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() public override void Dispose()
{ {
if (this.nativeDepthStencilState != null) if (this.nativeDepthStencilState != null)

View File

@ -2,6 +2,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements #endregion // Using Statements
@ -12,43 +13,33 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(30)] [PercentageComplete(100)]
[Developer("Glatzemann")] [Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public class DisplayModeCollection : IEnumerable<DisplayMode>, IEnumerable public class DisplayModeCollection : IEnumerable<DisplayMode>, IEnumerable
{ {
private List<DisplayMode> displayModes = new List<DisplayMode>(); private readonly List<DisplayMode> displayModes;
public IEnumerator<DisplayMode> GetEnumerator()
{
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
public IEnumerable<DisplayMode> this[SurfaceFormat format] public IEnumerable<DisplayMode> this[SurfaceFormat format]
{ {
get get
{ {
foreach (DisplayMode mode in displayModes) return displayModes.Where(current => current.Format == format).ToList();
{
if (mode.Format == format)
{
yield return mode;
}
}
}
set
{
foreach (DisplayMode mode in value)
{
displayModes.Add(mode);
}
} }
} }
internal DisplayModeCollection(List<DisplayMode> displayModes)
{
this.displayModes = displayModes;
}
public IEnumerator<DisplayMode> GetEnumerator()
{
return displayModes.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
} }
} }

View File

@ -25,13 +25,13 @@ namespace ANX.Framework.Graphics
public DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage) public DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage)
: base(graphicsDevice, indexElementSize, indexCount, usage) : base(graphicsDevice, indexElementSize, indexCount, usage)
{ {
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset); graphicsDevice.DeviceReset += graphicsDevice_DeviceReset;
} }
public DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage) public DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
: base(graphicsDevice, indexType, indexCount, usage) : base(graphicsDevice, indexType, indexCount, usage)
{ {
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset); graphicsDevice.DeviceReset += graphicsDevice_DeviceReset;
} }
~DynamicIndexBuffer() ~DynamicIndexBuffer()

View File

@ -25,13 +25,13 @@ namespace ANX.Framework.Graphics
public DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsage usage) public DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsage usage)
: base(graphicsDevice, vertexType, vertexCount, usage) : base(graphicsDevice, vertexType, vertexCount, usage)
{ {
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset); graphicsDevice.DeviceReset += graphicsDevice_DeviceReset;
} }
public DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) public DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
: base(graphicsDevice, vertexDeclaration, vertexCount, usage) : base(graphicsDevice, vertexDeclaration, vertexCount, usage)
{ {
graphicsDevice.DeviceReset += new EventHandler<EventArgs>(graphicsDevice_DeviceReset); graphicsDevice.DeviceReset += graphicsDevice_DeviceReset;
} }
~DynamicVertexBuffer() ~DynamicVertexBuffer()

View File

@ -10,17 +10,14 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(90)] [PercentageComplete(100)]
[Developer("Glatzemann")] [Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public class Effect : GraphicsResource, IGraphicsResource public class Effect : GraphicsResource, IGraphicsResource
{ {
#region Private #region Private
private INativeEffect nativeEffect; private INativeEffect nativeEffect;
private EffectTechniqueCollection techniqueCollection; private readonly byte[] byteCode;
private EffectTechnique currentTechnique;
private EffectParameterCollection parameterCollection;
private byte[] byteCode;
private EffectSourceLanguage sourceLanguage; private EffectSourceLanguage sourceLanguage;
#endregion #endregion
@ -38,34 +35,10 @@ namespace ANX.Framework.Graphics
} }
} }
public EffectTechnique CurrentTechnique public EffectTechnique CurrentTechnique { get; set; }
{ public EffectParameterCollection Parameters { get; private set; }
get public EffectTechniqueCollection Techniques { get; private set; }
{ #endregion
return this.currentTechnique;
}
set
{
this.currentTechnique = value;
}
}
public EffectParameterCollection Parameters
{
get
{
return this.parameterCollection;
}
}
public EffectTechniqueCollection Techniques
{
get
{
return this.techniqueCollection;
}
}
#endregion
#region Constructor #region Constructor
protected Effect(Effect cloneSource) protected Effect(Effect cloneSource)
@ -89,7 +62,7 @@ namespace ANX.Framework.Graphics
CreateNativeEffect(sourceLanguage); CreateNativeEffect(sourceLanguage);
this.currentTechnique = this.techniqueCollection[0]; this.CurrentTechnique = this.Techniques[0];
this.sourceLanguage = sourceLanguage; this.sourceLanguage = sourceLanguage;
} }
@ -126,10 +99,10 @@ namespace ANX.Framework.Graphics
} }
#endregion #endregion
#region Clone (TODO) #region Clone
public virtual Effect Clone() public virtual Effect Clone()
{ {
throw new NotImplementedException(); return new Effect(this);
} }
#endregion #endregion
@ -142,7 +115,7 @@ namespace ANX.Framework.Graphics
} }
#endregion #endregion
#region Dispose (TODO) #region Dispose
public override void Dispose() public override void Dispose()
{ {
if (nativeEffect != null) if (nativeEffect != null)
@ -154,7 +127,14 @@ namespace ANX.Framework.Graphics
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{ {
throw new NotImplementedException(); try
{
Dispose();
}
finally
{
base.Dispose(false);
}
} }
#endregion #endregion
@ -166,8 +146,8 @@ namespace ANX.Framework.Graphics
if (creator.IsLanguageSupported(sourceLanguage)) if (creator.IsLanguageSupported(sourceLanguage))
{ {
this.nativeEffect = creator.CreateEffect(GraphicsDevice, this, new MemoryStream(this.byteCode, false)); this.nativeEffect = creator.CreateEffect(GraphicsDevice, this, new MemoryStream(this.byteCode, false));
this.techniqueCollection = new EffectTechniqueCollection(this, this.nativeEffect); this.Techniques = new EffectTechniqueCollection(this, this.nativeEffect);
this.parameterCollection = new EffectParameterCollection(this, this.nativeEffect); this.Parameters = new EffectParameterCollection(this, this.nativeEffect);
} }
else else
throw new InvalidOperationException("couldn't create " + sourceLanguage + " native effect using RenderSystem " + throw new InvalidOperationException("couldn't create " + sourceLanguage + " native effect using RenderSystem " +

View File

@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Linq;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
#endregion // Using Statements #endregion // Using Statements
@ -12,48 +13,46 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(10)] [PercentageComplete(100)]
[Developer("Glatzemann")] [Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectAnnotationCollection : IEnumerable<EffectAnnotation> public sealed class EffectAnnotationCollection : IEnumerable<EffectAnnotation>
{ {
private readonly List<EffectAnnotation> annotations;
public int Count
{
get { return annotations.Count; }
}
public EffectAnnotation this[int index] public EffectAnnotation this[int index]
{ {
get get { return index >= 0 && index < annotations.Count ? annotations[index] : null; }
{
throw new NotImplementedException();
}
} }
public EffectAnnotation this[string name] public EffectAnnotation this[string name]
{ {
get get { return annotations.FirstOrDefault(annotation => annotation.Name == name); }
{ }
throw new NotImplementedException();
} internal EffectAnnotationCollection()
{
annotations = new List<EffectAnnotation>();
} }
IEnumerator<EffectAnnotation> IEnumerable<EffectAnnotation>.GetEnumerator() IEnumerator<EffectAnnotation> IEnumerable<EffectAnnotation>.GetEnumerator()
{ {
throw new NotImplementedException(); return annotations.GetEnumerator();
} }
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
throw new NotImplementedException(); return annotations.GetEnumerator();
} }
public List<EffectAnnotation>.Enumerator GetEnumerator() public List<EffectAnnotation>.Enumerator GetEnumerator()
{ {
throw new NotImplementedException(); return annotations.GetEnumerator();
}
public int Count
{
get
{
throw new NotImplementedException();
}
} }
} }
} }

View File

@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(60)] [PercentageComplete(80)]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")] [Developer("Glatzemann")]
public sealed class EffectParameter 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 public int ColumnCount
{ {
get get { return NativeParameter.ColumnCount; }
{
throw new NotImplementedException();
}
} }
public EffectParameterCollection Elements public string Name
{ {
get get { return NativeParameter.Name; }
{ }
throw new NotImplementedException();
}
}
public string Name public EffectParameterClass ParameterClass
{ {
get get { return NativeParameter.ParameterClass; }
{ }
return this.NativeParameter.Name;
}
}
public EffectParameterClass ParameterClass public EffectParameterType ParameterType
{ {
get get { return NativeParameter.ParameterType; }
{ }
throw new NotImplementedException();
}
}
public EffectParameterType ParameterType public int RowCount
{ {
get get { return NativeParameter.RowCount; }
{ }
throw new NotImplementedException();
}
}
public int RowCount public string Semantic
{ {
get get { return NativeParameter.Semantic; }
{ }
throw new NotImplementedException();
}
}
public string Semantic
{
get
{
return this.NativeParameter.Semantic;
}
}
public EffectParameterCollection StructureMembers
{
get
{
throw new NotImplementedException();
}
}
#endregion #endregion
#region GetValue #region GetValue

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)] [PercentageComplete(100)]
[Developer("Glatzemann")] [Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Tested)]
public enum EffectParameterClass public enum EffectParameterClass
{ {
Scalar, Scalar,

View File

@ -1,6 +1,7 @@
#region Using Statements #region Using Statements
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using System.Collections; using System.Collections;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
@ -24,6 +25,21 @@ namespace ANX.Framework.Graphics
private List<EffectParameter> parameters; private List<EffectParameter> parameters;
#endregion #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) internal EffectParameterCollection(Effect parentEffect, INativeEffect nativeEffect)
{ {
this.parentEffect = parentEffect; 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) public EffectParameter GetParameterBySemantic(string semantic)
{ {
foreach (EffectParameter parameter in parameters) foreach (EffectParameter parameter in parameters)
@ -92,13 +79,5 @@ namespace ANX.Framework.Graphics
{ {
return parameters.GetEnumerator(); return parameters.GetEnumerator();
} }
public int Count
{
get
{
return this.parameters.Count;
}
}
} }
} }

View File

@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Linq;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
@ -14,7 +15,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)] [PercentageComplete(100)]
[Developer("Glatzemann")] [Developer("Glatzemann, AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectPassCollection : IEnumerable<EffectPass> public sealed class EffectPassCollection : IEnumerable<EffectPass>
{ {
@ -22,10 +23,25 @@ namespace ANX.Framework.Graphics
private Effect parentEffect; private Effect parentEffect;
private INativeEffect nativeEffect; private INativeEffect nativeEffect;
private INativeEffectTechnique parentTechnique; private INativeEffectTechnique parentTechnique;
private List<EffectPass> passes; private readonly List<EffectPass> passes;
#endregion // Private Members #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) internal EffectPassCollection(Effect parentEffect, INativeEffect nativeEffect, INativeEffectTechnique parentTechnique)
{ {
this.parentEffect = parentEffect; 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<EffectPass> IEnumerable<EffectPass>.GetEnumerator() IEnumerator<EffectPass> IEnumerable<EffectPass>.GetEnumerator()
{ {
return (IEnumerator<EffectPass>)this.passes.GetEnumerator(); return passes.GetEnumerator();
} }
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return (IEnumerator)this.passes.GetEnumerator(); return passes.GetEnumerator();
} }
public List<EffectPass>.Enumerator GetEnumerator() public List<EffectPass>.Enumerator GetEnumerator()
{ {
return this.passes.GetEnumerator(); return passes.GetEnumerator();
} }
public int Count
{
get
{
return this.passes.Count;
}
}
} }
} }

View File

@ -16,7 +16,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)] [PercentageComplete(100)]
[Developer("Glatzemann")] [Developer("Glatzemann, AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectTechniqueCollection : IEnumerable<EffectTechnique>, IEnumerable public sealed class EffectTechniqueCollection : IEnumerable<EffectTechnique>, IEnumerable
{ {
@ -27,6 +27,21 @@ namespace ANX.Framework.Graphics
#endregion // Private Members #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) internal EffectTechniqueCollection(Effect parentEffect, INativeEffect nativeEffect)
{ {
this.parentEffect = parentEffect; 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<EffectTechnique> IEnumerable<EffectTechnique>.GetEnumerator() IEnumerator<EffectTechnique> IEnumerable<EffectTechnique>.GetEnumerator()
{ {
throw new NotImplementedException(); return techniques.GetEnumerator();
} }
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
throw new NotImplementedException(); return techniques.GetEnumerator();
} }
public List<EffectTechnique>.Enumerator GetEnumerator() public List<EffectTechnique>.Enumerator GetEnumerator()
{
throw new NotImplementedException();
}
public int Count
{ {
get return techniques.GetEnumerator();
{ }
return this.techniques.Count;
}
}
} }
} }

View File

@ -1,8 +1,9 @@
#region Using Statements #region Using Statements
using System; using System;
using System.Collections.ObjectModel;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements #endregion // Using Statements
@ -12,9 +13,12 @@ using System.Collections.Generic;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[Developer("???, AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class ModelBoneCollection : ReadOnlyCollection<ModelBone> public sealed class ModelBoneCollection : ReadOnlyCollection<ModelBone>
{ {
private ModelBone[] modelBones; private readonly ModelBone[] modelBones;
internal ModelBoneCollection(ModelBone[] modelBones) internal ModelBoneCollection(ModelBone[] modelBones)
: base(modelBones) : base(modelBones)
@ -29,23 +33,25 @@ namespace ANX.Framework.Graphics
public struct Enumerator : IEnumerator<ModelBone>, IDisposable, IEnumerator public struct Enumerator : IEnumerator<ModelBone>, IDisposable, IEnumerator
{ {
private ModelBone[] wrappedArray; private readonly ModelBone[] wrappedArray;
private int position; private int position;
public ModelBone Current
{
get { return this.wrappedArray[this.position]; }
}
object IEnumerator.Current
{
get { return this.Current; }
}
internal Enumerator(ModelBone[] wrappedArray) internal Enumerator(ModelBone[] wrappedArray)
{ {
this.wrappedArray = wrappedArray; this.wrappedArray = wrappedArray;
this.position = -1; this.position = -1;
} }
public ModelBone Current
{
get
{
return this.wrappedArray[this.position];
}
}
public bool MoveNext() public bool MoveNext()
{ {
this.position++; this.position++;
@ -65,26 +71,36 @@ namespace ANX.Framework.Graphics
public void Dispose() 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] public ModelBone this[string boneName]
{ {
get get
{ {
throw new NotImplementedException(); ModelBone result;
if (TryGetValue(boneName, out result) == false)
throw new KeyNotFoundException();
return result;
} }
} }

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections; using System.Collections;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements #endregion // Using Statements
@ -12,9 +13,12 @@ using System.Collections;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[Developer("???")]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class ModelEffectCollection : ReadOnlyCollection<Effect> public sealed class ModelEffectCollection : ReadOnlyCollection<Effect>
{ {
private List<Effect> effects; private readonly List<Effect> effects;
internal ModelEffectCollection() internal ModelEffectCollection()
: base(new List<Effect>()) : base(new List<Effect>())
@ -39,7 +43,7 @@ namespace ANX.Framework.Graphics
public struct Enumerator : IEnumerator<Effect>, IDisposable, IEnumerator public struct Enumerator : IEnumerator<Effect>, IDisposable, IEnumerator
{ {
private List<Effect> wrappedArray; private readonly List<Effect> wrappedArray;
private int position; private int position;
internal Enumerator(List<Effect> wrappedArray) internal Enumerator(List<Effect> wrappedArray)

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections; using System.Collections;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements #endregion // Using Statements
@ -12,9 +13,12 @@ using System.Collections;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)]
[Developer("???, AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class ModelMeshCollection : ReadOnlyCollection<ModelMesh> public sealed class ModelMeshCollection : ReadOnlyCollection<ModelMesh>
{ {
private ModelMesh[] modelMeshes; private readonly ModelMesh[] modelMeshes;
internal ModelMeshCollection(ModelMesh[] modelMeshes) internal ModelMeshCollection(ModelMesh[] modelMeshes)
: base(modelMeshes) : base(modelMeshes)
@ -29,7 +33,7 @@ namespace ANX.Framework.Graphics
public struct Enumerator : IEnumerator<ModelMesh>, IDisposable, IEnumerator public struct Enumerator : IEnumerator<ModelMesh>, IDisposable, IEnumerator
{ {
private ModelMesh[] wrappedArray; private readonly ModelMesh[] wrappedArray;
private int position; private int position;
internal Enumerator(ModelMesh[] wrappedArray) internal Enumerator(ModelMesh[] wrappedArray)
@ -77,16 +81,34 @@ namespace ANX.Framework.Graphics
public bool TryGetValue(string meshName, out ModelMesh value) 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] public ModelMesh this[string meshName]
{ {
get get
{ {
throw new NotImplementedException(); ModelMesh result;
if (TryGetValue(meshName, out result) == false)
{
throw new KeyNotFoundException();
}
return result;
} }
} }
} }
} }

View File

@ -14,7 +14,7 @@ namespace ANX.Framework.Graphics
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public sealed class ModelMeshPartCollection : ReadOnlyCollection<ModelMeshPart> public sealed class ModelMeshPartCollection : ReadOnlyCollection<ModelMeshPart>
{ {
private ModelMeshPart[] modelMeshParts; private readonly ModelMeshPart[] modelMeshParts;
internal ModelMeshPartCollection(ModelMeshPart[] modelMeshParts) internal ModelMeshPartCollection(ModelMeshPart[] modelMeshParts)
: base(modelMeshParts) : base(modelMeshParts)
@ -29,7 +29,7 @@ namespace ANX.Framework.Graphics
public struct Enumerator : IEnumerator<ModelMeshPart>, IDisposable, IEnumerator public struct Enumerator : IEnumerator<ModelMeshPart>, IDisposable, IEnumerator
{ {
private ModelMeshPart[] wrappedArray; private readonly ModelMeshPart[] wrappedArray;
private int position; private int position;
public ModelMeshPart Current public ModelMeshPart Current

View File

@ -1,3 +1,4 @@
using System;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
@ -6,11 +7,12 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
[PercentageComplete(100)] [PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class SamplerStateCollection public sealed class SamplerStateCollection
{ {
private SamplerState[] samplerStates; private readonly SamplerState[] samplerStates;
private GraphicsDevice graphics; private readonly GraphicsDevice graphics;
public SamplerStateCollection(GraphicsDevice graphics, int maxSamplers) public SamplerStateCollection(GraphicsDevice graphics, int maxSamplers)
{ {
@ -25,6 +27,9 @@ namespace ANX.Framework.Graphics
{ {
get get
{ {
if (index < 0 || index >= samplerStates.Length)
throw new ArgumentOutOfRangeException("index");
return samplerStates[index]; return samplerStates[index];
} }
set set

View File

@ -17,8 +17,11 @@ namespace ANX.Framework.NonXNA
public interface INativeEffectParameter public interface INativeEffectParameter
{ {
string Name { get; } string Name { get; }
string Semantic { get; } string Semantic { get; }
int ColumnCount { get; }
int RowCount { get; }
EffectParameterClass ParameterClass { get; }
EffectParameterType ParameterType { get; }
#region GetValue #region GetValue
bool GetValueBoolean(); bool GetValueBoolean();

View File

@ -255,12 +255,11 @@ namespace ANX.RenderSystem.GL3
var result = new List<GraphicsAdapter>(); var result = new List<GraphicsAdapter>();
foreach (DisplayDevice device in DisplayDevice.AvailableDisplays) foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
{ {
var displayModeCollection = new DisplayModeCollection(); var resultingModes = new List<DisplayMode>();
foreach (string format in Enum.GetNames(typeof(SurfaceFormat))) foreach (string format in Enum.GetNames(typeof(SurfaceFormat)))
{ {
SurfaceFormat surfaceFormat = SurfaceFormat surfaceFormat = (SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format);
(SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format);
// TODO: device.BitsPerPixel // TODO: device.BitsPerPixel
if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false) if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false)
@ -268,12 +267,10 @@ namespace ANX.RenderSystem.GL3
continue; continue;
} }
var modes = new List<DisplayMode>();
foreach (DisplayResolution res in device.AvailableResolutions) foreach (DisplayResolution res in device.AvailableResolutions)
{ {
float aspect = (float)res.Width / (float)res.Height; float aspect = (float)res.Width / (float)res.Height;
modes.Add(new DisplayMode resultingModes.Add(new DisplayMode
{ {
AspectRatio = aspect, AspectRatio = aspect,
Width = res.Width, Width = res.Width,
@ -282,13 +279,11 @@ namespace ANX.RenderSystem.GL3
Format = surfaceFormat, Format = surfaceFormat,
}); });
} }
displayModeCollection[surfaceFormat] = modes.ToArray();
} }
GraphicsAdapter newAdapter = new GraphicsAdapter var newAdapter = new GraphicsAdapter
{ {
SupportedDisplayModes = displayModeCollection, SupportedDisplayModes = new DisplayModeCollection(resultingModes),
IsDefaultAdapter = device.IsPrimary, IsDefaultAdapter = device.IsPrimary,
// TODO: // TODO:

View File

@ -20,31 +20,40 @@ namespace ANX.RenderSystem.GL3
#endregion #endregion
#region Public #region Public
/// <summary> /// <summary>
/// The name of the effect parameter. /// The name of the effect parameter.
/// </summary> /// </summary>
public string Name public string Name { get; private set; }
{
get; /// <summary>
private set; /// The index of the uniform.
} /// </summary>
public int UniformIndex { get; private set; }
public string Semantic public string Semantic
{ {
get get { throw new NotSupportedException(); }
{
throw new NotSupportedException();
}
} }
/// <summary> public int ColumnCount
/// The index of the uniform. {
/// </summary> get { throw new NotImplementedException(); }
public int UniformIndex }
{
get; public int RowCount
private set; {
} get { throw new NotImplementedException(); }
}
public EffectParameterClass ParameterClass
{
get { throw new NotImplementedException(); }
}
public EffectParameterType ParameterType
{
get { throw new NotImplementedException(); }
}
#endregion #endregion
#region Constructor #region Constructor

View File

@ -1,6 +1,7 @@
#region Using Statements #region Using Statements
using System; using System;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D; using SharpDX.Direct3D;
using SharpDX.DXGI; using SharpDX.DXGI;
@ -174,29 +175,32 @@ namespace ANX.RenderSystem.Windows.DX11
#region Translate (VertexElement) #region Translate (VertexElement)
public static string Translate(ref VertexElement element) public static string Translate(ref VertexElement element)
{ {
//TODO: map the other Usages //TODO: map the other Usages
if (element.VertexElementUsage == VertexElementUsage.TextureCoordinate) if (element.VertexElementUsage == VertexElementUsage.TextureCoordinate)
return "TEXCOORD"; return "TEXCOORD";
else
return element.VertexElementUsage.ToString().ToUpperInvariant(); return element.VertexElementUsage.ToString().ToUpperInvariant();
} }
#endregion #endregion
#region CalculateVertexCount #region CalculateVertexCount
public static int CalculateVertexCount(PrimitiveType type, int primitiveCount) public static int CalculateVertexCount(PrimitiveType type, int primitiveCount)
{ {
if (type == PrimitiveType.TriangleList) switch (type)
return primitiveCount * 3; {
else if (type == PrimitiveType.LineList) case PrimitiveType.TriangleList:
return primitiveCount * 2; return primitiveCount * 3;
else if (type == PrimitiveType.LineStrip) case PrimitiveType.LineList:
return primitiveCount + 1; return primitiveCount * 2;
else if (type == PrimitiveType.TriangleStrip) case PrimitiveType.LineStrip:
return primitiveCount + 2; 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 #region ConvertVertexElementFormat
public static Format ConvertVertexElementFormat(VertexElementFormat format) 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."); 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
} }
} }

View File

@ -172,10 +172,10 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
PreventSystemChange(); PreventSystemChange();
SharpDX.DXGI.Factory factory = new Factory(); var factory = new Factory();
List<GraphicsAdapter> adapterList = new List<GraphicsAdapter>(); var adapterList = new List<GraphicsAdapter>();
DisplayModeCollection displayModeCollection = new DisplayModeCollection(); var resultingModes = new List<DisplayMode>();
for (int i = 0; i < factory.GetAdapterCount(); i++) for (int i = 0; i < factory.GetAdapterCount(); i++)
{ {
@ -196,7 +196,8 @@ namespace ANX.RenderSystem.Windows.DX10
using (Output adapterOutput = adapter.Outputs[0]) 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) foreach (ModeDescription modeDescription in modeList)
{ {
DisplayMode displayMode = new DisplayMode() 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 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); adapterList.Add(ga);
} }

View File

@ -11,34 +11,44 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.RenderSystem.Windows.DX10 namespace ANX.RenderSystem.Windows.DX10
{ {
[PercentageComplete(70)] [PercentageComplete(50)]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")] [Developer("Glatzemann")]
public class EffectParameter_DX10 : INativeEffectParameter public class EffectParameter_DX10 : INativeEffectParameter
{ {
#region Public #region Public
public Dx10.EffectVariable NativeParameter public Dx10.EffectVariable NativeParameter { get; internal set; }
{
get;
internal set;
}
public string Name public string Name
{ {
get get { return NativeParameter.Description.Name; }
{ }
return NativeParameter.Description.Name;
}
}
public string Semantic public string Semantic
{ {
get get { return NativeParameter.Description.Semantic; }
{
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) #region SetValue (bool)
public void SetValue(bool value) public void SetValue(bool value)

View File

@ -8,6 +8,7 @@ using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
using SharpDX.DXGI; using SharpDX.DXGI;
using ANX.Framework.NonXNA.Development; using ANX.Framework.NonXNA.Development;
using System.Collections.ObjectModel;
#endregion #endregion
@ -160,14 +161,14 @@ namespace ANX.RenderSystem.Windows.DX11
#endregion #endregion
#region GetAdapterList #region GetAdapterList
public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList() public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{ {
PreventSystemChange(); PreventSystemChange();
var factory = new Factory(); var factory = new Factory();
List<GraphicsAdapter> adapterList = new List<GraphicsAdapter>(); var adapterList = new List<GraphicsAdapter>();
DisplayModeCollection displayModeCollection = new DisplayModeCollection(); var resultingModes = new List<DisplayMode>();
for (int i = 0; i < factory.GetAdapterCount(); i++) 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)) foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced))
{ {
DisplayMode displayMode = new DisplayMode() var displayMode = new DisplayMode
{ {
Format = DxFormatConverter.Translate(modeDescription.Format), Format = DxFormatConverter.Translate(modeDescription.Format),
Width = modeDescription.Width, 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 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... break; //TODO: for the moment only adapter output 0 is interesting...
} }
ga.SupportedDisplayModes = displayModeCollection; ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes);
adapterList.Add(ga); adapterList.Add(ga);
} }

View File

@ -11,34 +11,44 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.RenderSystem.Windows.DX11 namespace ANX.RenderSystem.Windows.DX11
{ {
[PercentageComplete(60)] [PercentageComplete(50)]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")] [Developer("Glatzemann")]
public class EffectParameter_DX11 : INativeEffectParameter public class EffectParameter_DX11 : INativeEffectParameter
{ {
#region Public #region Public
public Dx11.EffectVariable NativeParameter public Dx11.EffectVariable NativeParameter { get; internal set; }
{
get;
internal set;
}
public string Name public string Name
{ {
get get { return NativeParameter.Description.Name; }
{ }
return NativeParameter.Description.Name;
}
}
public string Semantic public string Semantic
{ {
get get { return NativeParameter.Description.Semantic; }
{
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) #region SetValue (bool)
public void SetValue(bool value) public void SetValue(bool value)
@ -283,5 +293,5 @@ namespace ANX.RenderSystem.Windows.DX11
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion #endregion
} }
} }

View File

@ -33,6 +33,26 @@ namespace ANX.RenderSystem.Windows.Metro
throw new NotSupportedException(); 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 #endregion
#region Constructor #region Constructor

View File

@ -86,15 +86,15 @@
</Tags> </Tags>
</Sample> </Sample>
<Sample> <Sample>
<Name>BasicEffectSample</Name> <Name>BasicEffectSample</Name>
<Description>A Sample demonstrating all possible uses of the BasicEffect class.</Description> <Description>A Sample demonstrating all possible uses of the BasicEffect class.</Description>
<ExecPath>BasicEffectSample\bin\x86\Debug\BasicEffectSample.exe</ExecPath> <ExecPath>BasicEffectSample\bin\x86\Debug\BasicEffectSample.exe</ExecPath>
<Categorie>Rendering</Categorie> <Categorie>Rendering</Categorie>
<Tags> <Tags>
<Tag>3D</Tag> <Tag>3D</Tag>
</Tags> </Tags>
</Sample> </Sample>
<Sample> <Sample>
<Name>SpriteSample</Name> <Name>SpriteSample</Name>