- 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:
parent
7031e5b44e
commit
3316d46dba
@ -442,6 +442,7 @@
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -442,6 +442,7 @@
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -444,6 +444,7 @@
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -445,6 +445,7 @@
|
||||
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
|
||||
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
|
||||
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
|
||||
<Compile Include="NonXNA\ThreadHelper.cs" />
|
||||
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -6,11 +7,17 @@ using System;
|
||||
|
||||
namespace ANX.Framework
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Tested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public static class FrameworkDispatcher
|
||||
{
|
||||
internal static event Action OnUpdate;
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (OnUpdate != null)
|
||||
OnUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using ANX.Framework;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
#endregion // Using Statements
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -11,16 +8,15 @@ using System.Collections.ObjectModel;
|
||||
|
||||
namespace ANX.Framework.GamerServices
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Tested)]
|
||||
public interface IAvatarAnimation
|
||||
{
|
||||
ReadOnlyCollection<Matrix> BoneTransforms { get; }
|
||||
|
||||
TimeSpan CurrentPosition { get; set; }
|
||||
|
||||
AvatarExpression Expression { get; }
|
||||
|
||||
TimeSpan Length { get; }
|
||||
|
||||
void Update(TimeSpan elapsedAnimationTime, bool loop);
|
||||
|
||||
void Update(TimeSpan elapsedAnimationTime, bool loop);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -11,7 +12,6 @@ namespace ANX.Framework.Graphics
|
||||
public class GraphicsDevice : IDisposable
|
||||
{
|
||||
#region Private Members
|
||||
private INativeGraphicsDevice nativeDevice;
|
||||
private IndexBuffer indexBuffer;
|
||||
private SamplerStateCollection samplerStateCollection;
|
||||
private Viewport viewport;
|
||||
@ -52,8 +52,8 @@ namespace ANX.Framework.Graphics
|
||||
|
||||
// TODO: get maximum number of sampler states from capabilities
|
||||
this.samplerStateCollection = new SamplerStateCollection(this, 8);
|
||||
this.textureCollection = new TextureCollection();
|
||||
this.vertexTextureCollection = new TextureCollection();
|
||||
this.textureCollection = new TextureCollection(16);
|
||||
this.vertexTextureCollection = new TextureCollection(16);
|
||||
|
||||
this.BlendState = BlendState.Opaque;
|
||||
this.DepthStencilState = DepthStencilState.Default;
|
||||
@ -71,13 +71,9 @@ namespace ANX.Framework.Graphics
|
||||
{
|
||||
ClearOptions options = ClearOptions.Target;
|
||||
if (this.currentPresentationParameters.DepthStencilFormat != DepthFormat.None)
|
||||
{
|
||||
options |= ClearOptions.DepthBuffer;
|
||||
}
|
||||
if (this.currentPresentationParameters.DepthStencilFormat == DepthFormat.Depth24Stencil8)
|
||||
{
|
||||
options |= ClearOptions.Stencil;
|
||||
}
|
||||
|
||||
Clear(options, color, 1, 0);
|
||||
// nativeDevice.Clear(ref color);
|
||||
@ -93,17 +89,18 @@ namespace ANX.Framework.Graphics
|
||||
if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer &&
|
||||
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 &&
|
||||
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
|
||||
@ -111,10 +108,11 @@ namespace ANX.Framework.Graphics
|
||||
#region 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
|
||||
throw new NotImplementedException();
|
||||
@ -126,13 +124,13 @@ namespace ANX.Framework.Graphics
|
||||
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
|
||||
int startIndex, int primitiveCount)
|
||||
{
|
||||
nativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
|
||||
NativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
|
||||
primitiveCount);
|
||||
}
|
||||
|
||||
public void DrawPrimitives(PrimitiveType primitiveType, int startVertex, int primitiveCount)
|
||||
{
|
||||
nativeDevice.DrawPrimitives(primitiveType, startVertex, primitiveCount);
|
||||
NativeDevice.DrawPrimitives(primitiveType, startVertex, primitiveCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -140,7 +138,7 @@ namespace ANX.Framework.Graphics
|
||||
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
|
||||
int startIndex, int primitiveCount, int instanceCount)
|
||||
{
|
||||
nativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
|
||||
NativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
|
||||
primitiveCount, instanceCount);
|
||||
}
|
||||
#endregion
|
||||
@ -149,8 +147,8 @@ namespace ANX.Framework.Graphics
|
||||
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
|
||||
short[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
|
||||
{
|
||||
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>();
|
||||
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
|
||||
var vertexDeclaration = VertexTypeHelper.GetDeclaration<T>();
|
||||
NativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
|
||||
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
|
||||
}
|
||||
|
||||
@ -158,15 +156,15 @@ namespace ANX.Framework.Graphics
|
||||
short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
|
||||
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);
|
||||
}
|
||||
|
||||
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
|
||||
int[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
|
||||
{
|
||||
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>();
|
||||
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
|
||||
var vertexDeclaration = VertexTypeHelper.GetDeclaration<T>();
|
||||
NativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
|
||||
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
|
||||
}
|
||||
|
||||
@ -174,7 +172,7 @@ namespace ANX.Framework.Graphics
|
||||
int[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
|
||||
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);
|
||||
}
|
||||
#endregion
|
||||
@ -183,24 +181,17 @@ namespace ANX.Framework.Graphics
|
||||
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount)
|
||||
where T : struct, IVertexType
|
||||
{
|
||||
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>();
|
||||
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
|
||||
var vertexDeclaration = VertexTypeHelper.GetDeclaration<T>();
|
||||
NativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
|
||||
}
|
||||
|
||||
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount,
|
||||
VertexDeclaration vertexDeclaration) where T : struct, IVertexType
|
||||
{
|
||||
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
|
||||
NativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
|
||||
}
|
||||
#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
|
||||
#region SetConstantBuffer
|
||||
/// <summary>
|
||||
@ -210,7 +201,7 @@ namespace ANX.Framework.Graphics
|
||||
/// <param name="constantBuffer">The managed constant buffer object to bind.</param>
|
||||
public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer)
|
||||
{
|
||||
this.nativeDevice.SetConstantBuffer(slot, constantBuffer);
|
||||
NativeDevice.SetConstantBuffer(slot, constantBuffer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -221,9 +212,7 @@ namespace ANX.Framework.Graphics
|
||||
public void SetConstantBuffers(params ConstantBuffer[] constantBuffers)
|
||||
{
|
||||
for (int slot = 0; slot < constantBuffers.Length; slot++)
|
||||
{
|
||||
this.nativeDevice.SetConstantBuffer(slot, constantBuffers[slot]);
|
||||
}
|
||||
NativeDevice.SetConstantBuffer(slot, constantBuffers[slot]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -234,20 +223,20 @@ namespace ANX.Framework.Graphics
|
||||
{
|
||||
VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer) };
|
||||
this.currentVertexBufferBindings = bindings;
|
||||
this.nativeDevice.SetVertexBuffers(bindings);
|
||||
NativeDevice.SetVertexBuffers(bindings);
|
||||
}
|
||||
|
||||
public void SetVertexBuffer(VertexBuffer vertexBuffer, int vertexOffset)
|
||||
{
|
||||
VertexBufferBinding[] bindings = new VertexBufferBinding[] { new VertexBufferBinding(vertexBuffer, vertexOffset) };
|
||||
this.currentVertexBufferBindings = bindings;
|
||||
this.nativeDevice.SetVertexBuffers(bindings);
|
||||
NativeDevice.SetVertexBuffers(bindings);
|
||||
}
|
||||
|
||||
public void SetVertexBuffers(params Graphics.VertexBufferBinding[] vertexBuffers)
|
||||
{
|
||||
this.currentVertexBufferBindings = vertexBuffers;
|
||||
nativeDevice.SetVertexBuffers(vertexBuffers);
|
||||
NativeDevice.SetVertexBuffers(vertexBuffers);
|
||||
}
|
||||
|
||||
#endregion // SetVertexBuffer
|
||||
@ -259,25 +248,23 @@ namespace ANX.Framework.Graphics
|
||||
{
|
||||
RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget) };
|
||||
this.currentRenderTargetBindings = renderTargetBindings;
|
||||
nativeDevice.SetRenderTargets(renderTargetBindings);
|
||||
NativeDevice.SetRenderTargets(renderTargetBindings);
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeDevice.SetRenderTargets(null);
|
||||
}
|
||||
NativeDevice.SetRenderTargets(null);
|
||||
}
|
||||
|
||||
public void SetRenderTarget(RenderTargetCube renderTarget, CubeMapFace cubeMapFace)
|
||||
{
|
||||
RenderTargetBinding[] renderTargetBindings = new RenderTargetBinding[] { new RenderTargetBinding(renderTarget, cubeMapFace) };
|
||||
this.currentRenderTargetBindings = renderTargetBindings;
|
||||
nativeDevice.SetRenderTargets(renderTargetBindings);
|
||||
NativeDevice.SetRenderTargets(renderTargetBindings);
|
||||
}
|
||||
|
||||
public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
|
||||
{
|
||||
this.currentRenderTargetBindings = renderTargets;
|
||||
nativeDevice.SetRenderTargets(renderTargets);
|
||||
NativeDevice.SetRenderTargets(renderTargets);
|
||||
}
|
||||
|
||||
#endregion // SetRenderTarget
|
||||
@ -285,17 +272,17 @@ namespace ANX.Framework.Graphics
|
||||
#region GetBackBufferData<T>
|
||||
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
|
||||
{
|
||||
nativeDevice.GetBackBufferData<T>(data);
|
||||
NativeDevice.GetBackBufferData<T>(data);
|
||||
}
|
||||
|
||||
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>
|
||||
@ -354,7 +341,7 @@ namespace ANX.Framework.Graphics
|
||||
}
|
||||
|
||||
// reset presentation parameters
|
||||
nativeDevice.ResizeBuffers(presentationParameters);
|
||||
NativeDevice.ResizeBuffers(presentationParameters);
|
||||
this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth,
|
||||
presentationParameters.BackBufferHeight);
|
||||
|
||||
@ -374,10 +361,11 @@ namespace ANX.Framework.Graphics
|
||||
{
|
||||
if (isDisposed == false)
|
||||
{
|
||||
if (nativeDevice != null)
|
||||
isDisposed = true;
|
||||
if (NativeDevice != null)
|
||||
{
|
||||
nativeDevice.Dispose();
|
||||
nativeDevice = null;
|
||||
NativeDevice.Dispose();
|
||||
NativeDevice = null;
|
||||
}
|
||||
|
||||
raise_Disposing(this, EventArgs.Empty);
|
||||
@ -622,69 +610,51 @@ namespace ANX.Framework.Graphics
|
||||
|
||||
internal INativeGraphicsDevice NativeDevice
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativeDevice;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.nativeDevice = value;
|
||||
}
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
internal void Recreate(PresentationParameters presentationParameters)
|
||||
{
|
||||
if (nativeDevice != null)
|
||||
if (NativeDevice != null)
|
||||
{
|
||||
nativeDevice.Dispose();
|
||||
raise_ResourceDestroyed(this, new ResourceDestroyedEventArgs("NativeGraphicsDevice", nativeDevice));
|
||||
nativeDevice = null;
|
||||
NativeDevice.Dispose();
|
||||
raise_ResourceDestroyed(this, new ResourceDestroyedEventArgs("NativeGraphicsDevice", NativeDevice));
|
||||
NativeDevice = null;
|
||||
}
|
||||
|
||||
if (nativeDevice == null)
|
||||
if (NativeDevice == null)
|
||||
{
|
||||
this.currentPresentationParameters = presentationParameters;
|
||||
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||
nativeDevice = creator.CreateGraphicsDevice(presentationParameters);
|
||||
NativeDevice = creator.CreateGraphicsDevice(presentationParameters);
|
||||
this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth,
|
||||
presentationParameters.BackBufferHeight);
|
||||
|
||||
raise_ResourceCreated(this, new ResourceCreatedEventArgs(nativeDevice));
|
||||
raise_ResourceCreated(this, new ResourceCreatedEventArgs(NativeDevice));
|
||||
GraphicsResourceTracker.Instance.UpdateGraphicsDeviceReference(this);
|
||||
|
||||
if (this.indexBuffer != null)
|
||||
{
|
||||
NativeDevice.SetIndexBuffer(this.indexBuffer);
|
||||
}
|
||||
|
||||
if (this.currentVertexBufferBindings != null)
|
||||
{
|
||||
NativeDevice.SetVertexBuffers(this.currentVertexBufferBindings);
|
||||
}
|
||||
|
||||
if (this.blendState != null)
|
||||
{
|
||||
this.blendState.NativeBlendState.Apply(this);
|
||||
}
|
||||
|
||||
if (this.rasterizerState != null)
|
||||
{
|
||||
this.rasterizerState.NativeRasterizerState.Apply(this);
|
||||
}
|
||||
|
||||
if (this.depthStencilState != null)
|
||||
{
|
||||
this.depthStencilState.NativeDepthStencilState.Apply(this);
|
||||
}
|
||||
|
||||
if (this.samplerStateCollection != null)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (this.samplerStateCollection[i] != null)
|
||||
{
|
||||
this.samplerStateCollection[i].NativeSamplerState.Apply(this, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -692,38 +662,38 @@ namespace ANX.Framework.Graphics
|
||||
|
||||
protected void raise_Disposing(object sender, EventArgs args)
|
||||
{
|
||||
if (Disposing != null)
|
||||
Disposing(sender, args);
|
||||
RaiseIfNotNull(Disposing, sender, args);
|
||||
}
|
||||
|
||||
protected void raise_DeviceResetting(object sender, EventArgs args)
|
||||
{
|
||||
if (DeviceResetting != null)
|
||||
DeviceResetting(sender, args);
|
||||
RaiseIfNotNull(DeviceResetting, sender, args);
|
||||
}
|
||||
|
||||
protected void raise_DeviceReset(object sender, EventArgs args)
|
||||
{
|
||||
if (DeviceReset != null)
|
||||
DeviceReset(sender, args);
|
||||
RaiseIfNotNull(DeviceReset, sender, args);
|
||||
}
|
||||
|
||||
protected void raise_DeviceLost(object sender, EventArgs args)
|
||||
{
|
||||
if (DeviceLost != null)
|
||||
DeviceLost(sender, args);
|
||||
RaiseIfNotNull(DeviceLost, sender, args);
|
||||
}
|
||||
|
||||
protected void raise_ResourceCreated(object sender, ResourceCreatedEventArgs args)
|
||||
{
|
||||
if (ResourceCreated != null)
|
||||
ResourceCreated(sender, args);
|
||||
RaiseIfNotNull(ResourceCreated, sender, args);
|
||||
}
|
||||
|
||||
protected void raise_ResourceDestroyed(object sender, ResourceDestroyedEventArgs args)
|
||||
{
|
||||
if (ResourceDestroyed != null)
|
||||
ResourceDestroyed(sender, args);
|
||||
RaiseIfNotNull(ResourceDestroyed, sender, args);
|
||||
}
|
||||
|
||||
private void RaiseIfNotNull<T>(EventHandler<T> handler, object sender, T args) where T : EventArgs
|
||||
{
|
||||
if (handler != null)
|
||||
handler(sender, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
|
||||
#endregion // Using Statements
|
||||
using ANX.Framework.NonXNA;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -9,18 +7,27 @@ using System;
|
||||
|
||||
namespace ANX.Framework.Graphics
|
||||
{
|
||||
public sealed class TextureCollection
|
||||
{
|
||||
public Texture this[int index]
|
||||
public sealed class TextureCollection
|
||||
{
|
||||
private Texture[] textures;
|
||||
|
||||
public Texture this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
return textures[index];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
textures[index] = value;
|
||||
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||
creator.SetTextureSampler(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
internal TextureCollection(int maxNumberOfTextures)
|
||||
{
|
||||
textures = new Texture[maxNumberOfTextures];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development;
|
||||
|
||||
namespace ANX.Framework.Input.Touch
|
||||
{
|
||||
[PercentageComplete(90)]
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
public struct TouchCollection : IList<TouchLocation>, ICollection<TouchLocation>, IEnumerable<TouchLocation>, IEnumerable
|
||||
{
|
||||
@ -67,7 +67,7 @@ namespace ANX.Framework.Input.Touch
|
||||
private List<TouchLocation> locations;
|
||||
#endregion
|
||||
|
||||
#region Public (TODO)
|
||||
#region Public
|
||||
public TouchLocation this[int index]
|
||||
{
|
||||
get
|
||||
@ -92,7 +92,7 @@ namespace ANX.Framework.Input.Touch
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ namespace ANX.Framework.Input.Touch
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -46,5 +46,7 @@ namespace ANX.Framework.NonXNA
|
||||
EffectSourceLanguage GetStockShaderSourceLanguage { get; }
|
||||
|
||||
ReadOnlyCollection<GraphicsAdapter> GetAdapterList();
|
||||
|
||||
void SetTextureSampler(int index, Texture value);
|
||||
}
|
||||
}
|
||||
|
20
ANX.Framework/NonXNA/RenderSystem/VertexTypeHelper.cs
Normal file
20
ANX.Framework/NonXNA/RenderSystem/VertexTypeHelper.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,3 @@
|
||||
#region Using Statements
|
||||
|
||||
|
||||
#endregion // Using Statements
|
||||
|
||||
// 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
|
||||
|
@ -371,7 +371,7 @@ namespace ANX.Framework
|
||||
{
|
||||
Quaternion 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)
|
||||
@ -409,9 +409,7 @@ namespace ANX.Framework
|
||||
public override string ToString()
|
||||
{
|
||||
var culture = CultureInfo.CurrentCulture;
|
||||
return "{X:" + X.ToString(culture) +
|
||||
" Y:" + Y.ToString(culture) +
|
||||
" Z:" + Z.ToString(culture) +
|
||||
return "{X:" + X.ToString(culture) + " Y:" + Y.ToString(culture) + " Z:" + Z.ToString(culture) +
|
||||
" W:" + W.ToString(culture) + "}";
|
||||
}
|
||||
#endregion
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.PlatformSystem;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -8,6 +9,9 @@ using ANX.Framework.NonXNA.PlatformSystem;
|
||||
|
||||
namespace ANX.Framework
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public static class TitleContainer
|
||||
{
|
||||
private static INativeTitleContainer nativeImplementation;
|
||||
|
@ -87,7 +87,6 @@
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX10.cs" />
|
||||
<Compile Include="EffectPass_DX10.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX10.cs" />
|
||||
<Compile Include="RenderTarget2D_DX10.cs" />
|
||||
|
@ -87,7 +87,6 @@
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX10.cs" />
|
||||
<Compile Include="EffectPass_DX10.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX10.cs" />
|
||||
<Compile Include="RenderTarget2D_DX10.cs" />
|
||||
|
@ -88,7 +88,6 @@
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX10.cs" />
|
||||
<Compile Include="EffectPass_DX10.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX10.cs" />
|
||||
<Compile Include="RenderTarget2D_DX10.cs" />
|
||||
|
@ -89,7 +89,6 @@
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX10.cs" />
|
||||
<Compile Include="EffectPass_DX10.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX10.cs" />
|
||||
<Compile Include="RenderTarget2D_DX10.cs" />
|
||||
|
@ -1,4 +1,3 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -8,8 +7,7 @@ using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using SharpDX.DXGI;
|
||||
|
||||
#endregion // Using Statements
|
||||
using Dx10 = SharpDX.Direct3D10;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -19,6 +17,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
public class Creator : IRenderSystemCreator
|
||||
{
|
||||
#region Public
|
||||
public string Name
|
||||
{
|
||||
get { return "DirectX10"; }
|
||||
@ -38,132 +37,133 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
}
|
||||
}
|
||||
|
||||
public EffectSourceLanguage GetStockShaderSourceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return EffectSourceLanguage.HLSL_FX;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateGraphicsDevice
|
||||
public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new GraphicsDeviceWindowsDX10(presentationParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateIndexBuffer
|
||||
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size,
|
||||
int indexCount, BufferUsage usage)
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new IndexBuffer_DX10(graphics, size, indexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateVertexBuffer
|
||||
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer,
|
||||
VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
PreventSystemChange();
|
||||
|
||||
return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage);
|
||||
return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#if XNAEXT
|
||||
#region CreateConstantBuffer
|
||||
public INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer, BufferUsage usage)
|
||||
{
|
||||
PreventSystemChange();
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode,
|
||||
Stream pixelShaderByteCode)
|
||||
#region CreateConstantBuffer
|
||||
public INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer, BufferUsage usage)
|
||||
{
|
||||
PreventSystemChange();
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region CreateEffect
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode,
|
||||
Stream pixelShaderByteCode)
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode);
|
||||
}
|
||||
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode)
|
||||
{
|
||||
PreventSystemChange();
|
||||
|
||||
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();
|
||||
|
||||
//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;
|
||||
return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateBlendState
|
||||
public INativeBlendState CreateBlendState()
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new BlendState_DX10();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateRasterizerState
|
||||
public INativeRasterizerState CreateRasterizerState()
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new RasterizerState_DX10();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateDepthStencilState
|
||||
public INativeDepthStencilState CreateDepthStencilState()
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new DepthStencilState_DX10();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateSamplerState
|
||||
public INativeSamplerState CreateSamplerState()
|
||||
{
|
||||
PreventSystemChange();
|
||||
return new SamplerState_DX10();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetShaderByteCode
|
||||
public byte[] GetShaderByteCode(PreDefinedShader type)
|
||||
{
|
||||
PreventSystemChange();
|
||||
|
||||
if (type == PreDefinedShader.SpriteBatch)
|
||||
switch (type)
|
||||
{
|
||||
return ShaderByteCode.SpriteBatchByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.AlphaTestEffect)
|
||||
{
|
||||
return ShaderByteCode.AlphaTestEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.BasicEffect)
|
||||
{
|
||||
return ShaderByteCode.BasicEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.DualTextureEffect)
|
||||
{
|
||||
return ShaderByteCode.DualTextureEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.EnvironmentMapEffect)
|
||||
{
|
||||
return ShaderByteCode.EnvironmentMapEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.SkinnedEffect)
|
||||
{
|
||||
return ShaderByteCode.SkinnedEffectByteCode;
|
||||
case PreDefinedShader.SpriteBatch:
|
||||
return ShaderByteCode.SpriteBatchByteCode;
|
||||
case PreDefinedShader.AlphaTestEffect:
|
||||
return ShaderByteCode.AlphaTestEffectByteCode;
|
||||
case PreDefinedShader.BasicEffect:
|
||||
return ShaderByteCode.BasicEffectByteCode;
|
||||
case PreDefinedShader.DualTextureEffect:
|
||||
return ShaderByteCode.DualTextureEffectByteCode;
|
||||
case PreDefinedShader.EnvironmentMapEffect:
|
||||
return ShaderByteCode.EnvironmentMapEffectByteCode;
|
||||
case PreDefinedShader.SkinnedEffect:
|
||||
return ShaderByteCode.SkinnedEffectByteCode;
|
||||
}
|
||||
|
||||
throw new NotImplementedException("ByteCode for '" + type + "' is not yet available");
|
||||
}
|
||||
#endregion
|
||||
|
||||
public EffectSourceLanguage GetStockShaderSourceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return EffectSourceLanguage.HLSL_FX;
|
||||
}
|
||||
}
|
||||
|
||||
#region GetAdapterList
|
||||
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
|
||||
{
|
||||
PreventSystemChange();
|
||||
@ -177,7 +177,7 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
using (Adapter adapter = factory.GetAdapter(i))
|
||||
{
|
||||
GraphicsAdapter ga = new GraphicsAdapter();
|
||||
var ga = new GraphicsAdapter();
|
||||
//ga.CurrentDisplayMode = ;
|
||||
//ga.Description = ;
|
||||
ga.DeviceId = adapter.Description.DeviceId;
|
||||
@ -218,23 +218,18 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
|
||||
return new ReadOnlyCollection<GraphicsAdapter>(adapterList);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height,
|
||||
int mipCount)
|
||||
{
|
||||
PreventSystemChange();
|
||||
|
||||
return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount);
|
||||
}
|
||||
|
||||
#region CreateRenderTarget
|
||||
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();
|
||||
|
||||
return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat,
|
||||
preferredMultiSampleCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PreventSystemChange
|
||||
private void PreventSystemChange()
|
||||
@ -243,16 +238,27 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage)
|
||||
{
|
||||
return sourceLanguage == EffectSourceLanguage.HLSL_FX || sourceLanguage == EffectSourceLanguage.HLSL;
|
||||
}
|
||||
#region IsLanguageSupported
|
||||
public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage)
|
||||
{
|
||||
return sourceLanguage == EffectSourceLanguage.HLSL_FX || sourceLanguage == EffectSourceLanguage.HLSL;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateOcclusionQuery (TODO)
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region SetTextureSampler (TODO)
|
||||
public void SetTextureSampler(int index, Texture value)
|
||||
{
|
||||
PreventSystemChange();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,6 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ANX.Framework.NonXNA;
|
||||
using SharpDX.Direct3D10;
|
||||
|
||||
#endregion // Using Statements
|
||||
|
||||
// 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
|
||||
@ -16,26 +9,19 @@ namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
public class EffectPass_DX10 : INativeEffectPass
|
||||
{
|
||||
private EffectPass nativePass;
|
||||
|
||||
public EffectPass NativePass
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativePass;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
this.nativePass = value;
|
||||
}
|
||||
}
|
||||
public EffectPass NativePass { get; internal set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return nativePass.Description.Name;
|
||||
return NativePass.Description.Name;
|
||||
}
|
||||
}
|
||||
|
||||
internal EffectPass_DX10(EffectPass setNativePass)
|
||||
{
|
||||
NativePass = setNativePass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +1,49 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using SharpDX.Direct3D10;
|
||||
|
||||
#endregion // Using Statements
|
||||
using Dx10 = SharpDX.Direct3D10;
|
||||
|
||||
// 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
|
||||
|
||||
using EffectPass = ANX.Framework.Graphics.EffectPass;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
public class EffectTechnique_DX10 : INativeEffectTechnique
|
||||
{
|
||||
private EffectTechnique nativeTechnique;
|
||||
private ANX.Framework.Graphics.Effect parentEffect;
|
||||
public class EffectTechnique_DX10 : INativeEffectTechnique
|
||||
{
|
||||
private Effect parentEffect;
|
||||
|
||||
internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect)
|
||||
{
|
||||
if (parentEffect == null)
|
||||
{
|
||||
throw new ArgumentNullException("parentEffect");
|
||||
}
|
||||
public Dx10.EffectTechnique NativeTechnique { get; internal set; }
|
||||
|
||||
this.parentEffect = parentEffect;
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return NativeTechnique.Description.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public EffectTechnique NativeTechnique
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativeTechnique;
|
||||
}
|
||||
internal set
|
||||
{
|
||||
this.nativeTechnique = value;
|
||||
}
|
||||
}
|
||||
public IEnumerable<EffectPass> Passes
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < NativeTechnique.Description.PassCount; i++)
|
||||
{
|
||||
EffectPass_DX10 passDx10 = new EffectPass_DX10(NativeTechnique.GetPassByIndex(i));
|
||||
EffectPass pass = new EffectPass(this.parentEffect);
|
||||
// TODO: wire up native pass and managed pass?
|
||||
yield return pass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return nativeTechnique.Description.Name;
|
||||
}
|
||||
}
|
||||
internal EffectTechnique_DX10(Effect parentEffect)
|
||||
{
|
||||
if (parentEffect == null)
|
||||
throw new ArgumentNullException("parentEffect");
|
||||
|
||||
|
||||
public IEnumerable<EffectPass> Passes
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int i = 0; i < nativeTechnique.Description.PassCount; i++)
|
||||
{
|
||||
EffectPass_DX10 passDx10 = new EffectPass_DX10();
|
||||
passDx10.NativePass = nativeTechnique.GetPassByIndex(i);
|
||||
|
||||
EffectPass pass = new EffectPass(this.parentEffect);
|
||||
|
||||
yield return pass;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.parentEffect = parentEffect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ANX.Framework.NonXNA;
|
||||
using SharpDX.Direct3D10;
|
||||
using System.IO;
|
||||
using ANX.Framework.Graphics;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
|
||||
#endregion // Using Statements
|
||||
using SharpDX.Direct3D10;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -17,133 +10,123 @@ using ANX.Framework.NonXNA.RenderSystem;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
public class IndexBuffer_DX10 : INativeIndexBuffer, IDisposable
|
||||
{
|
||||
private SharpDX.Direct3D10.Buffer buffer;
|
||||
private IndexElementSize size;
|
||||
public class IndexBuffer_DX10 : INativeIndexBuffer, IDisposable
|
||||
{
|
||||
private IndexElementSize size;
|
||||
|
||||
public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
public SharpDX.Direct3D10.Buffer NativeBuffer { get; private set; }
|
||||
|
||||
//TODO: translate and use usage
|
||||
#region Constructor
|
||||
public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
|
||||
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
|
||||
SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null;
|
||||
//TODO: translate and use usage
|
||||
|
||||
InitializeBuffer(device, size, indexCount, usage);
|
||||
}
|
||||
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
|
||||
Device device = gd10 != null ? gd10.NativeDevice as Device : null;
|
||||
|
||||
internal IndexBuffer_DX10(SharpDX.Direct3D10.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
|
||||
InitializeBuffer(device, size, indexCount, usage);
|
||||
}
|
||||
|
||||
private void InitializeBuffer(SharpDX.Direct3D10.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
BufferDescription description = new BufferDescription()
|
||||
{
|
||||
Usage = ResourceUsage.Dynamic,
|
||||
SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
|
||||
BindFlags = BindFlags.IndexBuffer,
|
||||
CpuAccessFlags = CpuAccessFlags.Write,
|
||||
OptionFlags = ResourceOptionFlags.None
|
||||
};
|
||||
|
||||
this.buffer = new SharpDX.Direct3D10.Buffer(device, description);
|
||||
this.buffer.Unmap();
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
//TODO: check offsetInBytes parameter for bounds etc.
|
||||
|
||||
GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
for (int i = startIndex; i < startIndex + elementCount; i++)
|
||||
{
|
||||
d.Write<T>(data[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vData.CopyTo(d);
|
||||
}
|
||||
buffer.Unmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pinnedArray.Free();
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
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
|
||||
|
||||
#region INativeBuffer Member
|
||||
|
||||
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
InitializeBuffer(device, size, indexCount, usage);
|
||||
}
|
||||
|
||||
internal IndexBuffer_DX10(Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
InitializeBuffer(device, size, indexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region InitializeBuffer
|
||||
private void InitializeBuffer(Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
BufferDescription description = new BufferDescription()
|
||||
{
|
||||
Usage = ResourceUsage.Dynamic,
|
||||
SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
|
||||
BindFlags = BindFlags.IndexBuffer,
|
||||
CpuAccessFlags = CpuAccessFlags.Write,
|
||||
OptionFlags = ResourceOptionFlags.None
|
||||
};
|
||||
|
||||
NativeBuffer = new SharpDX.Direct3D10.Buffer(device, description);
|
||||
NativeBuffer.Unmap();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
|
||||
where T : struct
|
||||
{
|
||||
//TODO: check offsetInBytes parameter for bounds etc.
|
||||
|
||||
using (var stream = NativeBuffer.Map(MapMode.WriteDiscard))
|
||||
{
|
||||
if (offsetInBytes > 0)
|
||||
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||
|
||||
if (startIndex > 0 || elementCount < data.Length)
|
||||
for (int i = startIndex; i < startIndex + elementCount; i++)
|
||||
stream.Write<T>(data[i]);
|
||||
else
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
stream.Write<T>(data[i]);
|
||||
|
||||
NativeBuffer.Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
if (NativeBuffer != null)
|
||||
{
|
||||
NativeBuffer.Dispose();
|
||||
NativeBuffer = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -18,301 +18,301 @@ using ANX.Framework;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
public class Texture2D_DX10 : INativeTexture2D
|
||||
{
|
||||
#region Private Members
|
||||
protected internal SharpDX.Direct3D10.Texture2D nativeTexture;
|
||||
protected internal SharpDX.Direct3D10.ShaderResourceView nativeShaderResourceView;
|
||||
protected internal int formatSize;
|
||||
protected internal SurfaceFormat surfaceFormat;
|
||||
protected internal GraphicsDevice graphicsDevice;
|
||||
public class Texture2D_DX10 : INativeTexture2D
|
||||
{
|
||||
#region Private Members
|
||||
protected internal SharpDX.Direct3D10.Texture2D nativeTexture;
|
||||
protected internal SharpDX.Direct3D10.ShaderResourceView nativeShaderResourceView;
|
||||
protected internal int formatSize;
|
||||
protected internal SurfaceFormat surfaceFormat;
|
||||
protected internal GraphicsDevice graphicsDevice;
|
||||
|
||||
#endregion // Private Members
|
||||
#endregion // Private Members
|
||||
|
||||
internal Texture2D_DX10(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
}
|
||||
|
||||
public Texture2D_DX10(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount)
|
||||
{
|
||||
if (mipCount > 1)
|
||||
{
|
||||
throw new Exception("creating textures with mip map not yet implemented");
|
||||
}
|
||||
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
this.surfaceFormat = surfaceFormat;
|
||||
|
||||
GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
|
||||
SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice;
|
||||
|
||||
SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription()
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
MipLevels = mipCount,
|
||||
ArraySize = mipCount,
|
||||
Format = FormatConverter.Translate(surfaceFormat),
|
||||
SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
|
||||
Usage = SharpDX.Direct3D10.ResourceUsage.Dynamic,
|
||||
BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource,
|
||||
CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.Write,
|
||||
OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None,
|
||||
};
|
||||
this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description);
|
||||
this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture);
|
||||
|
||||
// description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx
|
||||
// more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx
|
||||
|
||||
this.formatSize = FormatConverter.FormatSize(surfaceFormat);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return NativeTexture.NativePointer.ToInt32();
|
||||
}
|
||||
|
||||
internal SharpDX.Direct3D10.Texture2D NativeTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativeTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.nativeTexture != value)
|
||||
{
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
this.nativeTexture.Dispose();
|
||||
}
|
||||
|
||||
this.nativeTexture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal SharpDX.Direct3D10.ShaderResourceView NativeShaderResourceView
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativeShaderResourceView;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.nativeShaderResourceView != value)
|
||||
{
|
||||
if (this.nativeShaderResourceView != null)
|
||||
{
|
||||
this.nativeShaderResourceView.Dispose();
|
||||
}
|
||||
|
||||
this.nativeShaderResourceView = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
//TODO: handle offsetInBytes parameter
|
||||
//TODO: handle startIndex parameter
|
||||
//TODO: handle elementCount parameter
|
||||
|
||||
if (this.surfaceFormat == SurfaceFormat.Color)
|
||||
{
|
||||
int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubResourceIndex(0, 0, 1);
|
||||
SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
|
||||
int rowPitch = rectangle.Pitch;
|
||||
|
||||
unsafe
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
byte* colorData = (byte*)handle.AddrOfPinnedObject();
|
||||
|
||||
byte* pTexels = (byte*)rectangle.DataPointer;
|
||||
int srcIndex = 0;
|
||||
|
||||
for (int row = 0; row < Height; row++)
|
||||
{
|
||||
int rowStart = row * rowPitch;
|
||||
|
||||
for (int col = 0; col < Width; col++)
|
||||
{
|
||||
int colStart = col * formatSize;
|
||||
pTexels[rowStart + colStart + 0] = colorData[srcIndex++];
|
||||
pTexels[rowStart + colStart + 1] = colorData[srcIndex++];
|
||||
pTexels[rowStart + colStart + 2] = colorData[srcIndex++];
|
||||
pTexels[rowStart + colStart + 3] = colorData[srcIndex++];
|
||||
}
|
||||
}
|
||||
|
||||
handle.Free();
|
||||
}
|
||||
|
||||
this.nativeTexture.Unmap(subresource);
|
||||
}
|
||||
else if (surfaceFormat == SurfaceFormat.Dxt5 || surfaceFormat == SurfaceFormat.Dxt3 || surfaceFormat == SurfaceFormat.Dxt1)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
byte* colorData = (byte*)handle.AddrOfPinnedObject();
|
||||
|
||||
int w = (Width + 3) >> 2;
|
||||
int h = (Height + 3) >> 2;
|
||||
formatSize = (surfaceFormat == SurfaceFormat.Dxt1) ? 8 : 16;
|
||||
|
||||
int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubResourceIndex(0, 0, 1);
|
||||
SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
|
||||
SharpDX.DataStream ds = new SharpDX.DataStream(rectangle.DataPointer, Width * Height * 4 * 2, true, true);
|
||||
int pitch = rectangle.Pitch;
|
||||
int col = 0;
|
||||
int index = 0; // startIndex
|
||||
int count = data.Length; // elementCount
|
||||
int actWidth = w * formatSize;
|
||||
|
||||
for (int i = 0; i < h; i++)
|
||||
{
|
||||
ds.Position = (i * pitch) + (col * formatSize);
|
||||
if (count <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (count < actWidth)
|
||||
{
|
||||
for (int idx = index; idx < index + count; idx++)
|
||||
{
|
||||
ds.WriteByte(colorData[idx]);
|
||||
}
|
||||
//ds.WriteRange<byte>(colorDataArray, index, count);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
for (int idx = index; idx < index + actWidth; idx++)
|
||||
{
|
||||
ds.WriteByte(colorData[idx]);
|
||||
}
|
||||
//ds.WriteRange<byte>(colorDataArray, index, actWidth);
|
||||
|
||||
index += actWidth;
|
||||
count -= actWidth;
|
||||
}
|
||||
|
||||
handle.Free();
|
||||
|
||||
this.nativeTexture.Unmap(subresource);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
return this.nativeTexture.Description.Width;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
return this.nativeTexture.Description.Height;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public GraphicsDevice GraphicsDevice
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.graphicsDevice;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.nativeShaderResourceView != null)
|
||||
{
|
||||
this.nativeShaderResourceView.Dispose();
|
||||
this.nativeShaderResourceView = null;
|
||||
}
|
||||
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
this.nativeTexture.Dispose();
|
||||
this.nativeTexture = null;
|
||||
}
|
||||
}
|
||||
|
||||
#region SaveAsJpeg (TODO)
|
||||
public void SaveAsJpeg(Stream stream, int width, int height)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SaveAsPng (TODO)
|
||||
public void SaveAsPng(Stream stream, int width, int height)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INativeTexture2D Member
|
||||
|
||||
|
||||
public void GetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INativeBuffer Member
|
||||
|
||||
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
internal Texture2D_DX10(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
}
|
||||
|
||||
public Texture2D_DX10(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount)
|
||||
{
|
||||
if (mipCount > 1)
|
||||
{
|
||||
throw new Exception("creating textures with mip map not yet implemented");
|
||||
}
|
||||
|
||||
this.graphicsDevice = graphicsDevice;
|
||||
this.surfaceFormat = surfaceFormat;
|
||||
|
||||
GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
|
||||
SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice;
|
||||
|
||||
SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription()
|
||||
{
|
||||
Width = width,
|
||||
Height = height,
|
||||
MipLevels = mipCount,
|
||||
ArraySize = mipCount,
|
||||
Format = FormatConverter.Translate(surfaceFormat),
|
||||
SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
|
||||
Usage = SharpDX.Direct3D10.ResourceUsage.Dynamic,
|
||||
BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource,
|
||||
CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.Write,
|
||||
OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None,
|
||||
};
|
||||
this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description);
|
||||
this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture);
|
||||
|
||||
// description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx
|
||||
// more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx
|
||||
|
||||
this.formatSize = FormatConverter.FormatSize(surfaceFormat);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return NativeTexture.NativePointer.ToInt32();
|
||||
}
|
||||
|
||||
internal SharpDX.Direct3D10.Texture2D NativeTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativeTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.nativeTexture != value)
|
||||
{
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
this.nativeTexture.Dispose();
|
||||
}
|
||||
|
||||
this.nativeTexture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal SharpDX.Direct3D10.ShaderResourceView NativeShaderResourceView
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nativeShaderResourceView;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.nativeShaderResourceView != value)
|
||||
{
|
||||
if (this.nativeShaderResourceView != null)
|
||||
{
|
||||
this.nativeShaderResourceView.Dispose();
|
||||
}
|
||||
|
||||
this.nativeShaderResourceView = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
//TODO: handle offsetInBytes parameter
|
||||
//TODO: handle startIndex parameter
|
||||
//TODO: handle elementCount parameter
|
||||
|
||||
if (this.surfaceFormat == SurfaceFormat.Color)
|
||||
{
|
||||
int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubResourceIndex(0, 0, 1);
|
||||
SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
|
||||
int rowPitch = rectangle.Pitch;
|
||||
|
||||
unsafe
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
byte* colorData = (byte*)handle.AddrOfPinnedObject();
|
||||
|
||||
byte* pTexels = (byte*)rectangle.DataPointer;
|
||||
int srcIndex = 0;
|
||||
|
||||
for (int row = 0; row < Height; row++)
|
||||
{
|
||||
int rowStart = row * rowPitch;
|
||||
|
||||
for (int col = 0; col < Width; col++)
|
||||
{
|
||||
int colStart = col * formatSize;
|
||||
pTexels[rowStart + colStart + 0] = colorData[srcIndex++];
|
||||
pTexels[rowStart + colStart + 1] = colorData[srcIndex++];
|
||||
pTexels[rowStart + colStart + 2] = colorData[srcIndex++];
|
||||
pTexels[rowStart + colStart + 3] = colorData[srcIndex++];
|
||||
}
|
||||
}
|
||||
|
||||
handle.Free();
|
||||
}
|
||||
|
||||
this.nativeTexture.Unmap(subresource);
|
||||
}
|
||||
else if (surfaceFormat == SurfaceFormat.Dxt5 || surfaceFormat == SurfaceFormat.Dxt3 || surfaceFormat == SurfaceFormat.Dxt1)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
byte* colorData = (byte*)handle.AddrOfPinnedObject();
|
||||
|
||||
int w = (Width + 3) >> 2;
|
||||
int h = (Height + 3) >> 2;
|
||||
formatSize = (surfaceFormat == SurfaceFormat.Dxt1) ? 8 : 16;
|
||||
|
||||
int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubResourceIndex(0, 0, 1);
|
||||
SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
|
||||
SharpDX.DataStream ds = new SharpDX.DataStream(rectangle.DataPointer, Width * Height * 4 * 2, true, true);
|
||||
int pitch = rectangle.Pitch;
|
||||
int col = 0;
|
||||
int index = 0; // startIndex
|
||||
int count = data.Length; // elementCount
|
||||
int actWidth = w * formatSize;
|
||||
|
||||
for (int i = 0; i < h; i++)
|
||||
{
|
||||
ds.Position = (i * pitch) + (col * formatSize);
|
||||
if (count <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (count < actWidth)
|
||||
{
|
||||
for (int idx = index; idx < index + count; idx++)
|
||||
{
|
||||
ds.WriteByte(colorData[idx]);
|
||||
}
|
||||
//ds.WriteRange<byte>(colorDataArray, index, count);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
for (int idx = index; idx < index + actWidth; idx++)
|
||||
{
|
||||
ds.WriteByte(colorData[idx]);
|
||||
}
|
||||
//ds.WriteRange<byte>(colorDataArray, index, actWidth);
|
||||
|
||||
index += actWidth;
|
||||
count -= actWidth;
|
||||
}
|
||||
|
||||
handle.Free();
|
||||
|
||||
this.nativeTexture.Unmap(subresource);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
return this.nativeTexture.Description.Width;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
return this.nativeTexture.Description.Height;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public GraphicsDevice GraphicsDevice
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.graphicsDevice;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.nativeShaderResourceView != null)
|
||||
{
|
||||
this.nativeShaderResourceView.Dispose();
|
||||
this.nativeShaderResourceView = null;
|
||||
}
|
||||
|
||||
if (this.nativeTexture != null)
|
||||
{
|
||||
this.nativeTexture.Dispose();
|
||||
this.nativeTexture = null;
|
||||
}
|
||||
}
|
||||
|
||||
#region SaveAsJpeg (TODO)
|
||||
public void SaveAsJpeg(Stream stream, int width, int height)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SaveAsPng (TODO)
|
||||
public void SaveAsPng(Stream stream, int width, int height)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region INativeTexture2D Member
|
||||
|
||||
|
||||
public void GetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region INativeBuffer Member
|
||||
|
||||
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ANX.Framework.NonXNA;
|
||||
using SharpDX.Direct3D10;
|
||||
using System.IO;
|
||||
using ANX.Framework.Graphics;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
|
||||
#endregion // Using Statements
|
||||
using SharpDX.Direct3D10;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -17,139 +10,131 @@ using ANX.Framework.NonXNA.RenderSystem;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.DX10
|
||||
{
|
||||
public class VertexBuffer_DX10 : INativeVertexBuffer, IDisposable
|
||||
{
|
||||
SharpDX.Direct3D10.Buffer buffer;
|
||||
int vertexStride;
|
||||
public class VertexBuffer_DX10 : INativeVertexBuffer, IDisposable
|
||||
{
|
||||
int vertexStride;
|
||||
|
||||
public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
|
||||
SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null;
|
||||
public SharpDX.Direct3D10.Buffer NativeBuffer { get; private set; }
|
||||
|
||||
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
|
||||
}
|
||||
#region Constructor
|
||||
public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
|
||||
Device device = gd10 != null ? gd10.NativeDevice as Device : null;
|
||||
|
||||
internal VertexBuffer_DX10(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
|
||||
}
|
||||
|
||||
private void InitializeBuffer(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
this.vertexStride = vertexDeclaration.VertexStride;
|
||||
|
||||
//TODO: translate and use usage
|
||||
|
||||
if (device != null)
|
||||
{
|
||||
BufferDescription description = new BufferDescription()
|
||||
{
|
||||
Usage = ResourceUsage.Dynamic,
|
||||
SizeInBytes = vertexDeclaration.VertexStride * vertexCount,
|
||||
BindFlags = BindFlags.VertexBuffer,
|
||||
CpuAccessFlags = CpuAccessFlags.Write,
|
||||
OptionFlags = ResourceOptionFlags.None
|
||||
};
|
||||
|
||||
this.buffer = new SharpDX.Direct3D10.Buffer(device, description);
|
||||
this.buffer.Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
//TODO: check offsetInBytes parameter for bounds etc.
|
||||
|
||||
GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
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)
|
||||
{
|
||||
vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
using (var d = buffer.Map(MapMode.WriteDiscard))
|
||||
{
|
||||
if (startIndex > 0 || elementCount < data.Length)
|
||||
{
|
||||
for (int i = startIndex; i < startIndex + elementCount; i++)
|
||||
{
|
||||
d.Write<T>(data[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vData.CopyTo(d);
|
||||
}
|
||||
buffer.Unmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pinnedArray.Free();
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
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 INativeVertexBuffer Member
|
||||
|
||||
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
|
||||
{
|
||||
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
|
||||
|
||||
#region INativeBuffer Member
|
||||
|
||||
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
|
||||
}
|
||||
|
||||
internal VertexBuffer_DX10(Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region InitializeBuffer
|
||||
private void InitializeBuffer(Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
|
||||
{
|
||||
this.vertexStride = vertexDeclaration.VertexStride;
|
||||
|
||||
//TODO: translate and use usage
|
||||
|
||||
if (device != null)
|
||||
{
|
||||
BufferDescription description = new BufferDescription()
|
||||
{
|
||||
Usage = ResourceUsage.Dynamic,
|
||||
SizeInBytes = vertexDeclaration.VertexStride * vertexCount,
|
||||
BindFlags = BindFlags.VertexBuffer,
|
||||
CpuAccessFlags = CpuAccessFlags.Write,
|
||||
OptionFlags = ResourceOptionFlags.None
|
||||
};
|
||||
|
||||
NativeBuffer = new SharpDX.Direct3D10.Buffer(device, description);
|
||||
NativeBuffer.Unmap();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#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.
|
||||
|
||||
using (var stream = NativeBuffer.Map(MapMode.WriteDiscard))
|
||||
{
|
||||
if (offsetInBytes > 0)
|
||||
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||
|
||||
if (startIndex > 0 || elementCount < data.Length)
|
||||
for (int i = startIndex; i < startIndex + elementCount; i++)
|
||||
stream.Write<T>(data[i]);
|
||||
else
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
stream.Write<T>(data[i]);
|
||||
|
||||
NativeBuffer.Unmap();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount,
|
||||
int vertexStride) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using ANX.Framework.Windows.GL3;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -330,5 +331,17 @@ namespace ANX.RenderSystem.Windows.GL3
|
||||
return new OcclusionQueryGL3();
|
||||
}
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ namespace ANX.RenderSystem.Windows.GL3
|
||||
if (textureCache == null ||
|
||||
textureCache != value)
|
||||
{
|
||||
textureCache = value;
|
||||
textureCache = value;
|
||||
// TODO: multiple texture units
|
||||
TextureUnit textureUnit = TextureUnit.Texture0;
|
||||
GL.ActiveTexture(textureUnit);
|
||||
|
@ -166,5 +166,12 @@ namespace ANX.RenderSystem.PsVita
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetTextureSampler (TODO)
|
||||
public void SetTextureSampler(int index, Texture value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,6 @@
|
||||
<Compile Include="GraphicsDeviceWindowsDX11.cs" />
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX11.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX11.cs" />
|
||||
<Compile Include="RenderTarget2D_DX11.cs" />
|
||||
|
@ -99,7 +99,6 @@
|
||||
<Compile Include="GraphicsDeviceWindowsDX11.cs" />
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX11.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX11.cs" />
|
||||
<Compile Include="RenderTarget2D_DX11.cs" />
|
||||
|
@ -100,7 +100,6 @@
|
||||
<Compile Include="GraphicsDeviceWindowsDX11.cs" />
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX11.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX11.cs" />
|
||||
<Compile Include="RenderTarget2D_DX11.cs" />
|
||||
|
@ -97,7 +97,6 @@
|
||||
<Compile Include="GraphicsDeviceWindowsDX11.cs" />
|
||||
<Compile Include="IncludeHandler.cs" />
|
||||
<Compile Include="IndexBuffer_DX11.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerState_DX11.cs" />
|
||||
<Compile Include="RenderTarget2D_DX11.cs" />
|
||||
|
@ -249,5 +249,12 @@ namespace ANX.RenderSystem.Windows.DX11
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetTextureSampler (TODO)
|
||||
public void SetTextureSampler(int index, Texture value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,8 @@
|
||||
#region Using Statements
|
||||
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;
|
||||
|
||||
#endregion // Using Statements
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using SharpDX.Direct3D11;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
@ -19,58 +11,66 @@ using System.IO;
|
||||
namespace ANX.RenderSystem.Windows.DX11
|
||||
{
|
||||
public class IndexBuffer_DX11 : INativeIndexBuffer, IDisposable
|
||||
{
|
||||
private SharpDX.Direct3D11.Buffer buffer;
|
||||
private IndexElementSize size;
|
||||
{
|
||||
private IndexElementSize size;
|
||||
|
||||
public IndexBuffer_DX11(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
public SharpDX.Direct3D11.Buffer NativeBuffer { get; private set; }
|
||||
|
||||
//TODO: translate and use usage
|
||||
#region Constructor
|
||||
public IndexBuffer_DX11(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
|
||||
GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
|
||||
SharpDX.Direct3D11.DeviceContext context = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : null;
|
||||
//TODO: translate and use usage
|
||||
|
||||
InitializeBuffer(context.Device, size, indexCount, usage);
|
||||
}
|
||||
GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
|
||||
SharpDX.Direct3D11.DeviceContext context = gd11 != null ?
|
||||
gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext :
|
||||
null;
|
||||
|
||||
internal IndexBuffer_DX11(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
InitializeBuffer(context.Device, size, indexCount, usage);
|
||||
}
|
||||
|
||||
InitializeBuffer(device, size, indexCount, usage);
|
||||
}
|
||||
internal IndexBuffer_DX11(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
this.size = size;
|
||||
InitializeBuffer(device, size, indexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void InitializeBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
BufferDescription description = new BufferDescription()
|
||||
{
|
||||
Usage = ResourceUsage.Dynamic,
|
||||
SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
|
||||
BindFlags = BindFlags.IndexBuffer,
|
||||
CpuAccessFlags = CpuAccessFlags.Write,
|
||||
OptionFlags = ResourceOptionFlags.None
|
||||
};
|
||||
#region InitializeBuffer
|
||||
private void InitializeBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
|
||||
{
|
||||
BufferDescription description = new BufferDescription()
|
||||
{
|
||||
// TODO: translate usage
|
||||
Usage = ResourceUsage.Dynamic,
|
||||
SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
|
||||
BindFlags = BindFlags.IndexBuffer,
|
||||
CpuAccessFlags = CpuAccessFlags.Write,
|
||||
OptionFlags = ResourceOptionFlags.None
|
||||
};
|
||||
|
||||
this.buffer = new SharpDX.Direct3D11.Buffer(device, description);
|
||||
}
|
||||
NativeBuffer = new SharpDX.Direct3D11.Buffer(device, description);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||
}
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
|
||||
where T : struct
|
||||
{
|
||||
GraphicsDeviceWindowsDX11 dx11GraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX11;
|
||||
DeviceContext context = dx11GraphicsDevice.NativeDevice;
|
||||
{
|
||||
GraphicsDeviceWindowsDX11 dx11GraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX11;
|
||||
DeviceContext context = dx11GraphicsDevice.NativeDevice;
|
||||
|
||||
//TODO: check offsetInBytes parameter for bounds etc.
|
||||
//TODO: check offsetInBytes parameter for bounds etc.
|
||||
|
||||
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)
|
||||
stream.Seek(offsetInBytes, SeekOrigin.Current);
|
||||
@ -82,53 +82,61 @@ namespace ANX.RenderSystem.Windows.DX11
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
stream.Write<T>(data[i]);
|
||||
|
||||
context.UnmapSubresource(this.buffer, 0);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
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
|
||||
|
||||
#region INativeBuffer Member
|
||||
|
||||
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
context.UnmapSubresource(NativeBuffer, 0);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
if (NativeBuffer != null)
|
||||
{
|
||||
NativeBuffer.Dispose();
|
||||
NativeBuffer = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -14,16 +14,12 @@ namespace ANX.RenderSystem.Windows.DX11
|
||||
{
|
||||
int vertexStride;
|
||||
|
||||
public SharpDX.Direct3D11.Buffer NativeBuffer
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public SharpDX.Direct3D11.Buffer NativeBuffer { get; private set; }
|
||||
|
||||
#region Constructor
|
||||
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 ?
|
||||
gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext :
|
||||
null;
|
||||
@ -115,20 +111,39 @@ namespace ANX.RenderSystem.Windows.DX11
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData (TODO)
|
||||
#region GetData
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
}
|
||||
|
@ -279,5 +279,12 @@ namespace ANX.RenderSystem.Windows.Metro
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetTextureSampler (TODO)
|
||||
public void SetTextureSampler(int index, Texture value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -52,22 +52,16 @@ namespace ANXStatusComparer.Data
|
||||
foreach (Type type in types)
|
||||
{
|
||||
if (String.IsNullOrEmpty(type.Namespace))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Namespaces.ContainsKey(type.Namespace) == false)
|
||||
{
|
||||
Namespaces.Add(type.Namespace, new NamespaceData(type.Namespace));
|
||||
}
|
||||
Namespaces[type.Namespace].AllTypes.Add(type);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string key in Namespaces.Keys)
|
||||
{
|
||||
Namespaces[key].ParseTypes();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
#region Private Members
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
#endregion // Private Members
|
||||
|
||||
// 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
|
||||
@ -191,8 +188,7 @@ namespace ANXStatusComparer.Data
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (HasPercentageAttribute ?
|
||||
PercentageComplete.ToString("000") : "-?-") + "% - " + Handle.FullName;
|
||||
return (HasPercentageAttribute ? PercentageComplete.ToString("000") : "-?-") + "% - " + Handle.FullName;
|
||||
}
|
||||
|
||||
#region IsCorrect
|
||||
@ -201,21 +197,13 @@ namespace ANXStatusComparer.Data
|
||||
{
|
||||
bool isCorrect = true;
|
||||
if (CompareLists(Methods, otherObject.Methods, wrongPair) == false)
|
||||
{
|
||||
isCorrect = false;
|
||||
}
|
||||
if (CompareLists(Events, otherObject.Events, wrongPair) == false)
|
||||
{
|
||||
isCorrect = false;
|
||||
}
|
||||
if (CompareLists(Fields, otherObject.Fields, wrongPair) == false)
|
||||
{
|
||||
isCorrect = false;
|
||||
}
|
||||
if (CompareLists(Properties, otherObject.Properties, wrongPair) == false)
|
||||
{
|
||||
isCorrect = false;
|
||||
}
|
||||
|
||||
foreach(string parent in ParentNames)
|
||||
{
|
||||
@ -228,37 +216,33 @@ namespace ANXStatusComparer.Data
|
||||
|
||||
if (Handle.IsPublic != otherObject.Handle.IsPublic)
|
||||
{
|
||||
wrongPair.WrongAccesses.Add("[IsPublic(XNA:" + Handle.IsPublic +
|
||||
"|ANX:" + otherObject.Handle.IsPublic + ")] ");
|
||||
wrongPair.WrongAccesses.Add("[IsPublic(XNA:" + Handle.IsPublic + "|ANX:" + otherObject.Handle.IsPublic + ")] ");
|
||||
isCorrect = false;
|
||||
}
|
||||
|
||||
if (Handle.IsSealed != otherObject.Handle.IsSealed)
|
||||
{
|
||||
wrongPair.WrongAccesses.Add("[IsSealed(XNA:" + Handle.IsSealed +
|
||||
"|ANX:" + otherObject.Handle.IsSealed + ")] ");
|
||||
wrongPair.WrongAccesses.Add("[IsSealed(XNA:" + Handle.IsSealed + "|ANX:" + otherObject.Handle.IsSealed + ")] ");
|
||||
isCorrect = false;
|
||||
}
|
||||
|
||||
if (Handle.IsAbstract != otherObject.Handle.IsAbstract)
|
||||
{
|
||||
wrongPair.WrongAccesses.Add("[IsAbstract(XNA:" + Handle.IsAbstract +
|
||||
"|ANX:" + otherObject.Handle.IsAbstract + ")] ");
|
||||
wrongPair.WrongAccesses.Add("[IsAbstract(XNA:" + Handle.IsAbstract + "|ANX:" + otherObject.Handle.IsAbstract + ")] ");
|
||||
isCorrect = false;
|
||||
}
|
||||
|
||||
if (Handle.IsGenericType != otherObject.Handle.IsGenericType)
|
||||
{
|
||||
wrongPair.WrongAccesses.Add("[IsGenericType(XNA:" +
|
||||
Handle.IsGenericType +
|
||||
"|ANX:" + otherObject.Handle.IsGenericType + ")] ");
|
||||
wrongPair.WrongAccesses.Add("[IsGenericType(XNA:" + Handle.IsGenericType + "|ANX:" +
|
||||
otherObject.Handle.IsGenericType + ")] ");
|
||||
isCorrect = false;
|
||||
}
|
||||
|
||||
if (Handle.IsVisible != otherObject.Handle.IsVisible)
|
||||
{
|
||||
wrongPair.WrongAccesses.Add("[IsVisible(XNA:" + Handle.IsVisible +
|
||||
"|ANX:" + otherObject.Handle.IsVisible + ")] ");
|
||||
wrongPair.WrongAccesses.Add("[IsVisible(XNA:" + Handle.IsVisible + "|ANX:" + otherObject.Handle.IsVisible +
|
||||
")] ");
|
||||
isCorrect = false;
|
||||
}
|
||||
|
||||
@ -267,8 +251,7 @@ namespace ANXStatusComparer.Data
|
||||
#endregion
|
||||
|
||||
#region CompareLists
|
||||
private bool CompareLists(Dictionary<string, BaseObjectElement> dictXna,
|
||||
Dictionary<string, BaseObjectElement> dictAnx,
|
||||
private bool CompareLists(Dictionary<string, BaseObjectElement> dictXna, Dictionary<string, BaseObjectElement> dictAnx,
|
||||
ResultData.WrongObjectPair wrongPair)
|
||||
{
|
||||
bool isCorrect = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user