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

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

View File

@ -442,6 +442,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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();
}
}
}

View File

@ -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,14 +8,13 @@ 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);

View File

@ -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,108 +610,90 @@ 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);
}
}
}
}
}
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);
}
}
}

View File

@ -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.
@ -11,16 +9,25 @@ namespace ANX.Framework.Graphics
{
public sealed class TextureCollection
{
private Texture[] textures;
public Texture this[int index]
{
get
{
throw new NotImplementedException();
return textures[index];
}
set
{
throw new NotImplementedException();
textures[index] = value;
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
creator.SetTextureSampler(index, value);
}
}
internal TextureCollection(int maxNumberOfTextures)
{
textures = new Texture[maxNumberOfTextures];
}
}
}

View File

@ -9,7 +9,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input.Touch
{
[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

View File

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

View File

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

View File

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

View File

@ -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

View File

@ -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;

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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,26 +37,40 @@ 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);
}
#endregion
#if XNAEXT
#region CreateConstantBuffer
@ -70,100 +83,87 @@ namespace ANX.RenderSystem.Windows.DX10
#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)
{
case PreDefinedShader.SpriteBatch:
return ShaderByteCode.SpriteBatchByteCode;
}
else if (type == PreDefinedShader.AlphaTestEffect)
{
case PreDefinedShader.AlphaTestEffect:
return ShaderByteCode.AlphaTestEffectByteCode;
}
else if (type == PreDefinedShader.BasicEffect)
{
case PreDefinedShader.BasicEffect:
return ShaderByteCode.BasicEffectByteCode;
}
else if (type == PreDefinedShader.DualTextureEffect)
{
case PreDefinedShader.DualTextureEffect:
return ShaderByteCode.DualTextureEffectByteCode;
}
else if (type == PreDefinedShader.EnvironmentMapEffect)
{
case PreDefinedShader.EnvironmentMapEffect:
return ShaderByteCode.EnvironmentMapEffectByteCode;
}
else if (type == PreDefinedShader.SkinnedEffect)
{
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,14 +238,25 @@ namespace ANX.RenderSystem.Windows.DX10
}
#endregion
#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

View File

@ -1,13 +1,6 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using 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;
}
}
}

View File

@ -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;
private Effect parentEffect;
internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect)
{
if (parentEffect == null)
{
throw new ArgumentNullException("parentEffect");
}
this.parentEffect = parentEffect;
}
public EffectTechnique NativeTechnique
{
get
{
return this.nativeTechnique;
}
internal set
{
this.nativeTechnique = value;
}
}
public Dx10.EffectTechnique NativeTechnique { get; internal set; }
public string Name
{
get
{
return nativeTechnique.Description.Name;
return NativeTechnique.Description.Name;
}
}
public IEnumerable<EffectPass> Passes
{
get
{
for (int i = 0; i < nativeTechnique.Description.PassCount; i++)
for (int i = 0; i < NativeTechnique.Description.PassCount; i++)
{
EffectPass_DX10 passDx10 = new EffectPass_DX10();
passDx10.NativePass = nativeTechnique.GetPassByIndex(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;
}
}
}
internal EffectTechnique_DX10(Effect parentEffect)
{
if (parentEffect == null)
throw new ArgumentNullException("parentEffect");
this.parentEffect = parentEffect;
}
}
}

View File

@ -1,15 +1,8 @@
#region Using Statements
using System;
using System.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.
@ -19,9 +12,11 @@ namespace ANX.RenderSystem.Windows.DX10
{
public class IndexBuffer_DX10 : INativeIndexBuffer, IDisposable
{
private SharpDX.Direct3D10.Buffer buffer;
private IndexElementSize size;
public SharpDX.Direct3D10.Buffer NativeBuffer { get; private set; }
#region Constructor
public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
{
this.size = size;
@ -29,19 +24,20 @@ namespace ANX.RenderSystem.Windows.DX10
//TODO: translate and use usage
GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null;
Device device = gd10 != null ? gd10.NativeDevice as Device : null;
InitializeBuffer(device, size, indexCount, usage);
}
internal IndexBuffer_DX10(SharpDX.Direct3D10.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
internal IndexBuffer_DX10(Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{
this.size = size;
InitializeBuffer(device, size, indexCount, usage);
}
#endregion
private void InitializeBuffer(SharpDX.Direct3D10.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
#region InitializeBuffer
private void InitializeBuffer(Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{
BufferDescription description = new BufferDescription()
{
@ -52,98 +48,85 @@ namespace ANX.RenderSystem.Windows.DX10
OptionFlags = ResourceOptionFlags.None
};
this.buffer = new SharpDX.Direct3D10.Buffer(device, description);
this.buffer.Unmap();
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
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))
using (var stream = NativeBuffer.Map(MapMode.WriteDiscard))
{
if (offsetInBytes > 0)
{
vData.Seek(offsetInBytes / (size == IndexElementSize.SixteenBits ? 2 : 4), System.IO.SeekOrigin.Begin);
}
stream.Seek(offsetInBytes, SeekOrigin.Current);
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]);
}
}
stream.Write<T>(data[i]);
else
{
vData.CopyTo(d);
}
buffer.Unmap();
}
}
}
for (int i = 0; i < data.Length; i++)
stream.Write<T>(data[i]);
pinnedArray.Free();
NativeBuffer.Unmap();
}
}
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
#region Dispose
public void Dispose()
{
if (NativeBuffer != null)
{
NativeBuffer.Dispose();
NativeBuffer = null;
}
}
#endregion
#region GetData
public void GetData<T>(T[] data) where T : struct
{
throw new NotImplementedException();
using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, 0, data.Length);
NativeBuffer.Unmap();
}
}
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
}
}
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
{
using (var stream = NativeBuffer.Map(MapMode.Read))
{
if (offsetInBytes > 0)
stream.Seek(offsetInBytes, SeekOrigin.Current);
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
}
}
#endregion
}
}

View File

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

View File

@ -1,15 +1,8 @@
#region Using Statements
using System;
using System.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.
@ -19,23 +12,27 @@ namespace ANX.RenderSystem.Windows.DX10
{
public class VertexBuffer_DX10 : INativeVertexBuffer, IDisposable
{
SharpDX.Direct3D10.Buffer buffer;
int vertexStride;
public SharpDX.Direct3D10.Buffer NativeBuffer { get; private set; }
#region Constructor
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;
Device device = gd10 != null ? gd10.NativeDevice as Device : null;
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
}
internal VertexBuffer_DX10(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
internal VertexBuffer_DX10(Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
}
#endregion
private void InitializeBuffer(SharpDX.Direct3D10.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
#region InitializeBuffer
private void InitializeBuffer(Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{
this.vertexStride = vertexDeclaration.VertexStride;
@ -52,48 +49,32 @@ namespace ANX.RenderSystem.Windows.DX10
OptionFlags = ResourceOptionFlags.None
};
this.buffer = new SharpDX.Direct3D10.Buffer(device, description);
this.buffer.Unmap();
NativeBuffer = new SharpDX.Direct3D10.Buffer(device, description);
NativeBuffer.Unmap();
}
}
#endregion
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
#region SetData
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
where T : struct
{
//TODO: check offsetInBytes parameter for bounds etc.
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))
using (var stream = NativeBuffer.Map(MapMode.WriteDiscard))
{
if (offsetInBytes > 0)
{
vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin);
}
stream.Seek(offsetInBytes, SeekOrigin.Current);
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]);
}
}
stream.Write<T>(data[i]);
else
{
vData.CopyTo(d);
}
buffer.Unmap();
}
}
}
for (int i = 0; i < data.Length; i++)
stream.Write<T>(data[i]);
pinnedArray.Free();
NativeBuffer.Unmap();
}
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
@ -106,50 +87,54 @@ namespace ANX.RenderSystem.Windows.DX10
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
}
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
public void SetData<T>(GraphicsDevice graphicsDevice, 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
#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
{
throw new NotImplementedException();
using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, 0, data.Length);
NativeBuffer.Unmap();
}
}
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
using (var stream = NativeBuffer.Map(MapMode.Read))
{
stream.ReadRange(data, startIndex, elementCount);
NativeBuffer.Unmap();
}
}
#endregion
#region Dispose
public void Dispose()
{
if (this.NativeBuffer != null)
{
NativeBuffer.Dispose();
NativeBuffer = null;
}
}
#endregion
}
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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
}
}

View File

@ -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.
@ -20,9 +12,11 @@ namespace ANX.RenderSystem.Windows.DX11
{
public class IndexBuffer_DX11 : INativeIndexBuffer, IDisposable
{
private SharpDX.Direct3D11.Buffer buffer;
private IndexElementSize size;
public SharpDX.Direct3D11.Buffer NativeBuffer { get; private set; }
#region Constructor
public IndexBuffer_DX11(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
{
this.size = size;
@ -30,7 +24,9 @@ namespace ANX.RenderSystem.Windows.DX11
//TODO: translate and use usage
GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
SharpDX.Direct3D11.DeviceContext context = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext : null;
SharpDX.Direct3D11.DeviceContext context = gd11 != null ?
gd11.NativeDevice as SharpDX.Direct3D11.DeviceContext :
null;
InitializeBuffer(context.Device, size, indexCount, usage);
}
@ -38,14 +34,16 @@ namespace ANX.RenderSystem.Windows.DX11
internal IndexBuffer_DX11(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
{
this.size = size;
InitializeBuffer(device, size, indexCount, usage);
}
#endregion
#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,
@ -53,9 +51,11 @@ namespace ANX.RenderSystem.Windows.DX11
OptionFlags = ResourceOptionFlags.None
};
this.buffer = new SharpDX.Direct3D11.Buffer(device, description);
NativeBuffer = new SharpDX.Direct3D11.Buffer(device, description);
}
#endregion
#region SetData
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
{
SetData<T>(graphicsDevice, data, 0, data.Length);
@ -70,7 +70,7 @@ namespace ANX.RenderSystem.Windows.DX11
//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,51 +82,59 @@ namespace ANX.RenderSystem.Windows.DX11
for (int i = 0; i < data.Length; i++)
stream.Write<T>(data[i]);
context.UnmapSubresource(this.buffer, 0);
context.UnmapSubresource(NativeBuffer, 0);
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
{
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
#region Dispose
public void Dispose()
{
if (NativeBuffer != null)
{
NativeBuffer.Dispose();
NativeBuffer = null;
}
}
#endregion
#region GetData
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);
}
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

View File

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

View File

@ -14,16 +14,12 @@ namespace ANX.RenderSystem.Windows.DX11
{
int vertexStride;
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
}

View File

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

View File

@ -52,23 +52,17 @@ namespace ANXStatusComparer.Data
foreach (Type type in types)
{
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
}
}

View File

@ -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;