- Implemented ContentManager.OpenStream for Metro (Texture loading works already)

- Started refactoring all the Metro rendering classes
- Fixed some missing License headers
This commit is contained in:
SND\AstrorEnales_cp 2012-08-14 08:44:12 +00:00
parent b2bd44289f
commit eccbb00742
50 changed files with 1021 additions and 787 deletions

View File

@ -67,21 +67,27 @@ namespace ANX.Framework.NonXNA.Reflection
#region LoadStreamFromMetroAssets
#if WINDOWSMETRO
private async void LoadStreamFromMetroAssets()
private void LoadStreamFromMetroAssets()
{
var library = Windows.ApplicationModel.Package.Current.InstalledLocation;
//assemblyListStream = await library.OpenStreamForReadAsync("Assets\\" + Filename);
try
{
var task = library.OpenStreamForReadAsync("Assets\\" + Filename);
assemblyListStream = TaskHelper.WaitForAsyncOperation(task);
}
catch
{
assemblyListStream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(assemblyListStream);
writer.Write(5);
writer.Write("ANX.PlatformSystem.Metro");
writer.Write("ANX.RenderSystem.Windows.Metro");
writer.Write("ANX.InputSystem.Standard");
writer.Write("ANX.MediaSystem.Windows.OpenAL");
writer.Write("ANX.SoundSystem.Windows.XAudio");
assemblyListStream = new MemoryStream();
BinaryWriter writer = new BinaryWriter(assemblyListStream);
writer.Write(5);
writer.Write("ANX.PlatformSystem.Metro");
writer.Write("ANX.RenderSystem.Windows.Metro");
writer.Write("ANX.InputSystem.Standard");
writer.Write("ANX.MediaSystem.Windows.OpenAL");
writer.Write("ANX.SoundSystem.Windows.XAudio");
assemblyListStream.Position = 0;
assemblyListStream.Position = 0;
}
}
#endif
#endregion

View File

@ -1,14 +1,12 @@
#region Using Statements
#if WINDOWSMETRO
using System;
using System.Collections;
#endregion
using System.Threading.Tasks;
// 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
#if WINDOWSMETRO
namespace ANX.Framework
{
public struct DictionaryEntry
@ -34,5 +32,14 @@ namespace ANX.Framework
set { this.value = value; }
}
}
public static class TaskHelper
{
public static T WaitForAsyncOperation<T>(Task<T> task)
{
task.Wait();
return task.Result;
}
}
}
#endif

View File

@ -36,6 +36,9 @@
<ItemGroup>
<Compile Include="MetroContentManager.cs" />
<Compile Include="MetroGameTimer.cs" />
<Compile Include="MetroStorageContainer.cs" />
<Compile Include="MetroStorageDevice.cs" />
<Compile Include="MetroTitleContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MetroPlatformCreator.cs" />
<Compile Include="SupportedPlatformsImpl.cs" />

View File

@ -36,6 +36,9 @@
<ItemGroup>
<Compile Include="MetroContentManager.cs" />
<Compile Include="MetroGameTimer.cs" />
<Compile Include="MetroStorageContainer.cs" />
<Compile Include="MetroStorageDevice.cs" />
<Compile Include="MetroTitleContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MetroPlatformCreator.cs" />
<Compile Include="SupportedPlatformsImpl.cs" />

View File

@ -36,6 +36,9 @@
<ItemGroup>
<Compile Include="MetroContentManager.cs" />
<Compile Include="MetroGameTimer.cs" />
<Compile Include="MetroStorageContainer.cs" />
<Compile Include="MetroStorageDevice.cs" />
<Compile Include="MetroTitleContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MetroPlatformCreator.cs" />
<Compile Include="SupportedPlatformsImpl.cs" />

View File

@ -38,6 +38,9 @@
<ItemGroup>
<Compile Include="MetroContentManager.cs" />
<Compile Include="MetroGameTimer.cs" />
<Compile Include="MetroStorageContainer.cs" />
<Compile Include="MetroStorageDevice.cs" />
<Compile Include="MetroTitleContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MetroPlatformCreator.cs" />
<Compile Include="SupportedPlatformsImpl.cs" />

View File

@ -1,19 +1,68 @@
using System;
using System.IO;
using System.IO;
using ANX.Framework;
using ANX.Framework.NonXNA.PlatformSystem;
using Windows.ApplicationModel;
using Windows.Storage;
// 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.PlatformSystem.Metro
{
public class MetroContentManager : INativeContentManager
{
#region Private
private StorageFolder installLocation;
#endregion
#region Constructor
public MetroContentManager()
{
installLocation = Package.Current.InstalledLocation;
}
#endregion
#region MakeRootDirectoryAbsolute
public string MakeRootDirectoryAbsolute(string relativePath)
{
return relativePath;
return Path.Combine("Assets", relativePath);
}
#endregion
#region OpenStream
public Stream OpenStream(string filepath)
{
filepath = filepath.Replace("/", "\\");
Stream filestream = LoadStreamFromMetroAssets(filepath);
// TODO: this copy is really inefficient!!
// Find out why reading from the asset stream causes
// the position property to go crazy :/
MemoryStream stream = new MemoryStream();
filestream.CopyTo(stream);
filestream.Dispose();
filestream = null;
stream.Position = 0;
return stream;
}
#endregion
#region LoadStreamFromMetroAssets
private Stream LoadStreamFromMetroAssets(string filepath)
{
try
{
var task = installLocation.OpenStreamForReadAsync(filepath);
return TaskHelper.WaitForAsyncOperation(task);
}
catch
{
}
return null;
}
#endregion
}
}

View File

@ -2,6 +2,10 @@
using System.Diagnostics;
using ANX.Framework.NonXNA.PlatformSystem;
// 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.PlatformSystem.Metro
{
public class MetroGameTimer : INativeGameTimer

View File

@ -62,25 +62,25 @@ namespace ANX.PlatformSystem.Metro
}
#endregion
#region CreateStorageDevice (TODO)
#region CreateStorageDevice
public INativeStorageDevice CreateStorageDevice(StorageDevice device,
PlayerIndex player, int sizeInBytes, int directoryCount)
{
throw new NotImplementedException();
return new MetroStorageDevice();
}
#endregion
#region CreateStorageContainer (TODO)
#region CreateStorageContainer
public INativeStorageContainer CreateStorageContainer(StorageContainer container)
{
throw new NotImplementedException();
return new MetroStorageContainer();
}
#endregion
#region CreateTitleContainer (TODO)
#region CreateTitleContainer
public INativeTitleContainer CreateTitleContainer()
{
throw new NotImplementedException();
return new MetroTitleContainer();
}
#endregion

View File

@ -0,0 +1,59 @@
using System;
using System.IO;
using ANX.Framework.NonXNA.PlatformSystem;
// 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.PlatformSystem.Metro
{
public class MetroStorageContainer : INativeStorageContainer
{
public void CreateDirectory(string directory)
{
throw new NotImplementedException();
}
public System.IO.Stream CreateFile(string file)
{
throw new NotImplementedException();
}
public void DeleteDirectory(string directory)
{
throw new NotImplementedException();
}
public void DeleteFile(string file)
{
throw new NotImplementedException();
}
public bool DirectoryExists(string directory)
{
throw new NotImplementedException();
}
public bool FileExists(string file)
{
throw new NotImplementedException();
}
public string[] GetDirectoryNames(string searchPattern)
{
throw new NotImplementedException();
}
public string[] GetFileNames(string searchPattern)
{
throw new NotImplementedException();
}
public Stream OpenFile(string file, FileMode fileMode, FileAccess fileAccess,
FileShare fileShare)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,41 @@
using System;
using ANX.Framework.NonXNA.PlatformSystem;
// 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.PlatformSystem.Metro
{
public class MetroStorageDevice : INativeStorageDevice
{
public long FreeSpace
{
get
{
return 0;
}
}
public long TotalSpace
{
get
{
return 0;
}
}
public bool IsConnected
{
get
{
return true;
}
}
public void DeleteContainer(string titleName)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.IO;
using ANX.Framework.NonXNA.PlatformSystem;
// 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.PlatformSystem.Metro
{
public class MetroTitleContainer : INativeTitleContainer
{
public Stream OpenStream(string name)
{
throw new NotImplementedException();
}
public string GetCleanPath(string path)
{
// TODO
return path;
}
}
}

View File

@ -36,6 +36,7 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Include="BaseStateObject.cs" />
<Compile Include="NativeDxDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -36,6 +36,7 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Include="BaseStateObject.cs" />
<Compile Include="NativeDxDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -37,6 +37,7 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Include="BaseStateObject.cs" />
<Compile Include="NativeDxDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -38,6 +38,7 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Compile Include="BaseStateObject.cs" />
<Compile Include="NativeDxDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -0,0 +1,52 @@
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.Metro
{
public abstract class BaseStateObject
{
#region Private
protected bool isDirty;
protected bool bound;
#endregion
#region Public
public bool IsBound
{
get
{
return bound;
}
}
#endregion
#region Constructor
protected BaseStateObject()
{
isDirty = true;
}
#endregion
#region Release
public void Release()
{
bound = false;
}
#endregion
#region SetValueIfDifferentAndMarkDirty
protected void SetValueIfDifferentAndMarkDirty<T>(
ref T oldValue, ref T newValue)
{
if (oldValue.Equals(newValue) == false)
{
isDirty = true;
oldValue = newValue;
}
}
#endregion
}
}

View File

@ -9,65 +9,16 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro
{
public class BlendState_Metro : INativeBlendState
public class BlendState_Metro : BaseStateObject, INativeBlendState
{
#region Private Members
#region Private
private Dx11.BlendStateDescription blendStateDescription;
private Dx11.BlendState nativeBlendState;
private bool nativeBlendStateDirty;
private SharpDX.Color4 blendFactor;
private int multiSampleMask;
private bool bound;
#endregion // Private Members
public BlendState_Metro()
{
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
blendStateDescription.RenderTarget[i] = new Dx11.RenderTargetBlendDescription();
blendStateDescription.RenderTarget[i].IsBlendEnabled = (i < 4);
blendStateDescription.IndependentBlendEnable = true;
}
nativeBlendStateDirty = true;
}
public void Apply(GraphicsDevice graphicsDevice)
{
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
var device = gdMetro.NativeDevice.NativeDevice;
var context = gdMetro.NativeDevice.NativeContext;
UpdateNativeBlendState(device);
this.bound = true;
context.OutputMerger.SetBlendState(nativeBlendState, this.blendFactor, this.multiSampleMask);
}
public void Release()
{
this.bound = false;
}
public void Dispose()
{
if (this.nativeBlendState != null)
{
this.nativeBlendState.Dispose();
this.nativeBlendState = null;
}
}
public bool IsBound
{
get
{
return this.bound;
}
}
#endregion
#region Public
public Color BlendFactor
{
set
@ -97,12 +48,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
if (blendStateDescription.RenderTarget[i].AlphaBlendOperation != alphaBlendOperation)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[i].AlphaBlendOperation = alphaBlendOperation;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[i].AlphaBlendOperation,
ref alphaBlendOperation);
}
}
}
@ -115,12 +63,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
if (blendStateDescription.RenderTarget[i].BlendOperation != blendOperation)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[i].BlendOperation = blendOperation;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[i].BlendOperation,
ref blendOperation);
}
}
}
@ -133,12 +78,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
if (blendStateDescription.RenderTarget[i].DestinationAlphaBlend != destinationAlphaBlend)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[i].DestinationAlphaBlend = destinationAlphaBlend;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[i].DestinationAlphaBlend,
ref destinationAlphaBlend);
}
}
}
@ -151,12 +93,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
if (blendStateDescription.RenderTarget[i].DestinationBlend != destinationBlend)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[i].DestinationBlend = destinationBlend;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[i].DestinationBlend,
ref destinationBlend);
}
}
}
@ -166,14 +105,10 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check
if (blendStateDescription.RenderTarget[0].RenderTargetWriteMask != renderTargetWriteMask)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[0].RenderTargetWriteMask = renderTargetWriteMask;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[0].RenderTargetWriteMask,
ref renderTargetWriteMask);
}
}
@ -182,14 +117,10 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check
if (blendStateDescription.RenderTarget[1].RenderTargetWriteMask != renderTargetWriteMask)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[1].RenderTargetWriteMask = renderTargetWriteMask;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[1].RenderTargetWriteMask,
ref renderTargetWriteMask);
}
}
@ -198,14 +129,10 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check
if (blendStateDescription.RenderTarget[2].RenderTargetWriteMask != renderTargetWriteMask)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[2].RenderTargetWriteMask = renderTargetWriteMask;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[2].RenderTargetWriteMask,
ref renderTargetWriteMask);
}
}
@ -214,14 +141,10 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check
if (blendStateDescription.RenderTarget[3].RenderTargetWriteMask != renderTargetWriteMask)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[3].RenderTargetWriteMask = renderTargetWriteMask;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[3].RenderTargetWriteMask,
ref renderTargetWriteMask);
}
}
@ -233,12 +156,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
if (blendStateDescription.RenderTarget[i].SourceAlphaBlend != sourceAlphaBlend)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[i].SourceAlphaBlend = sourceAlphaBlend;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[i].SourceAlphaBlend,
ref sourceAlphaBlend);
}
}
}
@ -251,30 +171,71 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
if (blendStateDescription.RenderTarget[i].SourceBlend != sourceBlend)
{
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[i].SourceBlend = sourceBlend;
}
SetValueIfDifferentAndMarkDirty(
ref blendStateDescription.RenderTarget[i].SourceBlend,
ref sourceBlend);
}
}
}
#endregion
#region Constructor
public BlendState_Metro()
: base()
{
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{
blendStateDescription.RenderTarget[i] = new Dx11.RenderTargetBlendDescription();
blendStateDescription.RenderTarget[i].IsBlendEnabled = (i < 4);
blendStateDescription.IndependentBlendEnable = true;
}
}
#endregion
#region Apply
public void Apply(GraphicsDevice graphicsDevice)
{
GraphicsDeviceWindowsMetro gdMetro =
graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
var device = gdMetro.NativeDevice.NativeDevice;
var context = gdMetro.NativeDevice.NativeContext;
UpdateNativeBlendState(device);
this.bound = true;
context.OutputMerger.SetBlendState(nativeBlendState,
this.blendFactor, this.multiSampleMask);
}
#endregion
#region Dispose
public void Dispose()
{
if (this.nativeBlendState != null)
{
this.nativeBlendState.Dispose();
this.nativeBlendState = null;
}
}
#endregion
#region UpdateNativeBlendState
private void UpdateNativeBlendState(Dx11.Device device)
{
if (this.nativeBlendStateDirty == true || this.nativeBlendState == null)
if (isDirty == true || nativeBlendState == null)
{
if (this.nativeBlendState != null)
if (nativeBlendState != null)
{
this.nativeBlendState.Dispose();
this.nativeBlendState = null;
nativeBlendState.Dispose();
nativeBlendState = null;
}
this.nativeBlendState = new Dx11.BlendState(device, ref this.blendStateDescription);
nativeBlendState = new Dx11.BlendState(device,
ref blendStateDescription);
this.nativeBlendStateDirty = false;
isDirty = false;
}
}
#endregion
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
@ -12,14 +13,21 @@ namespace ANX.RenderSystem.Windows.Metro
{
public class Creator : IRenderSystemCreator
{
#region Public
public string Name
{
get { return "Metro"; }
get
{
return "Metro";
}
}
public int Priority
{
get { return 10; }
get
{
return 10;
}
}
public bool IsSupported
@ -29,38 +37,52 @@ namespace ANX.RenderSystem.Windows.Metro
return OSInformation.GetName() == PlatformName.Windows8;
}
}
#endregion
public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
#region CreateGraphicsDevice
public INativeGraphicsDevice CreateGraphicsDevice(
PresentationParameters presentationParameters)
{
return new GraphicsDeviceWindowsMetro(presentationParameters);
}
#endregion
#region CreateIndexBuffer
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics,
IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage)
IndexBuffer managedBuffer, IndexElementSize size, int indexCount,
BufferUsage usage)
{
return new IndexBuffer_Metro(graphics, size, indexCount, usage);
}
#endregion
#region CreateVertexBuffer
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics,
VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration,
int vertexCount, BufferUsage usage)
{
return new VertexBuffer_Metro(graphics, vertexDeclaration, vertexCount, usage);
}
#endregion
public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
#region CreateEffect
public INativeEffect CreateEffect(GraphicsDevice graphics,
Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{
Effect_Metro effect = new Effect_Metro(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode);
return effect;
return new Effect_Metro(graphics, managedEffect,
vertexShaderByteCode, pixelShaderByteCode);
}
#endregion
public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, System.IO.Stream byteCode)
#region CreateEffect
public INativeEffect CreateEffect(GraphicsDevice graphics,
Effect managedEffect, System.IO.Stream byteCode)
{
Effect_Metro effect = new Effect_Metro(graphics, managedEffect, byteCode);
return effect;
return new Effect_Metro(graphics, managedEffect, byteCode);
}
#endregion
#region CreateTexture (TODO)
public Texture2D CreateTexture(GraphicsDevice graphics, string fileName)
{
//TODO: implement
@ -73,27 +95,45 @@ namespace ANX.RenderSystem.Windows.Metro
//return texture;
}
#endregion
#region CreateTexture
public INativeTexture2D CreateTexture(GraphicsDevice graphics,
SurfaceFormat surfaceFormat, int width, int height, int mipCount)
{
return new Texture2D_Metro(graphics, width, height, surfaceFormat, mipCount);
}
#endregion
#region CreateBlendState
public INativeBlendState CreateBlendState()
{
return new BlendState_Metro();
}
#endregion
#region CreateRasterizerState
public INativeRasterizerState CreateRasterizerState()
{
return new RasterizerState_Metro();
}
#endregion
#region CreateDepthStencilState
public INativeDepthStencilState CreateDepthStencilState()
{
return new DepthStencilState_Metro();
}
#endregion
#region CreateSamplerState
public INativeSamplerState CreateSamplerState()
{
return new SamplerState_Metro();
}
#endregion
#region GetShaderByteCode
public byte[] GetShaderByteCode(PreDefinedShader type)
{
if (type == PreDefinedShader.SpriteBatch)
@ -123,22 +163,25 @@ namespace ANX.RenderSystem.Windows.Metro
throw new NotImplementedException("ByteCode for '" + type.ToString() + "' is not yet available");
}
#endregion
#region RegisterCreator
public void RegisterCreator(AddInSystemFactory factory)
{
factory.AddCreator(this);
}
#endregion
public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
#region GetAdapterList (TODO)
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(new GraphicsAdapter[]
{
new GraphicsAdapter()
{
IsDefaultAdapter = true
}
});
return new ReadOnlyCollection<GraphicsAdapter>(new GraphicsAdapter[]
{
new GraphicsAdapter()
{
IsDefaultAdapter = true
}
});
/*
SharpDX.DXGI.Factory factory = new Factory();
@ -189,15 +232,16 @@ namespace ANX.RenderSystem.Windows.Metro
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(adapterList);*/
}
#endregion
public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount)
#region CreateRenderTarget
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics,
int width, int height, bool mipMap, SurfaceFormat preferredFormat,
DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
{
return new Texture2D_Metro(graphics, width, height, surfaceFormat, mipCount);
}
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
{
return new RenderTarget2D_Metro(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
return new RenderTarget2D_Metro(graphics, width, height, mipMap,
preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
}
#endregion
}
}

View File

@ -8,84 +8,32 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro
{
public class DepthStencilState_Metro : INativeDepthStencilState
public class DepthStencilState_Metro : BaseStateObject, INativeDepthStencilState
{
#region Private Members
#region Private
private Dx11.DepthStencilStateDescription description;
private Dx11.DepthStencilState nativeDepthStencilState;
private bool nativeDepthStencilStateDirty;
private bool bound;
private int referenceStencil;
#endregion
#endregion // Private Members
public DepthStencilState_Metro()
{
this.description = new Dx11.DepthStencilStateDescription();
this.nativeDepthStencilStateDirty = true;
}
public void Apply(ANX.Framework.Graphics.GraphicsDevice graphicsDevice)
{
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
var device = gdMetro.NativeDevice.NativeDevice;
var context = gdMetro.NativeDevice.NativeContext;
UpdateNativeDepthStencilState(device);
this.bound = true;
context.OutputMerger.SetDepthStencilState(nativeDepthStencilState, this.referenceStencil);
}
public void Release()
{
this.bound = false;
}
public void Dispose()
{
if (this.nativeDepthStencilState != null)
{
this.nativeDepthStencilState.Dispose();
this.nativeDepthStencilState = null;
}
}
public bool IsBound
{
get
{
return this.bound;
}
}
public ANX.Framework.Graphics.StencilOperation CounterClockwiseStencilDepthBufferFail
#region Public
public StencilOperation CounterClockwiseStencilDepthBufferFail
{
set
{
Dx11.StencilOperation operation = FormatConverter.Translate(value);
if (description.BackFace.DepthFailOperation != operation)
{
description.BackFace.DepthFailOperation = operation;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.BackFace.DepthFailOperation, ref operation);
}
}
public ANX.Framework.Graphics.StencilOperation CounterClockwiseStencilFail
public StencilOperation CounterClockwiseStencilFail
{
set
{
Dx11.StencilOperation operation = FormatConverter.Translate(value);
if (description.BackFace.FailOperation != operation)
{
description.BackFace.FailOperation = operation;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.BackFace.FailOperation, ref operation);
}
}
@ -94,12 +42,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.Comparison comparison = FormatConverter.Translate(value);
if (description.BackFace.Comparison != comparison)
{
description.BackFace.Comparison = comparison;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.BackFace.Comparison, ref comparison);
}
}
@ -108,12 +52,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.StencilOperation operation = FormatConverter.Translate(value);
if (description.BackFace.PassOperation != operation)
{
description.BackFace.PassOperation = operation;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.BackFace.PassOperation, ref operation);
}
}
@ -124,7 +64,7 @@ namespace ANX.RenderSystem.Windows.Metro
if (description.IsDepthEnabled != value)
{
description.IsDepthEnabled = value;
nativeDepthStencilStateDirty = true;
isDirty = true;
}
}
}
@ -134,12 +74,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.Comparison comparison = FormatConverter.Translate(value);
if (description.DepthComparison != comparison)
{
description.DepthComparison = comparison;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.DepthComparison, ref comparison);
}
}
@ -150,12 +86,8 @@ namespace ANX.RenderSystem.Windows.Metro
Dx11.DepthWriteMask writeMask = value ?
Dx11.DepthWriteMask.All :
Dx11.DepthWriteMask.Zero;
if (description.DepthWriteMask != writeMask)
{
description.DepthWriteMask = writeMask;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.DepthWriteMask, ref writeMask);
}
}
@ -163,11 +95,7 @@ namespace ANX.RenderSystem.Windows.Metro
{
set
{
if (this.referenceStencil != value)
{
this.referenceStencil = value;
this.nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(ref referenceStencil, ref value);
}
}
@ -176,12 +104,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.StencilOperation operation = FormatConverter.Translate(value);
if (description.FrontFace.DepthFailOperation != operation)
{
description.FrontFace.DepthFailOperation = operation;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.FrontFace.DepthFailOperation, ref operation);
}
}
@ -192,36 +116,28 @@ namespace ANX.RenderSystem.Windows.Metro
if (description.IsStencilEnabled != value)
{
description.IsStencilEnabled = value;
nativeDepthStencilStateDirty = true;
isDirty = true;
}
}
}
public ANX.Framework.Graphics.StencilOperation StencilFail
public StencilOperation StencilFail
{
set
{
Dx11.StencilOperation operation = FormatConverter.Translate(value);
if (description.FrontFace.FailOperation != operation)
{
description.FrontFace.FailOperation = operation;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.FrontFace.FailOperation, ref operation);
}
}
public ANX.Framework.Graphics.CompareFunction StencilFunction
public CompareFunction StencilFunction
{
set
{
Dx11.Comparison comparison = FormatConverter.Translate(value);
if (description.FrontFace.Comparison != comparison)
{
description.FrontFace.Comparison = comparison;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.FrontFace.Comparison, ref comparison);
}
}
@ -229,27 +145,20 @@ namespace ANX.RenderSystem.Windows.Metro
{
set
{
byte stencilMask = (byte)value; //TODO: check range
if (description.StencilReadMask != stencilMask)
{
description.StencilReadMask = stencilMask;
nativeDepthStencilStateDirty = true;
}
byte stencilMask = (byte)value;
//TODO: check range
SetValueIfDifferentAndMarkDirty(
ref description.StencilReadMask, ref stencilMask);
}
}
public ANX.Framework.Graphics.StencilOperation StencilPass
public StencilOperation StencilPass
{
set
{
Dx11.StencilOperation operation = FormatConverter.Translate(value);
if (description.FrontFace.PassOperation != operation)
{
description.FrontFace.PassOperation = operation;
nativeDepthStencilStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.FrontFace.PassOperation, ref operation);
}
}
@ -257,13 +166,10 @@ namespace ANX.RenderSystem.Windows.Metro
{
set
{
byte stencilWriteMask = (byte)value; //TODO: check range
if (description.StencilWriteMask != stencilWriteMask)
{
description.StencilWriteMask = stencilWriteMask;
nativeDepthStencilStateDirty = true;
}
byte stencilWriteMask = (byte)value;
//TODO: check range
SetValueIfDifferentAndMarkDirty(
ref description.StencilWriteMask, ref stencilWriteMask);
}
}
@ -274,21 +180,60 @@ namespace ANX.RenderSystem.Windows.Metro
//TODO: check if we really need this. in xna this enables only counter clockwise stencil operations
}
}
#endregion
private void UpdateNativeDepthStencilState(Dx11.Device1 device)
#region Constructor
public DepthStencilState_Metro()
: base()
{
if (this.nativeDepthStencilStateDirty == true || this.nativeDepthStencilState == null)
description = new Dx11.DepthStencilStateDescription();
}
#endregion
#region Apply
public void Apply(GraphicsDevice graphicsDevice)
{
GraphicsDeviceWindowsMetro gdMetro =
graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
var device = gdMetro.NativeDevice.NativeDevice;
var context = gdMetro.NativeDevice.NativeContext;
UpdateNativeDepthStencilState(device);
bound = true;
context.OutputMerger.SetDepthStencilState(
nativeDepthStencilState, referenceStencil);
}
#endregion
#region Dispose
public void Dispose()
{
if (nativeDepthStencilState != null)
{
if (this.nativeDepthStencilState != null)
{
this.nativeDepthStencilState.Dispose();
this.nativeDepthStencilState = null;
}
this.nativeDepthStencilState = new Dx11.DepthStencilState(device, ref this.description);
this.nativeDepthStencilStateDirty = false;
nativeDepthStencilState.Dispose();
nativeDepthStencilState = null;
}
}
#endregion
#region UpdateNativeDepthStencilState
private void UpdateNativeDepthStencilState(Dx11.Device1 device)
{
if (isDirty == true || nativeDepthStencilState == null)
{
if (nativeDepthStencilState != null)
{
nativeDepthStencilState.Dispose();
nativeDepthStencilState = null;
}
nativeDepthStencilState =
new Dx11.DepthStencilState(device, ref description);
isDirty = false;
}
}
#endregion
}
}

View File

@ -13,61 +13,13 @@ namespace ANX.RenderSystem.Windows.Metro
{
public class Effect_Metro : INativeEffect
{
#region Private
private Dx11.VertexShader vertexShader;
private Dx11.PixelShader pixelShader;
private Effect managedEffect;
#endregion
public Effect_Metro(GraphicsDevice device, Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{
if (this.managedEffect == null)
{
throw new ArgumentNullException("managedEffect");
}
this.managedEffect = managedEffect;
if (vertexShaderByteCode.CanSeek)
{
vertexShaderByteCode.Seek(0, SeekOrigin.Begin);
}
int vertexSize = (int)(vertexShaderByteCode.Length - vertexShaderByteCode.Position);
byte[] vertexData = new byte[vertexSize];
vertexShaderByteCode.Read(vertexData, 0, vertexSize);
this.vertexShader = new Dx11.VertexShader((Dx11.Device)device.NativeDevice, vertexData);
if (pixelShaderByteCode.CanSeek)
{
pixelShaderByteCode.Seek(0, SeekOrigin.Begin);
}
int pixelSize = (int)(pixelShaderByteCode.Length - pixelShaderByteCode.Position);
byte[] pixelData = new byte[pixelSize];
pixelShaderByteCode.Read(pixelData, 0, pixelSize);
this.pixelShader = new Dx11.PixelShader((Dx11.Device)device.NativeDevice, pixelData);
}
public Effect_Metro(GraphicsDevice device, Effect managedEffect, Stream effectByteCode)
{
if (managedEffect == null)
{
throw new ArgumentNullException("managedEffect");
}
this.managedEffect = managedEffect;
if (effectByteCode.CanSeek)
{
effectByteCode.Seek(0, SeekOrigin.Begin);
}
// TODO
//this.nativeEffect = new Dx11.Effect(((GraphicsDeviceWindowsDX10)device.NativeDevice).NativeDevice, this.effectByteCode);
}
public void Apply(GraphicsDevice graphicsDevice)
{
//TODO: dummy
((GraphicsDeviceWindowsMetro)graphicsDevice.NativeDevice).currentEffect = this;
}
#region Public
//internal Dx11.Effect NativeEffect
//{
// get
@ -108,28 +60,6 @@ namespace ANX.RenderSystem.Windows.Metro
}
}
public void Dispose()
{
if (this.pixelShader != null)
{
this.pixelShader.Dispose();
this.pixelShader = null;
}
if (this.vertexShader != null)
{
this.vertexShader.Dispose();
this.vertexShader = null;
}
//if (this.nativeEffect != null)
//{
// this.nativeEffect.Dispose();
// this.nativeEffect = null;
//}
}
public IEnumerable<EffectTechnique> Techniques
{
get
@ -170,5 +100,79 @@ namespace ANX.RenderSystem.Windows.Metro
//}
}
}
#endregion
#region Constructor
public Effect_Metro(GraphicsDevice device, Effect managedEffect,
Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{
this.managedEffect = managedEffect;
byte[] vertexData = SeekIfPossibleAndReadBytes(vertexShaderByteCode);
vertexShader = new Dx11.VertexShader((Dx11.Device)device.NativeDevice, vertexData);
byte[] pixelData = SeekIfPossibleAndReadBytes(pixelShaderByteCode);
pixelShader = new Dx11.PixelShader((Dx11.Device)device.NativeDevice, pixelData);
}
public Effect_Metro(GraphicsDevice device, Effect managedEffect, Stream effectByteCode)
{
this.managedEffect = managedEffect;
if (effectByteCode.CanSeek)
{
effectByteCode.Seek(0, SeekOrigin.Begin);
}
// TODO
/*
byte[] vertexData = SeekIfPossibleAndReadBytes(vertexShaderByteCode);
vertexShader = new Dx11.VertexShader((Dx11.Device)device.NativeDevice, vertexData);
byte[] pixelData = SeekIfPossibleAndReadBytes(pixelShaderByteCode);
pixelShader = new Dx11.PixelShader((Dx11.Device)device.NativeDevice, pixelData);
*/
}
#endregion
#region SeekIfPossibleAndReadBytes
private byte[] SeekIfPossibleAndReadBytes(Stream stream)
{
if (stream.CanSeek)
{
stream.Seek(0, SeekOrigin.Begin);
}
int pixelSize = (int)(stream.Length - stream.Position);
byte[] data = new byte[pixelSize];
stream.Read(data, 0, pixelSize);
return data;
}
#endregion
#region Apply
public void Apply(GraphicsDevice graphicsDevice)
{
//TODO: dummy
((GraphicsDeviceWindowsMetro)graphicsDevice.NativeDevice).currentEffect = this;
}
#endregion
#region Dispose
public void Dispose()
{
if (pixelShader != null)
{
pixelShader.Dispose();
pixelShader = null;
}
if (vertexShader != null)
{
vertexShader.Dispose();
vertexShader = null;
}
}
#endregion
}
}

View File

@ -1,9 +1,7 @@
using System;
using System.Runtime.InteropServices;
using ANX.Framework;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using ANX.PlatformSystem.Metro;
using SharpDX.DXGI;
using Dx11 = SharpDX.Direct3D11;
@ -237,6 +235,7 @@ namespace ANX.RenderSystem.Windows.Metro
NativeDevice.NativeContext.InputAssembler.InputLayout = layout;
}*/
#region CalculateVertexCount
private int CalculateVertexCount(PrimitiveType type, int primitiveCount)
{
if (type == PrimitiveType.TriangleList)
@ -260,7 +259,9 @@ namespace ANX.RenderSystem.Windows.Metro
throw new NotImplementedException("couldn't calculate vertex count for PrimitiveType '" + type.ToString() + "'");
}
}
#endregion
#region SetIndexBuffer
public void SetIndexBuffer(IndexBuffer indexBuffer)
{
if (indexBuffer == null)
@ -281,7 +282,9 @@ namespace ANX.RenderSystem.Windows.Metro
throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
}
}
#endregion
#region SetVertexBuffers
public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers)
{
if (vertexBuffers == null)
@ -309,11 +312,16 @@ namespace ANX.RenderSystem.Windows.Metro
NativeDevice.NativeContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
}
#endregion
#region SetViewport
public void SetViewport(Viewport viewport)
{
this.currentViewport = new Dx11.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth);
this.currentViewport = new Dx11.Viewport(viewport.X, viewport.Y,
viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth);
}
#endregion
/*
/// <summary>
/// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives. The VertexDeclaration of ANX/XNA needs to be mapped
@ -344,6 +352,7 @@ namespace ANX.RenderSystem.Windows.Metro
return new Dx11.InputLayout(device, data, inputElements);
}*/
#region CreateInputElementFromVertexElement
private Dx11.InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
{
string elementName = FormatConverter.Translate(vertexElement.VertexElementUsage);
@ -369,7 +378,9 @@ namespace ANX.RenderSystem.Windows.Metro
return new Dx11.InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
}
#endregion
#region SetRenderTargets (TODO)
public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{
/*if (renderTargets == null)
@ -410,7 +421,9 @@ namespace ANX.RenderSystem.Windows.Metro
}
}*/
}
#endregion
#region GetBackBufferData (TODO)
public void GetBackBufferData<T>(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{
throw new NotImplementedException();
@ -425,13 +438,17 @@ namespace ANX.RenderSystem.Windows.Metro
{
throw new NotImplementedException();
}
#endregion
#region ResizeBuffers
public void ResizeBuffers(PresentationParameters presentationParameters)
{
NativeDevice.Resize(presentationParameters);
ResizeRenderWindow(presentationParameters);
}
#endregion
#region ResizeRenderWindow (TODO)
private void ResizeRenderWindow(PresentationParameters presentationParameters)
{
// TODO
@ -441,6 +458,7 @@ namespace ANX.RenderSystem.Windows.Metro
//gameWindow.Form.Bounds
//}
}
#endregion
#region Dispose
public void Dispose()

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.RenderSystem;
@ -12,50 +13,75 @@ namespace ANX.RenderSystem.Windows.Metro
{
public class IndexBuffer_Metro : INativeIndexBuffer, IDisposable
{
#region Private
private Dx11.Buffer buffer;
private IndexElementSize size;
private int indexSizeInBytes;
#endregion
public IndexBuffer_Metro(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
#region Public
public Dx11.Buffer NativeBuffer
{
get
{
return this.buffer;
}
}
#endregion
#region Constructor
public IndexBuffer_Metro(GraphicsDevice graphics, IndexElementSize size,
int indexCount, BufferUsage usage)
{
this.size = size;
indexSizeInBytes = size == IndexElementSize.SixteenBits ? 2 : 4;
//TODO: translate and use usage
GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro;
GraphicsDeviceWindowsMetro gdMetro =
graphics.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = gdMetro.NativeDevice.NativeDevice;
InitializeBuffer(device, size, indexCount, usage);
InitializeBuffer(device, indexCount, usage);
}
internal IndexBuffer_Metro(Dx11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
internal IndexBuffer_Metro(Dx11.Device device, IndexElementSize size,
int indexCount, BufferUsage usage)
{
this.size = size;
InitializeBuffer(device, size, indexCount, usage);
InitializeBuffer(device, indexCount, usage);
}
#endregion
private void InitializeBuffer(Dx11.Device device, IndexElementSize size, int indexCount, BufferUsage usage)
#region InitializeBuffer
private void InitializeBuffer(Dx11.Device device,
int indexCount, BufferUsage usage)
{
var description = new Dx11.BufferDescription()
{
Usage = Dx11.ResourceUsage.Dynamic,
SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
BindFlags = Dx11.BindFlags.IndexBuffer,
CpuAccessFlags = Dx11.CpuAccessFlags.Write,
OptionFlags = Dx11.ResourceOptionFlags.None
};
{
Usage = Dx11.ResourceUsage.Dynamic,
SizeInBytes = indexSizeInBytes * indexCount,
BindFlags = Dx11.BindFlags.IndexBuffer,
CpuAccessFlags = Dx11.CpuAccessFlags.Write,
OptionFlags = Dx11.ResourceOptionFlags.None
};
this.buffer = new Dx11.Buffer(device, description);
}
#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
{
GraphicsDeviceWindowsMetro metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
GraphicsDeviceWindowsMetro metroGraphicsDevice =
graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = metroGraphicsDevice.NativeDevice.NativeDevice;
Dx11.DeviceContext1 context = metroGraphicsDevice.NativeDevice.NativeContext;
@ -72,11 +98,12 @@ namespace ANX.RenderSystem.Windows.Metro
{
if (offsetInBytes > 0)
{
vData.Seek(offsetInBytes / (size == IndexElementSize.SixteenBits ? 2 : 4), System.IO.SeekOrigin.Begin);
vData.Seek(offsetInBytes / indexSizeInBytes, SeekOrigin.Begin);
}
SharpDX.DataStream stream;
SharpDX.DataBox box = context.MapSubresource(this.buffer, Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream);
SharpDX.DataBox box = context.MapSubresource(this.buffer,
Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream);
if (startIndex > 0 || elementCount < data.Length)
{
for (int i = startIndex; i < startIndex + elementCount; i++)
@ -95,50 +122,41 @@ namespace ANX.RenderSystem.Windows.Metro
pinnedArray.Free();
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,
int startIndex, int elementCount) where T : struct
{
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
}
public Dx11.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
#endregion
#region GetData (TODO)
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
public void GetData<T>(T[] data, int startIndex, int elementCount)
where T : struct
{
throw new NotImplementedException();
}
#endregion
#region Dispose
public void Dispose()
{
if (buffer != null)
{
buffer.Dispose();
buffer = null;
}
}
#endregion
}
}

View File

@ -9,7 +9,7 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro
{
public class RasterizerState_Metro : INativeRasterizerState
public class RasterizerState_Metro : BaseStateObject, INativeRasterizerState
{
#region Constants
private const int intMaxOver16 = int.MaxValue / 16;
@ -18,19 +18,9 @@ namespace ANX.RenderSystem.Windows.Metro
#region Private
private Dx11.RasterizerDescription1 description;
private Dx11.RasterizerState1 nativeRasterizerState;
private bool nativeRasterizerStateDirty;
private bool bound;
#endregion
#region Public
public bool IsBound
{
get
{
return bound;
}
}
public CullMode CullMode
{
set
@ -67,7 +57,7 @@ namespace ANX.RenderSystem.Windows.Metro
{
if (description.MultisampleEnable != value)
{
nativeRasterizerStateDirty = true;
isDirty = true;
description.MultisampleEnable = value;
}
}
@ -79,7 +69,7 @@ namespace ANX.RenderSystem.Windows.Metro
{
if (description.ScissorEnable != value)
{
nativeRasterizerStateDirty = true;
isDirty = true;
description.ScissorEnable = value;
}
}
@ -100,7 +90,7 @@ namespace ANX.RenderSystem.Windows.Metro
description = new Dx11.RasterizerDescription1();
description.AntialiasedLineEnable = false;
nativeRasterizerStateDirty = true;
isDirty = true;
}
#endregion
@ -118,13 +108,6 @@ namespace ANX.RenderSystem.Windows.Metro
}
#endregion
#region Release
public void Release()
{
bound = false;
}
#endregion
#region Dispose
public void Dispose()
{
@ -139,15 +122,16 @@ namespace ANX.RenderSystem.Windows.Metro
#region UpdateNativeRasterizerState
private void UpdateNativeRasterizerState(Dx11.Device1 device)
{
if (nativeRasterizerStateDirty == true ||
if (isDirty == true ||
nativeRasterizerState == null)
{
Dispose();
try
{
nativeRasterizerState = new Dx11.RasterizerState1(device, description);
nativeRasterizerStateDirty = false;
nativeRasterizerState =
new Dx11.RasterizerState1(device, description);
isDirty = false;
}
catch
{
@ -155,16 +139,5 @@ namespace ANX.RenderSystem.Windows.Metro
}
}
#endregion
#region SetValueIfDifferentAndMarkDirty
private void SetValueIfDifferentAndMarkDirty<T>(ref T oldValue, ref T newValue)
{
if (oldValue.Equals(newValue) == false)
{
nativeRasterizerStateDirty = true;
oldValue = newValue;
}
}
#endregion
}
}

View File

@ -11,11 +11,10 @@ namespace ANX.RenderSystem.Windows.Metro
{
public class RenderTarget2D_Metro : Texture2D_Metro, INativeRenderTarget2D, INativeTexture2D
{
#region Private Members
#endregion // Private Members
public RenderTarget2D_Metro(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
#region Constructor
public RenderTarget2D_Metro(GraphicsDevice graphics, int width, int height,
bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat,
int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphics)
{
if (mipMap)
@ -25,7 +24,7 @@ namespace ANX.RenderSystem.Windows.Metro
this.surfaceFormat = surfaceFormat;
GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
var graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = graphicsMetro.NativeDevice.NativeDevice;
var description = new Dx11.Texture2DDescription()
@ -49,6 +48,6 @@ namespace ANX.RenderSystem.Windows.Metro
this.formatSize = FormatConverter.FormatSize(surfaceFormat);
}
#endregion
}
}

View File

@ -9,60 +9,21 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro
{
public class SamplerState_Metro : INativeSamplerState
public class SamplerState_Metro : BaseStateObject, INativeSamplerState
{
#region Private Members
#region Private
private Dx11.SamplerStateDescription description;
private Dx11.SamplerState nativeSamplerState;
private bool nativeSamplerStateDirty;
private bool bound;
#endregion // Private Members
public SamplerState_Metro()
{
this.description = new Dx11.SamplerStateDescription();
this.nativeSamplerStateDirty = true;
}
public void Apply(GraphicsDevice graphicsDevice, int index)
{
throw new NotImplementedException();
//GraphicsDeviceWindowsMetro gdm = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
//Device device = gdm.NativeDevice;
//UpdateNativeSamplerState(device);
//this.bound = true;
//device.PixelShader.SetSampler(index, this.nativeSamplerState);
}
public void Release()
{
this.bound = false;
}
public bool IsBound
{
get
{
return this.bound;
}
}
#endregion
#region Public
public TextureAddressMode AddressU
{
set
{
Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
if (description.AddressU != mode)
{
description.AddressU = mode;
nativeSamplerStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.AddressU, ref mode);
}
}
@ -71,12 +32,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
if (description.AddressV != mode)
{
description.AddressV = mode;
nativeSamplerStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.AddressV, ref mode);
}
}
@ -85,12 +42,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
if (description.AddressW != mode)
{
description.AddressW = mode;
nativeSamplerStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.AddressW, ref mode);
}
}
@ -99,12 +52,8 @@ namespace ANX.RenderSystem.Windows.Metro
set
{
Dx11.Filter filter = FormatConverter.Translate(value);
if (description.Filter != filter)
{
description.Filter = filter;
nativeSamplerStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.Filter, ref filter);
}
}
@ -112,11 +61,8 @@ namespace ANX.RenderSystem.Windows.Metro
{
set
{
if (description.MaximumAnisotropy != value)
{
description.MaximumAnisotropy = value;
nativeSamplerStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.MaximumAnisotropy, ref value);
}
}
@ -127,7 +73,7 @@ namespace ANX.RenderSystem.Windows.Metro
if (description.MaximumLod != value)
{
description.MaximumLod = value;
nativeSamplerStateDirty = true;
isDirty = true;
}
}
}
@ -136,37 +82,62 @@ namespace ANX.RenderSystem.Windows.Metro
{
set
{
if (description.MipLodBias != value)
{
description.MipLodBias = value;
nativeSamplerStateDirty = true;
}
SetValueIfDifferentAndMarkDirty(
ref description.MipLodBias, ref value);
}
}
#endregion
#region Constructor
public SamplerState_Metro()
: base()
{
description = new Dx11.SamplerStateDescription();
}
#endregion
#region Apply (TODO)
public void Apply(GraphicsDevice graphicsDevice, int index)
{
var gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = gdMetro.NativeDevice.NativeDevice;
UpdateNativeSamplerState(device);
bound = true;
throw new NotImplementedException();
//device.PixelShader.SetSampler(index, this.nativeSamplerState);
}
#endregion
#region Dispose
public void Dispose()
{
if (this.nativeSamplerState != null)
if (nativeSamplerState != null)
{
this.nativeSamplerState.Dispose();
this.nativeSamplerState = null;
nativeSamplerState.Dispose();
nativeSamplerState = null;
}
}
#endregion
#region UpdateNativeSamplerState
private void UpdateNativeSamplerState(Dx11.Device1 device)
{
if (this.nativeSamplerStateDirty == true || this.nativeSamplerState == null)
if (isDirty == true || nativeSamplerState == null)
{
if (this.nativeSamplerState != null)
if (nativeSamplerState != null)
{
this.nativeSamplerState.Dispose();
this.nativeSamplerState = null;
nativeSamplerState.Dispose();
nativeSamplerState = null;
}
this.nativeSamplerState = new Dx11.SamplerState(device, ref this.description);
nativeSamplerState =
new Dx11.SamplerState(device, ref description);
this.nativeSamplerStateDirty = false;
isDirty = false;
}
}
#endregion
}
}

View File

@ -3,7 +3,6 @@ using ANX.PlatformSystem.Metro;
using SharpDX;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using Windows.UI.Core;
using PresentationParameters = ANX.Framework.Graphics.PresentationParameters;
// This file is part of the ANX.Framework created by the

View File

@ -14,21 +14,92 @@ namespace ANX.RenderSystem.Windows.Metro
{
public class Texture2D_Metro : INativeTexture2D
{
#region Private Members
#region Private
protected internal Dx11.Texture2D nativeTexture;
protected internal Dx11.ShaderResourceView nativeShaderResourceView;
protected internal int formatSize;
protected internal SurfaceFormat surfaceFormat;
protected internal GraphicsDevice graphicsDevice;
#endregion
#endregion // Private Members
#region Public
internal Dx11.Texture2D NativeTexture
{
get
{
return nativeTexture;
}
set
{
if (nativeTexture != value)
{
if (nativeTexture != null)
{
nativeTexture.Dispose();
}
nativeTexture = value;
}
}
}
internal Dx11.ShaderResourceView NativeShaderResourceView
{
get
{
return this.nativeShaderResourceView;
}
set
{
if (nativeShaderResourceView != value)
{
if (nativeShaderResourceView != null)
{
nativeShaderResourceView.Dispose();
}
nativeShaderResourceView = value;
}
}
}
public int Width
{
get
{
return nativeTexture != null ?
nativeTexture.Description.Width :
0;
}
}
public int Height
{
get
{
return nativeTexture != null ?
nativeTexture.Description.Height :
0;
}
}
public GraphicsDevice GraphicsDevice
{
get
{
return graphicsDevice;
}
}
#endregion
#region Constructor
internal Texture2D_Metro(GraphicsDevice graphicsDevice)
{
this.graphicsDevice = graphicsDevice;
}
public Texture2D_Metro(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount)
public Texture2D_Metro(GraphicsDevice graphicsDevice, int width, int height,
SurfaceFormat surfaceFormat, int mipCount)
{
if (mipCount > 1)
{
@ -41,7 +112,7 @@ namespace ANX.RenderSystem.Windows.Metro
GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = graphicsMetro.NativeDevice.NativeDevice;
Dx11.Texture2DDescription description = new Dx11.Texture2DDescription()
var description = new Dx11.Texture2DDescription()
{
Width = width,
Height = height,
@ -62,69 +133,42 @@ namespace ANX.RenderSystem.Windows.Metro
this.formatSize = FormatConverter.FormatSize(surfaceFormat);
}
#endregion
#region GetHashCode
public override int GetHashCode()
{
return NativeTexture.NativePointer.ToInt32();
}
#endregion
internal Dx11.Texture2D NativeTexture
#region SetData
public void SetData<T>(int level, Rectangle? rect, T[] data,
int startIndex, int elementCount) where T : struct
{
get
{
return this.nativeTexture;
}
set
{
if (this.nativeTexture != value)
{
if (this.nativeTexture != null)
{
this.nativeTexture.Dispose();
}
this.nativeTexture = value;
}
}
throw new NotImplementedException();
}
internal Dx11.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
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
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
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
GraphicsDeviceWindowsMetro metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
var metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = metroGraphicsDevice.NativeDevice.NativeDevice;
Dx11.DeviceContext1 context = metroGraphicsDevice.NativeDevice.NativeContext;
@ -216,55 +260,24 @@ namespace ANX.RenderSystem.Windows.Metro
throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString()));
}
}
#endregion
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;
}
}
#region Dispose
public void Dispose()
{
if (this.nativeShaderResourceView != null)
if (nativeShaderResourceView != null)
{
this.nativeShaderResourceView.Dispose();
this.nativeShaderResourceView = null;
nativeShaderResourceView.Dispose();
nativeShaderResourceView = null;
}
if (this.nativeTexture != null)
if (nativeTexture != null)
{
this.nativeTexture.Dispose();
this.nativeTexture = null;
nativeTexture.Dispose();
nativeTexture = null;
}
}
#endregion
#region SaveAsJpeg (TODO)
public void SaveAsJpeg(Stream stream, int width, int height)
@ -280,34 +293,23 @@ namespace ANX.RenderSystem.Windows.Metro
}
#endregion
#region INativeTexture2D Member
public void GetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
#region GetData (TODO)
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
public void GetData<T>(T[] data, int startIndex, int elementCount)
where T : struct
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.RenderSystem;
@ -12,47 +13,69 @@ namespace ANX.RenderSystem.Windows.Metro
{
public class VertexBuffer_Metro : INativeVertexBuffer, IDisposable
{
Dx11.Buffer buffer;
int vertexStride;
#region Private
private Dx11.Buffer buffer;
private int vertexStride;
#endregion
public VertexBuffer_Metro(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
#region Public
public Dx11.Buffer NativeBuffer
{
GraphicsDeviceWindowsMetro gdMetro = graphics.NativeDevice as GraphicsDeviceWindowsMetro;
get
{
return this.buffer;
}
}
#endregion
#region Constructor
public VertexBuffer_Metro(GraphicsDevice graphics,
VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{
GraphicsDeviceWindowsMetro gdMetro =
graphics.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = gdMetro.NativeDevice.NativeDevice;
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
vertexStride = vertexDeclaration.VertexStride;
InitializeBuffer(device, vertexCount, usage);
}
internal VertexBuffer_Metro(Dx11.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
internal VertexBuffer_Metro(Dx11.Device device,
VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{
InitializeBuffer(device, vertexDeclaration, vertexCount, usage);
vertexStride = vertexDeclaration.VertexStride;
InitializeBuffer(device, vertexCount, usage);
}
#endregion
private void InitializeBuffer(Dx11.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
#region InitializeBuffer
private void InitializeBuffer(Dx11.Device device, int vertexCount,
BufferUsage usage)
{
this.vertexStride = vertexDeclaration.VertexStride;
//TODO: translate and use usage
if (device != null)
{
var description = new Dx11.BufferDescription()
{
Usage = Dx11.ResourceUsage.Dynamic,
SizeInBytes = vertexDeclaration.VertexStride * vertexCount,
BindFlags = Dx11.BindFlags.VertexBuffer,
CpuAccessFlags = Dx11.CpuAccessFlags.Write,
OptionFlags = Dx11.ResourceOptionFlags.None
};
{
Usage = Dx11.ResourceUsage.Dynamic,
SizeInBytes = vertexStride * vertexCount,
BindFlags = Dx11.BindFlags.VertexBuffer,
CpuAccessFlags = Dx11.CpuAccessFlags.Write,
OptionFlags = Dx11.ResourceOptionFlags.None
};
this.buffer = new Dx11.Buffer(device, description);
buffer = new Dx11.Buffer(device, description);
}
}
#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
{
GraphicsDeviceWindowsMetro gdMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = gdMetro.NativeDevice.NativeDevice;
GraphicsDeviceWindowsMetro gdMetro =
graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.DeviceContext1 context = gdMetro.NativeDevice.NativeContext;
//TODO: check offsetInBytes parameter for bounds etc.
@ -68,11 +91,12 @@ namespace ANX.RenderSystem.Windows.Metro
{
if (offsetInBytes > 0)
{
vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin);
vData.Seek(offsetInBytes / vertexStride, SeekOrigin.Begin);
}
SharpDX.DataStream stream;
SharpDX.DataBox box = context.MapSubresource(this.buffer, Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream);
SharpDX.DataBox box = context.MapSubresource(buffer,
Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream);
if (startIndex > 0 || elementCount < data.Length)
{
for (int i = startIndex; i < startIndex + elementCount; i++)
@ -84,67 +108,61 @@ namespace ANX.RenderSystem.Windows.Metro
{
vData.CopyTo(stream);
}
context.UnmapSubresource(this.buffer, 0);
context.UnmapSubresource(buffer, 0);
}
}
pinnedArray.Free();
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data)
where T : struct
{
SetData<T>(graphicsDevice, data, 0, data.Length);
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,
int startIndex, int elementCount) where T : struct
{
SetData<T>(graphicsDevice, 0, data, startIndex, elementCount);
}
public Dx11.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 (TODO)
public void GetData<T>(int offsetInBytes, T[] data, int startIndex,
int elementCount, int vertexStride) where T : struct
{
throw new NotImplementedException();
}
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
public void GetData<T>(T[] data, int startIndex, int elementCount)
where T : struct
{
throw new NotImplementedException();
}
#endregion
#region Dispose
public void Dispose()
{
if (buffer != null)
{
buffer.Dispose();
buffer = null;
}
}
#endregion
}
}

View File

@ -113,10 +113,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -118,10 +118,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -113,10 +113,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -113,10 +113,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -114,10 +114,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -115,10 +115,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -115,10 +115,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -94,10 +94,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -123,10 +123,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -115,10 +115,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -114,10 +114,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -85,10 +85,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -151,10 +151,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -125,10 +125,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -89,10 +89,10 @@
<AppxManifest Include="Manifest.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<Content Include="Assets/Logo.png" />
<Content Include="Assets/SmallLogo.png" />
<Content Include="Assets/SplashScreen.png" />
<Content Include="Assets/StoreLogo.png" />
<Content Include="Assets\Logo.png" />
<Content Include="Assets\SmallLogo.png" />
<Content Include="Assets\SplashScreen.png" />
<Content Include="Assets\StoreLogo.png" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '11.0' ">
<VisualStudioVersion>11.0</VisualStudioVersion>

View File

@ -2,6 +2,10 @@
using System.Collections.Generic;
using System.Reflection;
// 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 ProjectConverter
{
public static class DefinesConverter

View File

@ -2,6 +2,10 @@
using System.IO;
using System.Xml.Linq;
// 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 ProjectConverter.Platforms
{
public class LinuxConverter : Converter

View File

@ -2,6 +2,10 @@
using System.IO;
using System.Xml.Linq;
// 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 ProjectConverter.Platforms.Metro
{
public class AppxManifest

View File

@ -1,6 +1,10 @@
using System;
using System.Xml.Linq;
using System.IO;
using System.Xml.Linq;
// 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 ProjectConverter.Platforms.Metro
{
@ -35,7 +39,7 @@ namespace ProjectConverter.Platforms.Metro
File.Copy(assetFilepath, targetAssetFilepath, true);
XElement newContentNode = new XElement(contentNodeName);
newContentNode.Add(new XAttribute("Include", "Assets/" + filename));
newContentNode.Add(new XAttribute("Include", "Assets\\" + filename));
itemGroup.Add(newContentNode);
}
}

View File

@ -5,6 +5,10 @@ using System.Linq;
using System.Xml.Linq;
using ProjectConverter.Platforms.Metro;
// 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 ProjectConverter.Platforms
{
public class MetroConverter : Converter

View File

@ -1,6 +1,10 @@
using System;
using System.Xml.Linq;
// 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 ProjectConverter.Platforms
{
public class PsVitaConverter : Converter