- Implemented some GetData methods in the Vertex and Index Buffer implementations

- Added developer, PercentageComplete and TestState attributes
- Added Event to the FrameworkDispatcher which will be used by the components that need it (audio etc.)
- Some more refactorings, regions, etc.
This commit is contained in:
SND\AstrorEnales_cp 2012-09-04 21:36:46 +00:00
parent 7031e5b44e
commit 3316d46dba
39 changed files with 963 additions and 1136 deletions

View File

@ -442,6 +442,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" /> <Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" /> <Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" /> <Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" /> <Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
<Compile Include="NonXNA\ThreadHelper.cs" /> <Compile Include="NonXNA\ThreadHelper.cs" />
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" /> <Compile Include="NonXNA\Windows8\AssetsHelper.cs" />

View File

@ -442,6 +442,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" /> <Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" /> <Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" /> <Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" /> <Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
<Compile Include="NonXNA\ThreadHelper.cs" /> <Compile Include="NonXNA\ThreadHelper.cs" />
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" /> <Compile Include="NonXNA\Windows8\AssetsHelper.cs" />

View File

@ -444,6 +444,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" /> <Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" /> <Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" /> <Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" /> <Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
<Compile Include="NonXNA\ThreadHelper.cs" /> <Compile Include="NonXNA\ThreadHelper.cs" />
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" /> <Compile Include="NonXNA\Windows8\AssetsHelper.cs" />

View File

@ -445,6 +445,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" /> <Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" /> <Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" /> <Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" /> <Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
<Compile Include="NonXNA\ThreadHelper.cs" /> <Compile Include="NonXNA\ThreadHelper.cs" />
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" /> <Compile Include="NonXNA\Windows8\AssetsHelper.cs" />

View File

@ -1,4 +1,5 @@
using System; using System;
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
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -6,11 +7,17 @@ using System;
namespace ANX.Framework namespace ANX.Framework
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Tested)]
[Developer("AstrorEnales")]
public static class FrameworkDispatcher public static class FrameworkDispatcher
{ {
internal static event Action OnUpdate;
public static void Update() public static void Update()
{ {
throw new NotImplementedException(); if (OnUpdate != null)
OnUpdate();
} }
} }
} }

View File

@ -1,9 +1,6 @@
#region Using Statements
using System; using System;
using ANX.Framework;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -11,14 +8,13 @@ using System.Collections.ObjectModel;
namespace ANX.Framework.GamerServices namespace ANX.Framework.GamerServices
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Tested)]
public interface IAvatarAnimation public interface IAvatarAnimation
{ {
ReadOnlyCollection<Matrix> BoneTransforms { get; } ReadOnlyCollection<Matrix> BoneTransforms { get; }
TimeSpan CurrentPosition { get; set; } TimeSpan CurrentPosition { get; set; }
AvatarExpression Expression { get; } AvatarExpression Expression { get; }
TimeSpan Length { get; } TimeSpan Length { get; }
void Update(TimeSpan elapsedAnimationTime, bool loop); void Update(TimeSpan elapsedAnimationTime, bool loop);

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.RenderSystem;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -11,7 +12,6 @@ namespace ANX.Framework.Graphics
public class GraphicsDevice : IDisposable public class GraphicsDevice : IDisposable
{ {
#region Private Members #region Private Members
private INativeGraphicsDevice nativeDevice;
private IndexBuffer indexBuffer; private IndexBuffer indexBuffer;
private SamplerStateCollection samplerStateCollection; private SamplerStateCollection samplerStateCollection;
private Viewport viewport; private Viewport viewport;
@ -52,8 +52,8 @@ namespace ANX.Framework.Graphics
// TODO: get maximum number of sampler states from capabilities // TODO: get maximum number of sampler states from capabilities
this.samplerStateCollection = new SamplerStateCollection(this, 8); this.samplerStateCollection = new SamplerStateCollection(this, 8);
this.textureCollection = new TextureCollection(); this.textureCollection = new TextureCollection(16);
this.vertexTextureCollection = new TextureCollection(); this.vertexTextureCollection = new TextureCollection(16);
this.BlendState = BlendState.Opaque; this.BlendState = BlendState.Opaque;
this.DepthStencilState = DepthStencilState.Default; this.DepthStencilState = DepthStencilState.Default;
@ -71,13 +71,9 @@ namespace ANX.Framework.Graphics
{ {
ClearOptions options = ClearOptions.Target; ClearOptions options = ClearOptions.Target;
if (this.currentPresentationParameters.DepthStencilFormat != DepthFormat.None) if (this.currentPresentationParameters.DepthStencilFormat != DepthFormat.None)
{
options |= ClearOptions.DepthBuffer; options |= ClearOptions.DepthBuffer;
}
if (this.currentPresentationParameters.DepthStencilFormat == DepthFormat.Depth24Stencil8) if (this.currentPresentationParameters.DepthStencilFormat == DepthFormat.Depth24Stencil8)
{
options |= ClearOptions.Stencil; options |= ClearOptions.Stencil;
}
Clear(options, color, 1, 0); Clear(options, color, 1, 0);
// nativeDevice.Clear(ref color); // nativeDevice.Clear(ref color);
@ -93,17 +89,18 @@ namespace ANX.Framework.Graphics
if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer && if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer &&
this.currentPresentationParameters.DepthStencilFormat == DepthFormat.None) this.currentPresentationParameters.DepthStencilFormat == DepthFormat.None)
{ {
throw new InvalidOperationException("The depth buffer can only be cleared if it exists. The current DepthStencilFormat is DepthFormat.None"); throw new InvalidOperationException("The depth buffer can only be cleared if it exists. The current " +
"DepthStencilFormat is DepthFormat.None");
} }
if ((options & ClearOptions.Stencil) == ClearOptions.Stencil && if ((options & ClearOptions.Stencil) == ClearOptions.Stencil &&
this.currentPresentationParameters.DepthStencilFormat != DepthFormat.Depth24Stencil8) this.currentPresentationParameters.DepthStencilFormat != DepthFormat.Depth24Stencil8)
{ {
throw new InvalidOperationException("The stencil buffer can only be cleared if it exists. The current DepthStencilFormat is not DepthFormat.Depth24Stencil8"); throw new InvalidOperationException("The stencil buffer can only be cleared if it exists. The current " +
"DepthStencilFormat is not DepthFormat.Depth24Stencil8");
} }
NativeDevice.Clear(options, color, depth, stencil);
nativeDevice.Clear(options, color, depth, stencil);
} }
#endregion // Clear #endregion // Clear
@ -111,10 +108,11 @@ namespace ANX.Framework.Graphics
#region Present #region Present
public void Present() public void Present()
{ {
nativeDevice.Present(); NativeDevice.Present();
} }
public void Present(Nullable<Rectangle> sourceRectangle, Nullable<Rectangle> destinationRectangle, IntPtr overrideWindowHandle) public void Present(Nullable<Rectangle> sourceRectangle, Nullable<Rectangle> destinationRectangle,
IntPtr overrideWindowHandle)
{ {
//TODO: implement //TODO: implement
throw new NotImplementedException(); throw new NotImplementedException();
@ -126,13 +124,13 @@ namespace ANX.Framework.Graphics
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount) int startIndex, int primitiveCount)
{ {
nativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex, NativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
primitiveCount); primitiveCount);
} }
public void DrawPrimitives(PrimitiveType primitiveType, int startVertex, int primitiveCount) public void DrawPrimitives(PrimitiveType primitiveType, int startVertex, int primitiveCount)
{ {
nativeDevice.DrawPrimitives(primitiveType, startVertex, primitiveCount); NativeDevice.DrawPrimitives(primitiveType, startVertex, primitiveCount);
} }
#endregion #endregion
@ -140,7 +138,7 @@ namespace ANX.Framework.Graphics
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount) int startIndex, int primitiveCount, int instanceCount)
{ {
nativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex, NativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
primitiveCount, instanceCount); primitiveCount, instanceCount);
} }
#endregion #endregion
@ -149,8 +147,8 @@ namespace ANX.Framework.Graphics
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
short[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType short[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
{ {
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>(); var vertexDeclaration = VertexTypeHelper.GetDeclaration<T>();
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, NativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits); indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
} }
@ -158,15 +156,15 @@ namespace ANX.Framework.Graphics
short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
where T : struct, IVertexType where T : struct, IVertexType
{ {
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, NativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits); indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
} }
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
int[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType int[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
{ {
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>(); var vertexDeclaration = VertexTypeHelper.GetDeclaration<T>();
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, NativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits); indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
} }
@ -174,7 +172,7 @@ namespace ANX.Framework.Graphics
int[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) int[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
where T : struct, IVertexType where T : struct, IVertexType
{ {
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, NativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits); indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
} }
#endregion #endregion
@ -183,24 +181,17 @@ namespace ANX.Framework.Graphics
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount) public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount)
where T : struct, IVertexType where T : struct, IVertexType
{ {
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>(); var vertexDeclaration = VertexTypeHelper.GetDeclaration<T>();
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration); NativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
} }
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount,
VertexDeclaration vertexDeclaration) where T : struct, IVertexType VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{ {
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration); NativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
} }
#endregion #endregion
private VertexDeclaration GetDeclarationForDraw<T>() where T : struct, IVertexType
{
//TODO: cache the instances to avoid reflection overhead
IVertexType vertexType = Activator.CreateInstance<T>();
return vertexType.VertexDeclaration;
}
#if XNAEXT #if XNAEXT
#region SetConstantBuffer #region SetConstantBuffer
/// <summary> /// <summary>
@ -210,7 +201,7 @@ namespace ANX.Framework.Graphics
/// <param name="constantBuffer">The managed constant buffer object to bind.</param> /// <param name="constantBuffer">The managed constant buffer object to bind.</param>
public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer) public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer)
{ {
this.nativeDevice.SetConstantBuffer(slot, constantBuffer); NativeDevice.SetConstantBuffer(slot, constantBuffer);
} }
/// <summary> /// <summary>
@ -221,9 +212,7 @@ namespace ANX.Framework.Graphics
public void SetConstantBuffers(params ConstantBuffer[] constantBuffers) public void SetConstantBuffers(params ConstantBuffer[] constantBuffers)
{ {
for (int slot = 0; slot < constantBuffers.Length; slot++) for (int slot = 0; slot < constantBuffers.Length; slot++)
{ NativeDevice.SetConstantBuffer(slot, constantBuffers[slot]);
this.nativeDevice.SetConstantBuffer(slot, constantBuffers[slot]);
}
} }
#endregion #endregion
@ -234,20 +223,20 @@ namespace ANX.Framework.Graphics
{ {
VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer) }; VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer) };
this.currentVertexBufferBindings = bindings; this.currentVertexBufferBindings = bindings;
this.nativeDevice.SetVertexBuffers(bindings); NativeDevice.SetVertexBuffers(bindings);
} }
public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset) public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
{ {
VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer, vertexOffset) }; VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer, vertexOffset) };
this.currentVertexBufferBindings = bindings; this.currentVertexBufferBindings = bindings;
this.nativeDevice.SetVertexBuffers(bindings); NativeDevice.SetVertexBuffers(bindings);
} }
public void SetVertexBuffers(params Graphics.VertexBufferBinding[] vertexBuffers) public void SetVertexBuffers(params Graphics.VertexBufferBinding[] vertexBuffers)
{ {
this.currentVertexBufferBindings = vertexBuffers; this.currentVertexBufferBindings = vertexBuffers;
nativeDevice.SetVertexBuffers(vertexBuffers); NativeDevice.SetVertexBuffers(vertexBuffers);
} }
#endregion // SetVertexBuffer #endregion // SetVertexBuffer
@ -259,25 +248,23 @@ namespace ANX.Framework.Graphics
{ {
RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget) }; RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget) };
this.currentRenderTargetBindings = renderTargetBindings; this.currentRenderTargetBindings = renderTargetBindings;
nativeDevice.SetRenderTargets(renderTargetBindings); NativeDevice.SetRenderTargets(renderTargetBindings);
} }
else else
{ NativeDevice.SetRenderTargets(null);
nativeDevice.SetRenderTargets(null);
}
} }
public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace) public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
{ {
RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget, cubeMapFace) }; RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget, cubeMapFace) };
this.currentRenderTargetBindings = renderTargetBindings; this.currentRenderTargetBindings = renderTargetBindings;
nativeDevice.SetRenderTargets(renderTargetBindings); NativeDevice.SetRenderTargets(renderTargetBindings);
} }
public void SetRenderTargets(params RenderTargetBinding[] renderTargets) public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{ {
this.currentRenderTargetBindings = renderTargets; this.currentRenderTargetBindings = renderTargets;
nativeDevice.SetRenderTargets(renderTargets); NativeDevice.SetRenderTargets(renderTargets);
} }
#endregion // SetRenderTarget #endregion // SetRenderTarget
@ -285,17 +272,17 @@ namespace ANX.Framework.Graphics
#region GetBackBufferData<T> #region GetBackBufferData<T>
public void GetBackBufferData<T>(Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct public void GetBackBufferData<T>(Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct
{ {
nativeDevice.GetBackBufferData<T>(rect, data, startIndex, elementCount); NativeDevice.GetBackBufferData<T>(rect, data, startIndex, elementCount);
} }
public void GetBackBufferData<T>(T[] data) where T : struct public void GetBackBufferData<T>(T[] data) where T : struct
{ {
nativeDevice.GetBackBufferData<T>(data); NativeDevice.GetBackBufferData<T>(data);
} }
public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct
{ {
nativeDevice.GetBackBufferData<T>(data, startIndex, elementCount); NativeDevice.GetBackBufferData<T>(data, startIndex, elementCount);
} }
#endregion // GetBackBufferData<T> #endregion // GetBackBufferData<T>
@ -354,7 +341,7 @@ namespace ANX.Framework.Graphics
} }
// reset presentation parameters // reset presentation parameters
nativeDevice.ResizeBuffers(presentationParameters); NativeDevice.ResizeBuffers(presentationParameters);
this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth, this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight); presentationParameters.BackBufferHeight);
@ -374,10 +361,11 @@ namespace ANX.Framework.Graphics
{ {
if (isDisposed == false) if (isDisposed == false)
{ {
if (nativeDevice != null) isDisposed = true;
if (NativeDevice != null)
{ {
nativeDevice.Dispose(); NativeDevice.Dispose();
nativeDevice = null; NativeDevice = null;
} }
raise_Disposing(this, EventArgs.Empty); raise_Disposing(this, EventArgs.Empty);
@ -622,108 +610,90 @@ namespace ANX.Framework.Graphics
internal INativeGraphicsDevice NativeDevice internal INativeGraphicsDevice NativeDevice
{ {
get get;
{ set;
return this.nativeDevice;
}
set
{
this.nativeDevice = value;
}
} }
internal void Recreate(PresentationParameters presentationParameters) internal void Recreate(PresentationParameters presentationParameters)
{ {
if (nativeDevice != null) if (NativeDevice != null)
{ {
nativeDevice.Dispose(); NativeDevice.Dispose();
raise_ResourceDestroyed(this, new ResourceDestroyedEventArgs("NativeGraphicsDevice", nativeDevice)); raise_ResourceDestroyed(this, new ResourceDestroyedEventArgs("NativeGraphicsDevice", NativeDevice));
nativeDevice = null; NativeDevice = null;
} }
if (nativeDevice == null) if (NativeDevice == null)
{ {
this.currentPresentationParameters = presentationParameters; this.currentPresentationParameters = presentationParameters;
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>(); var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
nativeDevice = creator.CreateGraphicsDevice(presentationParameters); NativeDevice = creator.CreateGraphicsDevice(presentationParameters);
this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight); presentationParameters.BackBufferHeight);
raise_ResourceCreated(this, new ResourceCreatedEventArgs(nativeDevice)); raise_ResourceCreated(this, new ResourceCreatedEventArgs(NativeDevice));
GraphicsResourceTracker.Instance.UpdateGraphicsDeviceReference(this); GraphicsResourceTracker.Instance.UpdateGraphicsDeviceReference(this);
if (this.indexBuffer != null) if (this.indexBuffer != null)
{
NativeDevice.SetIndexBuffer(this.indexBuffer); NativeDevice.SetIndexBuffer(this.indexBuffer);
}
if (this.currentVertexBufferBindings != null) if (this.currentVertexBufferBindings != null)
{
NativeDevice.SetVertexBuffers(this.currentVertexBufferBindings); NativeDevice.SetVertexBuffers(this.currentVertexBufferBindings);
}
if (this.blendState != null) if (this.blendState != null)
{
this.blendState.NativeBlendState.Apply(this); this.blendState.NativeBlendState.Apply(this);
}
if (this.rasterizerState != null) if (this.rasterizerState != null)
{
this.rasterizerState.NativeRasterizerState.Apply(this); this.rasterizerState.NativeRasterizerState.Apply(this);
}
if (this.depthStencilState != null) if (this.depthStencilState != null)
{
this.depthStencilState.NativeDepthStencilState.Apply(this); this.depthStencilState.NativeDepthStencilState.Apply(this);
}
if (this.samplerStateCollection != null) if (this.samplerStateCollection != null)
{ {
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (this.samplerStateCollection[i] != null) if (this.samplerStateCollection[i] != null)
{
this.samplerStateCollection[i].NativeSamplerState.Apply(this, i); this.samplerStateCollection[i].NativeSamplerState.Apply(this, i);
} }
} }
} }
} }
}
protected void raise_Disposing(object sender, EventArgs args) protected void raise_Disposing(object sender, EventArgs args)
{ {
if (Disposing != null) RaiseIfNotNull(Disposing, sender, args);
Disposing(sender, args);
} }
protected void raise_DeviceResetting(object sender, EventArgs args) protected void raise_DeviceResetting(object sender, EventArgs args)
{ {
if (DeviceResetting != null) RaiseIfNotNull(DeviceResetting, sender, args);
DeviceResetting(sender, args);
} }
protected void raise_DeviceReset(object sender, EventArgs args) protected void raise_DeviceReset(object sender, EventArgs args)
{ {
if (DeviceReset != null) RaiseIfNotNull(DeviceReset, sender, args);
DeviceReset(sender, args);
} }
protected void raise_DeviceLost(object sender, EventArgs args) protected void raise_DeviceLost(object sender, EventArgs args)
{ {
if (DeviceLost != null) RaiseIfNotNull(DeviceLost, sender, args);
DeviceLost(sender, args);
} }
protected void raise_ResourceCreated(object sender, ResourceCreatedEventArgs args) protected void raise_ResourceCreated(object sender, ResourceCreatedEventArgs args)
{ {
if (ResourceCreated != null) RaiseIfNotNull(ResourceCreated, sender, args);
ResourceCreated(sender, args);
} }
protected void raise_ResourceDestroyed(object sender, ResourceDestroyedEventArgs args) protected void raise_ResourceDestroyed(object sender, ResourceDestroyedEventArgs args)
{ {
if (ResourceDestroyed != null) RaiseIfNotNull(ResourceDestroyed, sender, args);
ResourceDestroyed(sender, args); }
private void RaiseIfNotNull<T>(EventHandler<T> handler, object sender, T args) where T : EventArgs
{
if (handler != null)
handler(sender, args);
} }
} }
} }

View File

@ -1,7 +1,5 @@
#region Using Statements
using System; using System;
using ANX.Framework.NonXNA;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -11,16 +9,25 @@ namespace ANX.Framework.Graphics
{ {
public sealed class TextureCollection public sealed class TextureCollection
{ {
private Texture[] textures;
public Texture this[int index] public Texture this[int index]
{ {
get get
{ {
throw new NotImplementedException(); return textures[index];
} }
set set
{ {
throw new NotImplementedException(); textures[index] = value;
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
creator.SetTextureSampler(index, value);
} }
} }
internal TextureCollection(int maxNumberOfTextures)
{
textures = new Texture[maxNumberOfTextures];
}
} }
} }

View File

@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input.Touch namespace ANX.Framework.Input.Touch
{ {
[PercentageComplete(90)] [PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)] [TestState(TestStateAttribute.TestState.Untested)]
public struct TouchCollection : IList<TouchLocation>, ICollection<TouchLocation>, IEnumerable<TouchLocation>, IEnumerable public struct TouchCollection : IList<TouchLocation>, ICollection<TouchLocation>, IEnumerable<TouchLocation>, IEnumerable
{ {
@ -67,7 +67,7 @@ namespace ANX.Framework.Input.Touch
private List<TouchLocation> locations; private List<TouchLocation> locations;
#endregion #endregion
#region Public (TODO) #region Public
public TouchLocation this[int index] public TouchLocation this[int index]
{ {
get get
@ -92,7 +92,7 @@ namespace ANX.Framework.Input.Touch
{ {
get get
{ {
throw new NotImplementedException(); return true;
} }
} }
@ -100,7 +100,7 @@ namespace ANX.Framework.Input.Touch
{ {
get get
{ {
throw new NotImplementedException(); return true;
} }
} }
#endregion #endregion

View File

@ -46,5 +46,7 @@ namespace ANX.Framework.NonXNA
EffectSourceLanguage GetStockShaderSourceLanguage { get; } EffectSourceLanguage GetStockShaderSourceLanguage { get; }
ReadOnlyCollection<GraphicsAdapter> GetAdapterList(); ReadOnlyCollection<GraphicsAdapter> GetAdapterList();
void SetTextureSampler(int index, Texture value);
} }
} }

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using ANX.Framework.Graphics;
namespace ANX.Framework.NonXNA.RenderSystem
{
internal static class VertexTypeHelper
{
private static Dictionary<Type, IVertexType> rememberedInstances = new Dictionary<Type, IVertexType>();
public static VertexDeclaration GetDeclaration<T>() where T : struct, IVertexType
{
Type type = typeof(T);
if (rememberedInstances.ContainsKey(type) == false)
rememberedInstances.Add(type, Activator.CreateInstance<T>());
return rememberedInstances[type].VertexDeclaration;
}
}
}

View File

@ -1,8 +1,3 @@
#region Using Statements
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license

View File

@ -371,7 +371,7 @@ namespace ANX.Framework
{ {
Quaternion result; Quaternion result;
Quaternion.Slerp(ref quaternion1, ref quaternion2, amount, out result); Quaternion.Slerp(ref quaternion1, ref quaternion2, amount, out result);
return result; throw new NotImplementedException(); return result;
} }
public static void Slerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result) public static void Slerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
@ -409,9 +409,7 @@ namespace ANX.Framework
public override string ToString() public override string ToString()
{ {
var culture = CultureInfo.CurrentCulture; var culture = CultureInfo.CurrentCulture;
return "{X:" + X.ToString(culture) + return "{X:" + X.ToString(culture) + " Y:" + Y.ToString(culture) + " Z:" + Z.ToString(culture) +
" Y:" + Y.ToString(culture) +
" Z:" + Z.ToString(culture) +
" W:" + W.ToString(culture) + "}"; " W:" + W.ToString(culture) + "}";
} }
#endregion #endregion

View File

@ -1,6 +1,7 @@
using System.IO; using System.IO;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.PlatformSystem; using ANX.Framework.NonXNA.PlatformSystem;
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
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -8,6 +9,9 @@ using ANX.Framework.NonXNA.PlatformSystem;
namespace ANX.Framework namespace ANX.Framework
{ {
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
public static class TitleContainer public static class TitleContainer
{ {
private static INativeTitleContainer nativeImplementation; private static INativeTitleContainer nativeImplementation;

View File

@ -87,7 +87,6 @@
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX10.cs" /> <Compile Include="RasterizerState_DX10.cs" />
<Compile Include="RenderTarget2D_DX10.cs" /> <Compile Include="RenderTarget2D_DX10.cs" />

View File

@ -87,7 +87,6 @@
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX10.cs" /> <Compile Include="RasterizerState_DX10.cs" />
<Compile Include="RenderTarget2D_DX10.cs" /> <Compile Include="RenderTarget2D_DX10.cs" />

View File

@ -88,7 +88,6 @@
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX10.cs" /> <Compile Include="RasterizerState_DX10.cs" />
<Compile Include="RenderTarget2D_DX10.cs" /> <Compile Include="RenderTarget2D_DX10.cs" />

View File

@ -89,7 +89,6 @@
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX10.cs" /> <Compile Include="IndexBuffer_DX10.cs" />
<Compile Include="EffectPass_DX10.cs" /> <Compile Include="EffectPass_DX10.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX10.cs" /> <Compile Include="RasterizerState_DX10.cs" />
<Compile Include="RenderTarget2D_DX10.cs" /> <Compile Include="RenderTarget2D_DX10.cs" />

View File

@ -1,4 +1,3 @@
#region Using Statements
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -8,8 +7,7 @@ using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
using SharpDX.DXGI; using SharpDX.DXGI;
using Dx10 = SharpDX.Direct3D10;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -19,6 +17,7 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
public class Creator : IRenderSystemCreator public class Creator : IRenderSystemCreator
{ {
#region Public
public string Name public string Name
{ {
get { return "DirectX10"; } get { return "DirectX10"; }
@ -38,26 +37,40 @@ namespace ANX.RenderSystem.Windows.DX10
} }
} }
public EffectSourceLanguage GetStockShaderSourceLanguage
{
get
{
return EffectSourceLanguage.HLSL_FX;
}
}
#endregion
#region CreateGraphicsDevice
public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters) public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
{ {
PreventSystemChange(); PreventSystemChange();
return new GraphicsDeviceWindowsDX10(presentationParameters); return new GraphicsDeviceWindowsDX10(presentationParameters);
} }
#endregion
#region CreateIndexBuffer
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size, public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size,
int indexCount, BufferUsage usage) int indexCount, BufferUsage usage)
{ {
PreventSystemChange(); PreventSystemChange();
return new IndexBuffer_DX10(graphics, size, indexCount, usage); return new IndexBuffer_DX10(graphics, size, indexCount, usage);
} }
#endregion
#region CreateVertexBuffer
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer, public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer,
VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
PreventSystemChange(); PreventSystemChange();
return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage); return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage);
} }
#endregion
#if XNAEXT #if XNAEXT
#region CreateConstantBuffer #region CreateConstantBuffer
@ -70,100 +83,87 @@ namespace ANX.RenderSystem.Windows.DX10
#endregion #endregion
#endif #endif
#region CreateEffect
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode, public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode,
Stream pixelShaderByteCode) Stream pixelShaderByteCode)
{ {
PreventSystemChange(); PreventSystemChange();
return new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode); return new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode);
} }
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode) public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode)
{ {
PreventSystemChange(); PreventSystemChange();
return new Effect_DX10(graphics, managedEffect, byteCode); return new Effect_DX10(graphics, managedEffect, byteCode);
} }
#endregion
public Texture2D CreateTexture(GraphicsDevice graphics, string fileName) #region CreateTexture
public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height,
int mipCount)
{ {
PreventSystemChange(); PreventSystemChange();
return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount);
//TODO: implement
throw new NotImplementedException();
//GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
//SharpDX.Direct3D10.Texture2D nativeTexture = SharpDX.Direct3D10.Texture2D.FromFile<SharpDX.Direct3D10.Texture2D>(graphicsDX10.NativeDevice, fileName);
//Texture2D_DX10 texture = new Texture2D_DX10(graphics, nativeTexture.Description.Width, nativeTexture.Description.Height, FormatConverter.Translate(nativeTexture.Description.Format), nativeTexture.Description.MipLevels);
//texture.NativeTexture = nativeTexture;
//return texture;
} }
#endregion
#region CreateBlendState
public INativeBlendState CreateBlendState() public INativeBlendState CreateBlendState()
{ {
PreventSystemChange(); PreventSystemChange();
return new BlendState_DX10(); return new BlendState_DX10();
} }
#endregion
#region CreateRasterizerState
public INativeRasterizerState CreateRasterizerState() public INativeRasterizerState CreateRasterizerState()
{ {
PreventSystemChange(); PreventSystemChange();
return new RasterizerState_DX10(); return new RasterizerState_DX10();
} }
#endregion
#region CreateDepthStencilState
public INativeDepthStencilState CreateDepthStencilState() public INativeDepthStencilState CreateDepthStencilState()
{ {
PreventSystemChange(); PreventSystemChange();
return new DepthStencilState_DX10(); return new DepthStencilState_DX10();
} }
#endregion
#region CreateSamplerState
public INativeSamplerState CreateSamplerState() public INativeSamplerState CreateSamplerState()
{ {
PreventSystemChange(); PreventSystemChange();
return new SamplerState_DX10(); return new SamplerState_DX10();
} }
#endregion
#region GetShaderByteCode
public byte[] GetShaderByteCode(PreDefinedShader type) public byte[] GetShaderByteCode(PreDefinedShader type)
{ {
PreventSystemChange(); PreventSystemChange();
switch (type)
if (type == PreDefinedShader.SpriteBatch)
{ {
case PreDefinedShader.SpriteBatch:
return ShaderByteCode.SpriteBatchByteCode; return ShaderByteCode.SpriteBatchByteCode;
} case PreDefinedShader.AlphaTestEffect:
else if (type == PreDefinedShader.AlphaTestEffect)
{
return ShaderByteCode.AlphaTestEffectByteCode; return ShaderByteCode.AlphaTestEffectByteCode;
} case PreDefinedShader.BasicEffect:
else if (type == PreDefinedShader.BasicEffect)
{
return ShaderByteCode.BasicEffectByteCode; return ShaderByteCode.BasicEffectByteCode;
} case PreDefinedShader.DualTextureEffect:
else if (type == PreDefinedShader.DualTextureEffect)
{
return ShaderByteCode.DualTextureEffectByteCode; return ShaderByteCode.DualTextureEffectByteCode;
} case PreDefinedShader.EnvironmentMapEffect:
else if (type == PreDefinedShader.EnvironmentMapEffect)
{
return ShaderByteCode.EnvironmentMapEffectByteCode; return ShaderByteCode.EnvironmentMapEffectByteCode;
} case PreDefinedShader.SkinnedEffect:
else if (type == PreDefinedShader.SkinnedEffect)
{
return ShaderByteCode.SkinnedEffectByteCode; return ShaderByteCode.SkinnedEffectByteCode;
} }
throw new NotImplementedException("ByteCode for '" + type + "' is not yet available"); throw new NotImplementedException("ByteCode for '" + type + "' is not yet available");
} }
#endregion
public EffectSourceLanguage GetStockShaderSourceLanguage #region GetAdapterList
{
get
{
return EffectSourceLanguage.HLSL_FX;
}
}
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList() public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{ {
PreventSystemChange(); PreventSystemChange();
@ -177,7 +177,7 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
using (Adapter adapter = factory.GetAdapter(i)) using (Adapter adapter = factory.GetAdapter(i))
{ {
GraphicsAdapter ga = new GraphicsAdapter(); var ga = new GraphicsAdapter();
//ga.CurrentDisplayMode = ; //ga.CurrentDisplayMode = ;
//ga.Description = ; //ga.Description = ;
ga.DeviceId = adapter.Description.DeviceId; ga.DeviceId = adapter.Description.DeviceId;
@ -218,23 +218,18 @@ namespace ANX.RenderSystem.Windows.DX10
return new ReadOnlyCollection<GraphicsAdapter>(adapterList); return new ReadOnlyCollection<GraphicsAdapter>(adapterList);
} }
#endregion
public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, #region CreateRenderTarget
int mipCount)
{
PreventSystemChange();
return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount);
}
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap,
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
RenderTargetUsage usage)
{ {
PreventSystemChange(); PreventSystemChange();
return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat,
preferredMultiSampleCount, usage); preferredMultiSampleCount, usage);
} }
#endregion
#region PreventSystemChange #region PreventSystemChange
private void PreventSystemChange() private void PreventSystemChange()
@ -243,14 +238,25 @@ namespace ANX.RenderSystem.Windows.DX10
} }
#endregion #endregion
#region IsLanguageSupported
public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage) public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage)
{ {
return sourceLanguage == EffectSourceLanguage.HLSL_FX || sourceLanguage == EffectSourceLanguage.HLSL; return sourceLanguage == EffectSourceLanguage.HLSL_FX || sourceLanguage == EffectSourceLanguage.HLSL;
} }
#endregion
#region CreateOcclusionQuery (TODO) #region CreateOcclusionQuery (TODO)
public IOcclusionQuery CreateOcclusionQuery() public IOcclusionQuery CreateOcclusionQuery()
{ {
PreventSystemChange();
throw new NotImplementedException();
}
#endregion
#region SetTextureSampler (TODO)
public void SetTextureSampler(int index, Texture value)
{
PreventSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion #endregion

View File

@ -1,13 +1,6 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using SharpDX.Direct3D10; using SharpDX.Direct3D10;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -16,26 +9,19 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
public class EffectPass_DX10 : INativeEffectPass public class EffectPass_DX10 : INativeEffectPass
{ {
private EffectPass nativePass; public EffectPass NativePass { get; internal set; }
public EffectPass NativePass
{
get
{
return this.nativePass;
}
internal set
{
this.nativePass = value;
}
}
public string Name public string Name
{ {
get get
{ {
return nativePass.Description.Name; return NativePass.Description.Name;
} }
} }
internal EffectPass_DX10(EffectPass setNativePass)
{
NativePass = setNativePass;
}
} }
} }

View File

@ -1,71 +1,49 @@
#region Using Statements
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using ANX.Framework.Graphics;
using System.Text;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using SharpDX.Direct3D10; using Dx10 = SharpDX.Direct3D10;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
using EffectPass = ANX.Framework.Graphics.EffectPass;
namespace ANX.RenderSystem.Windows.DX10 namespace ANX.RenderSystem.Windows.DX10
{ {
public class EffectTechnique_DX10 : INativeEffectTechnique public class EffectTechnique_DX10 : INativeEffectTechnique
{ {
private EffectTechnique nativeTechnique; private Effect parentEffect;
private ANX.Framework.Graphics.Effect parentEffect;
internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect) public Dx10.EffectTechnique NativeTechnique { get; internal set; }
{
if (parentEffect == null)
{
throw new ArgumentNullException("parentEffect");
}
this.parentEffect = parentEffect;
}
public EffectTechnique NativeTechnique
{
get
{
return this.nativeTechnique;
}
internal set
{
this.nativeTechnique = value;
}
}
public string Name public string Name
{ {
get get
{ {
return nativeTechnique.Description.Name; return NativeTechnique.Description.Name;
} }
} }
public IEnumerable<EffectPass> Passes public IEnumerable<EffectPass> Passes
{ {
get get
{ {
for (int i = 0; i < nativeTechnique.Description.PassCount; i++) for (int i = 0; i < NativeTechnique.Description.PassCount; i++)
{ {
EffectPass_DX10 passDx10 = new EffectPass_DX10(); EffectPass_DX10 passDx10 = new EffectPass_DX10(NativeTechnique.GetPassByIndex(i));
passDx10.NativePass = nativeTechnique.GetPassByIndex(i);
EffectPass pass = new EffectPass(this.parentEffect); EffectPass pass = new EffectPass(this.parentEffect);
// TODO: wire up native pass and managed pass?
yield return pass; yield return pass;
} }
} }
} }
internal EffectTechnique_DX10(Effect parentEffect)
{
if (parentEffect == null)
throw new ArgumentNullException("parentEffect");
this.parentEffect = parentEffect;
}
} }
} }

View File

@ -1,15 +1,8 @@
#region Using Statements
using System; using System;
using System.Collections.Generic; using System.IO;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using SharpDX.Direct3D10;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
using SharpDX.Direct3D10;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -19,9 +12,11 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
public class IndexBuffer_DX10 : INativeIndexBuffer, IDisposable public class IndexBuffer_DX10 : INativeIndexBuffer, IDisposable
{ {
private SharpDX.Direct3D10.Buffer buffer;
private IndexElementSize size; private IndexElementSize size;
public SharpDX.Direct3D10.Buffer NativeBuffer { get; private set; }
#region Constructor
public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
this.size = size; this.size = size;
@ -29,19 +24,20 @@ namespace ANX.RenderSystem.Windows.DX10
//TODO: translate and use usage //TODO: translate and use usage
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; Device device = gd10 != null ? gd10.NativeDevice as Device : null;
InitializeBuffer(device, size, indexCount, usage); InitializeBuffer(device, size, indexCount, usage);
} }
internal IndexBuffer_DX10(SharpDX.Direct3D10.Device device, IndexElementSize size, int indexCount, BufferUsage usage) internal IndexBuffer_DX10(Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
this.size = size; this.size = size;
InitializeBuffer(device, size, indexCount, usage); InitializeBuffer(device, size, indexCount, usage);
} }
#endregion
private void InitializeBuffer(SharpDX.Direct3D10.Device device, IndexElementSize size, int indexCount, BufferUsage usage) #region InitializeBuffer
private void InitializeBuffer(Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
BufferDescription description = new BufferDescription() BufferDescription description = new BufferDescription()
{ {
@ -52,98 +48,85 @@ namespace ANX.RenderSystem.Windows.DX10
OptionFlags = ResourceOptionFlags.None OptionFlags = ResourceOptionFlags.None
}; };
this.buffer = new SharpDX.Direct3D10.Buffer(device, description); NativeBuffer = new SharpDX.Direct3D10.Buffer(device, description);
this.buffer.Unmap(); NativeBuffer.Unmap();
} }
#endregion
#region SetData
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
{ {
SetData<T>(graphicsDevice, data, 0, data.Length); SetData<T>(graphicsDevice, data, 0, data.Length);
} }
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
where T : struct
{ {
//TODO: check offsetInBytes parameter for bounds etc. //TODO: check offsetInBytes parameter for bounds etc.
GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); using (var stream = NativeBuffer.Map(MapMode.WriteDiscard))
IntPtr dataPointer = pinnedArray.AddrOfPinnedObject();
int dataLength = Marshal.SizeOf(typeof(T)) * data.Length;
unsafe
{
using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, true))
{ {
if (offsetInBytes > 0) if (offsetInBytes > 0)
{ stream.Seek(offsetInBytes, SeekOrigin.Current);
vData.Seek(offsetInBytes / (size == IndexElementSize.SixteenBits ? 2 : 4), System.IO.SeekOrigin.Begin);
}
using (var d = buffer.Map(MapMode.WriteDiscard))
{
if (startIndex > 0 || elementCount < data.Length) if (startIndex > 0 || elementCount < data.Length)
{
for (int i = startIndex; i < startIndex + elementCount; i++) for (int i = startIndex; i < startIndex + elementCount; i++)
{ stream.Write<T>(data[i]);
d.Write<T>(data[i]);
}
}
else else
{ for (int i = 0; i < data.Length; i++)
vData.CopyTo(d); stream.Write<T>(data[i]);
}
buffer.Unmap();
}
}
}
pinnedArray.Free(); NativeBuffer.Unmap();
}
} }
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
{ {
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount); SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
} }
public SharpDX.Direct3D10.Buffer NativeBuffer
{
get
{
return this.buffer;
}
}
public void Dispose()
{
if (this.buffer != null)
{
buffer.Dispose();
buffer = null;
}
}
#region INativeIndexBuffer Member
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
}
#endregion #endregion
#region INativeBuffer Member #region Dispose
public void Dispose()
{
if (NativeBuffer != null)
{
NativeBuffer.Dispose();
NativeBuffer = null;
}
}
#endregion
#region GetData
public void GetData<T>(T[] data) where T : struct public void GetData<T>(T[] data) where T : struct
{ {
throw new NotImplementedException(); using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, 0, data.Length);
NativeBuffer.Unmap();
}
} }
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
}
} }
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
{
using (var stream = NativeBuffer.Map(MapMode.Read))
{
if (offsetInBytes > 0)
stream.Seek(offsetInBytes, SeekOrigin.Current);
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
}
}
#endregion #endregion
} }
} }

View File

@ -1,71 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.RenderSystem.Windows.DX10
{
internal sealed class NativeMethods
{
// Not needed anymore, is in platforms now!
//[SuppressUnmanagedCodeSecurity, DllImport("user32.dll", CharSet = CharSet.Auto)]
//internal static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
//// Nested Types
//[StructLayout(LayoutKind.Sequential)]
//public struct Message
//{
// public IntPtr hWnd;
// public NativeMethods.WindowMessage msg;
// public IntPtr wParam;
// public IntPtr lParam;
// public uint time;
// public Point p;
//}
internal enum WindowMessage : uint
{
ActivateApplication = 0x1c,
Character = 0x102,
Close = 0x10,
Destroy = 2,
EnterMenuLoop = 0x211,
EnterSizeMove = 0x231,
ExitMenuLoop = 530,
ExitSizeMove = 0x232,
GetMinMax = 0x24,
KeyDown = 0x100,
KeyUp = 0x101,
LeftButtonDoubleClick = 0x203,
LeftButtonDown = 0x201,
LeftButtonUp = 0x202,
MiddleButtonDoubleClick = 0x209,
MiddleButtonDown = 0x207,
MiddleButtonUp = 520,
MouseFirst = 0x201,
MouseLast = 0x20d,
MouseMove = 0x200,
MouseWheel = 0x20a,
NonClientHitTest = 0x84,
Paint = 15,
PowerBroadcast = 0x218,
Quit = 0x12,
RightButtonDoubleClick = 0x206,
RightButtonDown = 0x204,
RightButtonUp = 0x205,
SetCursor = 0x20,
Size = 5,
SystemCharacter = 0x106,
SystemCommand = 0x112,
SystemKeyDown = 260,
SystemKeyUp = 0x105,
XButtonDoubleClick = 0x20d,
XButtonDown = 0x20b,
XButtonUp = 0x20c
}
}
}

View File

@ -1,15 +1,8 @@
#region Using Statements
using System; using System;
using System.Collections.Generic; using System.IO;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using SharpDX.Direct3D10;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
using SharpDX.Direct3D10;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -19,23 +12,27 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
public class VertexBuffer_DX10 : INativeVertexBuffer, IDisposable public class VertexBuffer_DX10 : INativeVertexBuffer, IDisposable
{ {
SharpDX.Direct3D10.Buffer buffer;
int vertexStride; int vertexStride;
public SharpDX.Direct3D10.Buffer NativeBuffer { get; private set; }
#region Constructor
public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10; GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null; Device device = gd10 != null ? gd10.NativeDevice as Device : null;
InitializeBuffer(device, vertexDeclaration, vertexCount, usage); InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
} }
internal VertexBuffer_DX10(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) internal VertexBuffer_DX10(Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
InitializeBuffer(device, vertexDeclaration, vertexCount, usage); InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
} }
#endregion
private void InitializeBuffer(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) #region InitializeBuffer
private void InitializeBuffer(Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
this.vertexStride = vertexDeclaration.VertexStride; this.vertexStride = vertexDeclaration.VertexStride;
@ -52,48 +49,32 @@ namespace ANX.RenderSystem.Windows.DX10
OptionFlags = ResourceOptionFlags.None OptionFlags = ResourceOptionFlags.None
}; };
this.buffer = new SharpDX.Direct3D10.Buffer(device, description); NativeBuffer = new SharpDX.Direct3D10.Buffer(device, description);
this.buffer.Unmap(); NativeBuffer.Unmap();
} }
} }
#endregion
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct #region SetData
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
where T : struct
{ {
//TODO: check offsetInBytes parameter for bounds etc. //TODO: check offsetInBytes parameter for bounds etc.
GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned); using (var stream = NativeBuffer.Map(MapMode.WriteDiscard))
IntPtr dataPointer = pinnedArray.AddrOfPinnedObject();
int dataLength = Marshal.SizeOf(typeof(T)) * data.Length;
unsafe
{
using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, true))
{ {
if (offsetInBytes > 0) if (offsetInBytes > 0)
{ stream.Seek(offsetInBytes, SeekOrigin.Current);
vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin);
}
using (var d = buffer.Map(MapMode.WriteDiscard))
{
if (startIndex > 0 || elementCount < data.Length) if (startIndex > 0 || elementCount < data.Length)
{
for (int i = startIndex; i < startIndex + elementCount; i++) for (int i = startIndex; i < startIndex + elementCount; i++)
{ stream.Write<T>(data[i]);
d.Write<T>(data[i]);
}
}
else else
{ for (int i = 0; i < data.Length; i++)
vData.CopyTo(d); stream.Write<T>(data[i]);
}
buffer.Unmap();
}
}
}
pinnedArray.Free(); NativeBuffer.Unmap();
}
} }
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
@ -106,50 +87,54 @@ namespace ANX.RenderSystem.Windows.DX10
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount); SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
} }
public SharpDX.Direct3D10.Buffer NativeBuffer public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount,
{ int vertexStride) where T : struct
get
{
return this.buffer;
}
}
public void Dispose()
{
if (this.buffer != null)
{
buffer.Dispose();
buffer = null;
}
}
#region INativeVertexBuffer Member
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
{
throw new NotImplementedException();
}
#endregion #endregion
#region INativeBuffer Member #region GetData
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
{
using (var stream = NativeBuffer.Map(MapMode.Read))
{
if (offsetInBytes > 0)
stream.Seek(offsetInBytes, SeekOrigin.Current);
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
}
}
public void GetData<T>(T[] data) where T : struct public void GetData<T>(T[] data) where T : struct
{ {
throw new NotImplementedException(); using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, 0, data.Length);
NativeBuffer.Unmap();
}
} }
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
} }
}
#endregion
#region Dispose
public void Dispose()
{
if (this.NativeBuffer != null)
{
NativeBuffer.Dispose();
NativeBuffer = null;
}
}
#endregion #endregion
} }
} }

View File

@ -9,6 +9,7 @@ using ANX.Framework.NonXNA.Development;
using ANX.Framework.NonXNA.RenderSystem; using ANX.Framework.NonXNA.RenderSystem;
using ANX.Framework.Windows.GL3; using ANX.Framework.Windows.GL3;
using OpenTK; using OpenTK;
using OpenTK.Graphics.OpenGL;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -330,5 +331,17 @@ namespace ANX.RenderSystem.Windows.GL3
return new OcclusionQueryGL3(); return new OcclusionQueryGL3();
} }
#endregion #endregion
#region SetTextureSampler (TODO)
public void SetTextureSampler(int index, Texture value)
{
TextureUnit textureUnit = TextureUnit.Texture0 + index;
GL.ActiveTexture(textureUnit);
int handle = (value.NativeTexture as Texture2DGL3).NativeHandle;
GL.BindTexture(TextureTarget.Texture2D, handle);
int unitIndex = (int)(textureUnit - TextureUnit.Texture0);
//GL.Uniform1(UniformIndex, 1, ref unitIndex);
}
#endregion
} }
} }

View File

@ -166,5 +166,12 @@ namespace ANX.RenderSystem.PsVita
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion #endregion
#region SetTextureSampler (TODO)
public void SetTextureSampler(int index, Texture value)
{
throw new NotImplementedException();
}
#endregion
} }
} }

View File

@ -100,7 +100,6 @@
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />
<Compile Include="RenderTarget2D_DX11.cs" /> <Compile Include="RenderTarget2D_DX11.cs" />

View File

@ -99,7 +99,6 @@
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />
<Compile Include="RenderTarget2D_DX11.cs" /> <Compile Include="RenderTarget2D_DX11.cs" />

View File

@ -100,7 +100,6 @@
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />
<Compile Include="RenderTarget2D_DX11.cs" /> <Compile Include="RenderTarget2D_DX11.cs" />

View File

@ -97,7 +97,6 @@
<Compile Include="GraphicsDeviceWindowsDX11.cs" /> <Compile Include="GraphicsDeviceWindowsDX11.cs" />
<Compile Include="IncludeHandler.cs" /> <Compile Include="IncludeHandler.cs" />
<Compile Include="IndexBuffer_DX11.cs" /> <Compile Include="IndexBuffer_DX11.cs" />
<Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RasterizerState_DX11.cs" /> <Compile Include="RasterizerState_DX11.cs" />
<Compile Include="RenderTarget2D_DX11.cs" /> <Compile Include="RenderTarget2D_DX11.cs" />

View File

@ -249,5 +249,12 @@ namespace ANX.RenderSystem.Windows.DX11
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion #endregion
#region SetTextureSampler (TODO)
public void SetTextureSampler(int index, Texture value)
{
throw new NotImplementedException();
}
#endregion
} }
} }

View File

@ -1,16 +1,8 @@
#region Using Statements
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using SharpDX.Direct3D11;
using ANX.Framework.Graphics;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA.RenderSystem;
using System.IO; using System.IO;
using ANX.Framework.Graphics;
#endregion // Using Statements using ANX.Framework.NonXNA.RenderSystem;
using SharpDX.Direct3D11;
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
@ -20,9 +12,11 @@ namespace ANX.RenderSystem.Windows.DX11
{ {
public class IndexBuffer_DX11 : INativeIndexBuffer, IDisposable public class IndexBuffer_DX11 : INativeIndexBuffer, IDisposable
{ {
private SharpDX.Direct3D11.Buffer buffer;
private IndexElementSize size; private IndexElementSize size;
public SharpDX.Direct3D11.Buffer NativeBuffer { get; private set; }
#region Constructor
public IndexBuffer_DX11(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) public IndexBuffer_DX11(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
this.size = size; this.size = size;
@ -30,7 +24,9 @@ namespace ANX.RenderSystem.Windows.DX11
//TODO: translate and use usage //TODO: translate and use usage
GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11; GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
SharpDX.Direct3D11.DeviceContext context = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : null; SharpDX.Direct3D11.DeviceContext context = gd11 != null ?
gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext :
null;
InitializeBuffer(context.Device, size, indexCount, usage); InitializeBuffer(context.Device, size, indexCount, usage);
} }
@ -38,14 +34,16 @@ namespace ANX.RenderSystem.Windows.DX11
internal IndexBuffer_DX11(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage) internal IndexBuffer_DX11(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
this.size = size; this.size = size;
InitializeBuffer(device, size, indexCount, usage); InitializeBuffer(device, size, indexCount, usage);
} }
#endregion
#region InitializeBuffer
private void InitializeBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage) private void InitializeBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
BufferDescription description = new BufferDescription() BufferDescription description = new BufferDescription()
{ {
// TODO: translate usage
Usage = ResourceUsage.Dynamic, Usage = ResourceUsage.Dynamic,
SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount, SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
BindFlags = BindFlags.IndexBuffer, BindFlags = BindFlags.IndexBuffer,
@ -53,9 +51,11 @@ namespace ANX.RenderSystem.Windows.DX11
OptionFlags = ResourceOptionFlags.None OptionFlags = ResourceOptionFlags.None
}; };
this.buffer = new SharpDX.Direct3D11.Buffer(device, description); NativeBuffer = new SharpDX.Direct3D11.Buffer(device, description);
} }
#endregion
#region SetData
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
{ {
SetData<T>(graphicsDevice, data, 0, data.Length); SetData<T>(graphicsDevice, data, 0, data.Length);
@ -70,7 +70,7 @@ namespace ANX.RenderSystem.Windows.DX11
//TODO: check offsetInBytes parameter for bounds etc. //TODO: check offsetInBytes parameter for bounds etc.
SharpDX.DataStream stream; SharpDX.DataStream stream;
context.MapSubresource(this.buffer, MapMode.WriteDiscard, MapFlags.None, out stream); context.MapSubresource(NativeBuffer, MapMode.WriteDiscard, MapFlags.None, out stream);
if (offsetInBytes > 0) if (offsetInBytes > 0)
stream.Seek(offsetInBytes, SeekOrigin.Current); stream.Seek(offsetInBytes, SeekOrigin.Current);
@ -82,51 +82,59 @@ namespace ANX.RenderSystem.Windows.DX11
for (int i = 0; i < data.Length; i++) for (int i = 0; i < data.Length; i++)
stream.Write<T>(data[i]); stream.Write<T>(data[i]);
context.UnmapSubresource(this.buffer, 0); context.UnmapSubresource(NativeBuffer, 0);
} }
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
{ {
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount); SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
} }
public SharpDX.Direct3D11.Buffer NativeBuffer
{
get
{
return this.buffer;
}
}
public void Dispose()
{
if (this.buffer != null)
{
buffer.Dispose();
buffer = null;
}
}
#region INativeIndexBuffer Member
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
}
#endregion #endregion
#region INativeBuffer Member #region Dispose
public void Dispose()
{
if (NativeBuffer != null)
{
NativeBuffer.Dispose();
NativeBuffer = null;
}
}
#endregion
#region GetData
public void GetData<T>(T[] data) where T : struct public void GetData<T>(T[] data) where T : struct
{ {
throw new NotImplementedException(); DeviceContext context = NativeBuffer.Device.ImmediateContext;
SharpDX.DataStream stream;
context.MapSubresource(NativeBuffer, MapMode.Read, MapFlags.None, out stream);
stream.ReadRange(data, 0, data.Length);
context.UnmapSubresource(NativeBuffer, 0);
} }
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); DeviceContext context = NativeBuffer.Device.ImmediateContext;
SharpDX.DataStream stream;
context.MapSubresource(NativeBuffer, MapMode.Read, MapFlags.None, out stream);
stream.ReadRange(data, startIndex, elementCount);
context.UnmapSubresource(NativeBuffer, 0);
}
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
{
DeviceContext context = NativeBuffer.Device.ImmediateContext;
SharpDX.DataStream stream;
context.MapSubresource(NativeBuffer, MapMode.Read, MapFlags.None, out stream);
if (offsetInBytes > 0)
stream.Seek(offsetInBytes, SeekOrigin.Current);
stream.ReadRange(data, startIndex, elementCount);
context.UnmapSubresource(NativeBuffer, 0);
} }
#endregion #endregion

View File

@ -1,69 +0,0 @@
using System;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.RenderSystem.Windows.DX11
{
internal sealed class NativeMethods
{
// Not needed any more, in platforms now!
//[SuppressUnmanagedCodeSecurity, DllImport("user32.dll", CharSet = CharSet.Auto)]
//internal static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
//// Nested Types
//[StructLayout(LayoutKind.Sequential)]
//public struct Message
//{
// public IntPtr hWnd;
// public NativeMethods.WindowMessage msg;
// public IntPtr wParam;
// public IntPtr lParam;
// public uint time;
// public Point p;
//}
internal enum WindowMessage : uint
{
ActivateApplication = 0x1c,
Character = 0x102,
Close = 0x10,
Destroy = 2,
EnterMenuLoop = 0x211,
EnterSizeMove = 0x231,
ExitMenuLoop = 530,
ExitSizeMove = 0x232,
GetMinMax = 0x24,
KeyDown = 0x100,
KeyUp = 0x101,
LeftButtonDoubleClick = 0x203,
LeftButtonDown = 0x201,
LeftButtonUp = 0x202,
MiddleButtonDoubleClick = 0x209,
MiddleButtonDown = 0x207,
MiddleButtonUp = 520,
MouseFirst = 0x201,
MouseLast = 0x20d,
MouseMove = 0x200,
MouseWheel = 0x20a,
NonClientHitTest = 0x84,
Paint = 15,
PowerBroadcast = 0x218,
Quit = 0x12,
RightButtonDoubleClick = 0x206,
RightButtonDown = 0x204,
RightButtonUp = 0x205,
SetCursor = 0x20,
Size = 5,
SystemCharacter = 0x106,
SystemCommand = 0x112,
SystemKeyDown = 260,
SystemKeyUp = 0x105,
XButtonDoubleClick = 0x20d,
XButtonDown = 0x20b,
XButtonUp = 0x20c
}
}
}

View File

@ -14,16 +14,12 @@ namespace ANX.RenderSystem.Windows.DX11
{ {
int vertexStride; int vertexStride;
public SharpDX.Direct3D11.Buffer NativeBuffer public SharpDX.Direct3D11.Buffer NativeBuffer { get; private set; }
{
get;
private set;
}
#region Constructor #region Constructor
public VertexBuffer_DX11(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) public VertexBuffer_DX11(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11; var gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
SharpDX.Direct3D11.DeviceContext context = gd11 != null ? SharpDX.Direct3D11.DeviceContext context = gd11 != null ?
gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext :
null; null;
@ -115,20 +111,39 @@ namespace ANX.RenderSystem.Windows.DX11
} }
#endregion #endregion
#region GetData (TODO) #region GetData
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
{ {
throw new NotImplementedException(); DeviceContext context = NativeBuffer.Device.ImmediateContext;
SharpDX.DataStream stream;
context.MapSubresource(NativeBuffer, MapMode.Read, MapFlags.None, out stream);
if (offsetInBytes > 0)
stream.Seek(offsetInBytes, SeekOrigin.Current);
stream.ReadRange(data, startIndex, elementCount);
context.UnmapSubresource(NativeBuffer, 0);
} }
public void GetData<T>(T[] data) where T : struct public void GetData<T>(T[] data) where T : struct
{ {
throw new NotImplementedException(); DeviceContext context = NativeBuffer.Device.ImmediateContext;
SharpDX.DataStream stream;
context.MapSubresource(NativeBuffer, MapMode.Read, MapFlags.None, out stream);
stream.ReadRange(data, 0, data.Length);
context.UnmapSubresource(NativeBuffer, 0);
} }
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); DeviceContext context = NativeBuffer.Device.ImmediateContext;
SharpDX.DataStream stream;
context.MapSubresource(NativeBuffer, MapMode.Read, MapFlags.None, out stream);
stream.ReadRange(data, startIndex, elementCount);
context.UnmapSubresource(NativeBuffer, 0);
} }
#endregion #endregion
} }

View File

@ -279,5 +279,12 @@ namespace ANX.RenderSystem.Windows.Metro
} }
#endregion #endregion
#region SetTextureSampler (TODO)
public void SetTextureSampler(int index, Texture value)
{
throw new NotImplementedException();
}
#endregion
} }
} }

View File

@ -52,23 +52,17 @@ namespace ANXStatusComparer.Data
foreach (Type type in types) foreach (Type type in types)
{ {
if (String.IsNullOrEmpty(type.Namespace)) if (String.IsNullOrEmpty(type.Namespace))
{
continue; continue;
}
if (Namespaces.ContainsKey(type.Namespace) == false) if (Namespaces.ContainsKey(type.Namespace) == false)
{
Namespaces.Add(type.Namespace, new NamespaceData(type.Namespace)); Namespaces.Add(type.Namespace, new NamespaceData(type.Namespace));
}
Namespaces[type.Namespace].AllTypes.Add(type); Namespaces[type.Namespace].AllTypes.Add(type);
} }
} }
foreach (string key in Namespaces.Keys) foreach (string key in Namespaces.Keys)
{
Namespaces[key].ParseTypes(); Namespaces[key].ParseTypes();
} }
}
#endregion #endregion
} }
} }

View File

@ -1,10 +1,7 @@
#region Private Members
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
#endregion // Private Members
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
@ -191,8 +188,7 @@ namespace ANXStatusComparer.Data
public override string ToString() public override string ToString()
{ {
return (HasPercentageAttribute ? return (HasPercentageAttribute ? PercentageComplete.ToString("000") : "-?-") + "% - " + Handle.FullName;
PercentageComplete.ToString("000") : "-?-") + "% - " + Handle.FullName;
} }
#region IsCorrect #region IsCorrect
@ -201,21 +197,13 @@ namespace ANXStatusComparer.Data
{ {
bool isCorrect = true; bool isCorrect = true;
if (CompareLists(Methods, otherObject.Methods, wrongPair) == false) if (CompareLists(Methods, otherObject.Methods, wrongPair) == false)
{
isCorrect = false; isCorrect = false;
}
if (CompareLists(Events, otherObject.Events, wrongPair) == false) if (CompareLists(Events, otherObject.Events, wrongPair) == false)
{
isCorrect = false; isCorrect = false;
}
if (CompareLists(Fields, otherObject.Fields, wrongPair) == false) if (CompareLists(Fields, otherObject.Fields, wrongPair) == false)
{
isCorrect = false; isCorrect = false;
}
if (CompareLists(Properties, otherObject.Properties, wrongPair) == false) if (CompareLists(Properties, otherObject.Properties, wrongPair) == false)
{
isCorrect = false; isCorrect = false;
}
foreach(string parent in ParentNames) foreach(string parent in ParentNames)
{ {
@ -228,37 +216,33 @@ namespace ANXStatusComparer.Data
if (Handle.IsPublic != otherObject.Handle.IsPublic) if (Handle.IsPublic != otherObject.Handle.IsPublic)
{ {
wrongPair.WrongAccesses.Add("[IsPublic(XNA:" + Handle.IsPublic + wrongPair.WrongAccesses.Add("[IsPublic(XNA:" + Handle.IsPublic + "|ANX:" + otherObject.Handle.IsPublic + ")] ");
"|ANX:" + otherObject.Handle.IsPublic + ")] ");
isCorrect = false; isCorrect = false;
} }
if (Handle.IsSealed != otherObject.Handle.IsSealed) if (Handle.IsSealed != otherObject.Handle.IsSealed)
{ {
wrongPair.WrongAccesses.Add("[IsSealed(XNA:" + Handle.IsSealed + wrongPair.WrongAccesses.Add("[IsSealed(XNA:" + Handle.IsSealed + "|ANX:" + otherObject.Handle.IsSealed + ")] ");
"|ANX:" + otherObject.Handle.IsSealed + ")] ");
isCorrect = false; isCorrect = false;
} }
if (Handle.IsAbstract != otherObject.Handle.IsAbstract) if (Handle.IsAbstract != otherObject.Handle.IsAbstract)
{ {
wrongPair.WrongAccesses.Add("[IsAbstract(XNA:" + Handle.IsAbstract + wrongPair.WrongAccesses.Add("[IsAbstract(XNA:" + Handle.IsAbstract + "|ANX:" + otherObject.Handle.IsAbstract + ")] ");
"|ANX:" + otherObject.Handle.IsAbstract + ")] ");
isCorrect = false; isCorrect = false;
} }
if (Handle.IsGenericType != otherObject.Handle.IsGenericType) if (Handle.IsGenericType != otherObject.Handle.IsGenericType)
{ {
wrongPair.WrongAccesses.Add("[IsGenericType(XNA:" + wrongPair.WrongAccesses.Add("[IsGenericType(XNA:" + Handle.IsGenericType + "|ANX:" +
Handle.IsGenericType + otherObject.Handle.IsGenericType + ")] ");
"|ANX:" + otherObject.Handle.IsGenericType + ")] ");
isCorrect = false; isCorrect = false;
} }
if (Handle.IsVisible != otherObject.Handle.IsVisible) if (Handle.IsVisible != otherObject.Handle.IsVisible)
{ {
wrongPair.WrongAccesses.Add("[IsVisible(XNA:" + Handle.IsVisible + wrongPair.WrongAccesses.Add("[IsVisible(XNA:" + Handle.IsVisible + "|ANX:" + otherObject.Handle.IsVisible +
"|ANX:" + otherObject.Handle.IsVisible + ")] "); ")] ");
isCorrect = false; isCorrect = false;
} }
@ -267,8 +251,7 @@ namespace ANXStatusComparer.Data
#endregion #endregion
#region CompareLists #region CompareLists
private bool CompareLists(Dictionary<string, BaseObjectElement> dictXna, private bool CompareLists(Dictionary<string, BaseObjectElement> dictXna, Dictionary<string, BaseObjectElement> dictAnx,
Dictionary<string, BaseObjectElement> dictAnx,
ResultData.WrongObjectPair wrongPair) ResultData.WrongObjectPair wrongPair)
{ {
bool isCorrect = true; bool isCorrect = true;