- 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 #region LoadStreamFromMetroAssets
#if WINDOWSMETRO #if WINDOWSMETRO
private async void LoadStreamFromMetroAssets() private void LoadStreamFromMetroAssets()
{ {
var library = Windows.ApplicationModel.Package.Current.InstalledLocation; 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(); assemblyListStream.Position = 0;
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;
} }
#endif #endif
#endregion #endregion

View File

@ -1,14 +1,12 @@
#region Using Statements #if WINDOWSMETRO
using System; using System;
using System.Collections; using System.Collections;
using System.Threading.Tasks;
#endregion
// This file is part of the ANX.Framework created by the // This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license. // "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license // For details see: http://anxframework.codeplex.com/license
#if WINDOWSMETRO
namespace ANX.Framework namespace ANX.Framework
{ {
public struct DictionaryEntry public struct DictionaryEntry
@ -34,5 +32,14 @@ namespace ANX.Framework
set { this.value = value; } set { this.value = value; }
} }
} }
public static class TaskHelper
{
public static T WaitForAsyncOperation<T>(Task<T> task)
{
task.Wait();
return task.Result;
}
}
} }
#endif #endif

View File

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

View File

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

View File

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

View File

@ -38,6 +38,9 @@
<ItemGroup> <ItemGroup>
<Compile Include="MetroContentManager.cs" /> <Compile Include="MetroContentManager.cs" />
<Compile Include="MetroGameTimer.cs" /> <Compile Include="MetroGameTimer.cs" />
<Compile Include="MetroStorageContainer.cs" />
<Compile Include="MetroStorageDevice.cs" />
<Compile Include="MetroTitleContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MetroPlatformCreator.cs" /> <Compile Include="MetroPlatformCreator.cs" />
<Compile Include="SupportedPlatformsImpl.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 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 namespace ANX.PlatformSystem.Metro
{ {
public class MetroContentManager : INativeContentManager 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) public string MakeRootDirectoryAbsolute(string relativePath)
{ {
return relativePath; return Path.Combine("Assets", relativePath);
} }
#endregion
#region OpenStream
public Stream OpenStream(string filepath) 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; return null;
} }
#endregion
} }
} }

View File

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

View File

@ -62,25 +62,25 @@ namespace ANX.PlatformSystem.Metro
} }
#endregion #endregion
#region CreateStorageDevice (TODO) #region CreateStorageDevice
public INativeStorageDevice CreateStorageDevice(StorageDevice device, public INativeStorageDevice CreateStorageDevice(StorageDevice device,
PlayerIndex player, int sizeInBytes, int directoryCount) PlayerIndex player, int sizeInBytes, int directoryCount)
{ {
throw new NotImplementedException(); return new MetroStorageDevice();
} }
#endregion #endregion
#region CreateStorageContainer (TODO) #region CreateStorageContainer
public INativeStorageContainer CreateStorageContainer(StorageContainer container) public INativeStorageContainer CreateStorageContainer(StorageContainer container)
{ {
throw new NotImplementedException(); return new MetroStorageContainer();
} }
#endregion #endregion
#region CreateTitleContainer (TODO) #region CreateTitleContainer
public INativeTitleContainer CreateTitleContainer() public INativeTitleContainer CreateTitleContainer()
{ {
throw new NotImplementedException(); return new MetroTitleContainer();
} }
#endregion #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 /> <StartupObject />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseStateObject.cs" />
<Compile Include="NativeDxDevice.cs" /> <Compile Include="NativeDxDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>

View File

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

View File

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

View File

@ -38,6 +38,7 @@
<StartupObject /> <StartupObject />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BaseStateObject.cs" />
<Compile Include="NativeDxDevice.cs" /> <Compile Include="NativeDxDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </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 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.BlendStateDescription blendStateDescription;
private Dx11.BlendState nativeBlendState; private Dx11.BlendState nativeBlendState;
private bool nativeBlendStateDirty;
private SharpDX.Color4 blendFactor; private SharpDX.Color4 blendFactor;
private int multiSampleMask; private int multiSampleMask;
private bool bound; #endregion
#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;
}
}
#region Public
public Color BlendFactor public Color BlendFactor
{ {
set set
@ -97,12 +48,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{ {
if (blendStateDescription.RenderTarget[i].AlphaBlendOperation != alphaBlendOperation) SetValueIfDifferentAndMarkDirty(
{ ref blendStateDescription.RenderTarget[i].AlphaBlendOperation,
nativeBlendStateDirty = true; ref alphaBlendOperation);
blendStateDescription.RenderTarget[i].AlphaBlendOperation = alphaBlendOperation;
}
} }
} }
} }
@ -115,12 +63,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{ {
if (blendStateDescription.RenderTarget[i].BlendOperation != blendOperation) SetValueIfDifferentAndMarkDirty(
{ ref blendStateDescription.RenderTarget[i].BlendOperation,
nativeBlendStateDirty = true; ref blendOperation);
blendStateDescription.RenderTarget[i].BlendOperation = blendOperation;
}
} }
} }
} }
@ -133,12 +78,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{ {
if (blendStateDescription.RenderTarget[i].DestinationAlphaBlend != destinationAlphaBlend) SetValueIfDifferentAndMarkDirty(
{ ref blendStateDescription.RenderTarget[i].DestinationAlphaBlend,
nativeBlendStateDirty = true; ref destinationAlphaBlend);
blendStateDescription.RenderTarget[i].DestinationAlphaBlend = destinationAlphaBlend;
}
} }
} }
} }
@ -151,12 +93,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{ {
if (blendStateDescription.RenderTarget[i].DestinationBlend != destinationBlend) SetValueIfDifferentAndMarkDirty(
{ ref blendStateDescription.RenderTarget[i].DestinationBlend,
nativeBlendStateDirty = true; ref destinationBlend);
blendStateDescription.RenderTarget[i].DestinationBlend = destinationBlend;
}
} }
} }
} }
@ -166,14 +105,10 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check //TODO: range check
SetValueIfDifferentAndMarkDirty(
if (blendStateDescription.RenderTarget[0].RenderTargetWriteMask != renderTargetWriteMask) ref blendStateDescription.RenderTarget[0].RenderTargetWriteMask,
{ ref renderTargetWriteMask);
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[0].RenderTargetWriteMask = renderTargetWriteMask;
}
} }
} }
@ -182,14 +117,10 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check //TODO: range check
SetValueIfDifferentAndMarkDirty(
if (blendStateDescription.RenderTarget[1].RenderTargetWriteMask != renderTargetWriteMask) ref blendStateDescription.RenderTarget[1].RenderTargetWriteMask,
{ ref renderTargetWriteMask);
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[1].RenderTargetWriteMask = renderTargetWriteMask;
}
} }
} }
@ -198,14 +129,10 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check //TODO: range check
SetValueIfDifferentAndMarkDirty(
if (blendStateDescription.RenderTarget[2].RenderTargetWriteMask != renderTargetWriteMask) ref blendStateDescription.RenderTarget[2].RenderTargetWriteMask,
{ ref renderTargetWriteMask);
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[2].RenderTargetWriteMask = renderTargetWriteMask;
}
} }
} }
@ -214,14 +141,10 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value); Dx11.ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
//TODO: range check //TODO: range check
SetValueIfDifferentAndMarkDirty(
if (blendStateDescription.RenderTarget[3].RenderTargetWriteMask != renderTargetWriteMask) ref blendStateDescription.RenderTarget[3].RenderTargetWriteMask,
{ ref renderTargetWriteMask);
nativeBlendStateDirty = true;
blendStateDescription.RenderTarget[3].RenderTargetWriteMask = renderTargetWriteMask;
}
} }
} }
@ -233,12 +156,9 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{ {
if (blendStateDescription.RenderTarget[i].SourceAlphaBlend != sourceAlphaBlend) SetValueIfDifferentAndMarkDirty(
{ ref blendStateDescription.RenderTarget[i].SourceAlphaBlend,
nativeBlendStateDirty = true; ref sourceAlphaBlend);
blendStateDescription.RenderTarget[i].SourceAlphaBlend = sourceAlphaBlend;
}
} }
} }
} }
@ -251,30 +171,71 @@ namespace ANX.RenderSystem.Windows.Metro
for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++) for (int i = 0; i < blendStateDescription.RenderTarget.Length; i++)
{ {
if (blendStateDescription.RenderTarget[i].SourceBlend != sourceBlend) SetValueIfDifferentAndMarkDirty(
{ ref blendStateDescription.RenderTarget[i].SourceBlend,
nativeBlendStateDirty = true; ref sourceBlend);
blendStateDescription.RenderTarget[i].SourceBlend = 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) 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(); nativeBlendState.Dispose();
this.nativeBlendState = null; 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;
using System.Collections.ObjectModel;
using System.IO; using System.IO;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
@ -12,14 +13,21 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
public class Creator : IRenderSystemCreator public class Creator : IRenderSystemCreator
{ {
#region Public
public string Name public string Name
{ {
get { return "Metro"; } get
{
return "Metro";
}
} }
public int Priority public int Priority
{ {
get { return 10; } get
{
return 10;
}
} }
public bool IsSupported public bool IsSupported
@ -29,38 +37,52 @@ namespace ANX.RenderSystem.Windows.Metro
return OSInformation.GetName() == PlatformName.Windows8; return OSInformation.GetName() == PlatformName.Windows8;
} }
} }
#endregion
public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters) #region CreateGraphicsDevice
public INativeGraphicsDevice CreateGraphicsDevice(
PresentationParameters presentationParameters)
{ {
return new GraphicsDeviceWindowsMetro(presentationParameters); return new GraphicsDeviceWindowsMetro(presentationParameters);
} }
#endregion
#region CreateIndexBuffer
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, 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); return new IndexBuffer_Metro(graphics, size, indexCount, usage);
} }
#endregion
#region CreateVertexBuffer
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, 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); 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 new Effect_Metro(graphics, managedEffect,
vertexShaderByteCode, pixelShaderByteCode);
return effect;
} }
#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 new Effect_Metro(graphics, managedEffect, byteCode);
return effect;
} }
#endregion
#region CreateTexture (TODO)
public Texture2D CreateTexture(GraphicsDevice graphics, string fileName) public Texture2D CreateTexture(GraphicsDevice graphics, string fileName)
{ {
//TODO: implement //TODO: implement
@ -73,27 +95,45 @@ namespace ANX.RenderSystem.Windows.Metro
//return texture; //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() public INativeBlendState CreateBlendState()
{ {
return new BlendState_Metro(); return new BlendState_Metro();
} }
#endregion
#region CreateRasterizerState
public INativeRasterizerState CreateRasterizerState() public INativeRasterizerState CreateRasterizerState()
{ {
return new RasterizerState_Metro(); return new RasterizerState_Metro();
} }
#endregion
#region CreateDepthStencilState
public INativeDepthStencilState CreateDepthStencilState() public INativeDepthStencilState CreateDepthStencilState()
{ {
return new DepthStencilState_Metro(); return new DepthStencilState_Metro();
} }
#endregion
#region CreateSamplerState
public INativeSamplerState CreateSamplerState() public INativeSamplerState CreateSamplerState()
{ {
return new SamplerState_Metro(); return new SamplerState_Metro();
} }
#endregion
#region GetShaderByteCode
public byte[] GetShaderByteCode(PreDefinedShader type) public byte[] GetShaderByteCode(PreDefinedShader type)
{ {
if (type == PreDefinedShader.SpriteBatch) if (type == PreDefinedShader.SpriteBatch)
@ -123,22 +163,25 @@ namespace ANX.RenderSystem.Windows.Metro
throw new NotImplementedException("ByteCode for '" + type.ToString() + "' is not yet available"); throw new NotImplementedException("ByteCode for '" + type.ToString() + "' is not yet available");
} }
#endregion
#region RegisterCreator
public void RegisterCreator(AddInSystemFactory factory) public void RegisterCreator(AddInSystemFactory factory)
{ {
factory.AddCreator(this); factory.AddCreator(this);
} }
#endregion
#region GetAdapterList (TODO)
public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList() public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{ {
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(new GraphicsAdapter[] return new ReadOnlyCollection<GraphicsAdapter>(new GraphicsAdapter[]
{ {
new GraphicsAdapter() new GraphicsAdapter()
{ {
IsDefaultAdapter = true IsDefaultAdapter = true
} }
}); });
/* /*
SharpDX.DXGI.Factory factory = new Factory(); SharpDX.DXGI.Factory factory = new Factory();
@ -189,15 +232,16 @@ namespace ANX.RenderSystem.Windows.Metro
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(adapterList);*/ 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); return new RenderTarget2D_Metro(graphics, width, height, mipMap,
} preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
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);
} }
#endregion
} }
} }

View File

@ -8,84 +8,32 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro 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.DepthStencilStateDescription description;
private Dx11.DepthStencilState nativeDepthStencilState; private Dx11.DepthStencilState nativeDepthStencilState;
private bool nativeDepthStencilStateDirty;
private bool bound;
private int referenceStencil; private int referenceStencil;
#endregion
#endregion // Private Members #region Public
public StencilOperation CounterClockwiseStencilDepthBufferFail
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
{ {
set set
{ {
Dx11.StencilOperation operation = FormatConverter.Translate(value); Dx11.StencilOperation operation = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.BackFace.DepthFailOperation != operation) ref description.BackFace.DepthFailOperation, ref operation);
{
description.BackFace.DepthFailOperation = operation;
nativeDepthStencilStateDirty = true;
}
} }
} }
public ANX.Framework.Graphics.StencilOperation CounterClockwiseStencilFail public StencilOperation CounterClockwiseStencilFail
{ {
set set
{ {
Dx11.StencilOperation operation = FormatConverter.Translate(value); Dx11.StencilOperation operation = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.BackFace.FailOperation != operation) ref description.BackFace.FailOperation, ref operation);
{
description.BackFace.FailOperation = operation;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -94,12 +42,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.Comparison comparison = FormatConverter.Translate(value); Dx11.Comparison comparison = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.BackFace.Comparison != comparison) ref description.BackFace.Comparison, ref comparison);
{
description.BackFace.Comparison = comparison;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -108,12 +52,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.StencilOperation operation = FormatConverter.Translate(value); Dx11.StencilOperation operation = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.BackFace.PassOperation != operation) ref description.BackFace.PassOperation, ref operation);
{
description.BackFace.PassOperation = operation;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -124,7 +64,7 @@ namespace ANX.RenderSystem.Windows.Metro
if (description.IsDepthEnabled != value) if (description.IsDepthEnabled != value)
{ {
description.IsDepthEnabled = value; description.IsDepthEnabled = value;
nativeDepthStencilStateDirty = true; isDirty = true;
} }
} }
} }
@ -134,12 +74,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.Comparison comparison = FormatConverter.Translate(value); Dx11.Comparison comparison = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.DepthComparison != comparison) ref description.DepthComparison, ref comparison);
{
description.DepthComparison = comparison;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -150,12 +86,8 @@ namespace ANX.RenderSystem.Windows.Metro
Dx11.DepthWriteMask writeMask = value ? Dx11.DepthWriteMask writeMask = value ?
Dx11.DepthWriteMask.All : Dx11.DepthWriteMask.All :
Dx11.DepthWriteMask.Zero; Dx11.DepthWriteMask.Zero;
SetValueIfDifferentAndMarkDirty(
if (description.DepthWriteMask != writeMask) ref description.DepthWriteMask, ref writeMask);
{
description.DepthWriteMask = writeMask;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -163,11 +95,7 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
set set
{ {
if (this.referenceStencil != value) SetValueIfDifferentAndMarkDirty(ref referenceStencil, ref value);
{
this.referenceStencil = value;
this.nativeDepthStencilStateDirty = true;
}
} }
} }
@ -176,12 +104,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.StencilOperation operation = FormatConverter.Translate(value); Dx11.StencilOperation operation = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.FrontFace.DepthFailOperation != operation) ref description.FrontFace.DepthFailOperation, ref operation);
{
description.FrontFace.DepthFailOperation = operation;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -192,36 +116,28 @@ namespace ANX.RenderSystem.Windows.Metro
if (description.IsStencilEnabled != value) if (description.IsStencilEnabled != value)
{ {
description.IsStencilEnabled = value; description.IsStencilEnabled = value;
nativeDepthStencilStateDirty = true; isDirty = true;
} }
} }
} }
public ANX.Framework.Graphics.StencilOperation StencilFail public StencilOperation StencilFail
{ {
set set
{ {
Dx11.StencilOperation operation = FormatConverter.Translate(value); Dx11.StencilOperation operation = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.FrontFace.FailOperation != operation) ref description.FrontFace.FailOperation, ref operation);
{
description.FrontFace.FailOperation = operation;
nativeDepthStencilStateDirty = true;
}
} }
} }
public ANX.Framework.Graphics.CompareFunction StencilFunction public CompareFunction StencilFunction
{ {
set set
{ {
Dx11.Comparison comparison = FormatConverter.Translate(value); Dx11.Comparison comparison = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.FrontFace.Comparison != comparison) ref description.FrontFace.Comparison, ref comparison);
{
description.FrontFace.Comparison = comparison;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -229,27 +145,20 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
set set
{ {
byte stencilMask = (byte)value; //TODO: check range byte stencilMask = (byte)value;
//TODO: check range
if (description.StencilReadMask != stencilMask) SetValueIfDifferentAndMarkDirty(
{ ref description.StencilReadMask, ref stencilMask);
description.StencilReadMask = stencilMask;
nativeDepthStencilStateDirty = true;
}
} }
} }
public ANX.Framework.Graphics.StencilOperation StencilPass public StencilOperation StencilPass
{ {
set set
{ {
Dx11.StencilOperation operation = FormatConverter.Translate(value); Dx11.StencilOperation operation = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.FrontFace.PassOperation != operation) ref description.FrontFace.PassOperation, ref operation);
{
description.FrontFace.PassOperation = operation;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -257,13 +166,10 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
set set
{ {
byte stencilWriteMask = (byte)value; //TODO: check range byte stencilWriteMask = (byte)value;
//TODO: check range
if (description.StencilWriteMask != stencilWriteMask) SetValueIfDifferentAndMarkDirty(
{ ref description.StencilWriteMask, ref stencilWriteMask);
description.StencilWriteMask = stencilWriteMask;
nativeDepthStencilStateDirty = true;
}
} }
} }
@ -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 //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) nativeDepthStencilState.Dispose();
{ nativeDepthStencilState = null;
this.nativeDepthStencilState.Dispose();
this.nativeDepthStencilState = null;
}
this.nativeDepthStencilState = new Dx11.DepthStencilState(device, ref this.description);
this.nativeDepthStencilStateDirty = false;
} }
} }
#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 public class Effect_Metro : INativeEffect
{ {
#region Private
private Dx11.VertexShader vertexShader; private Dx11.VertexShader vertexShader;
private Dx11.PixelShader pixelShader; private Dx11.PixelShader pixelShader;
private Effect managedEffect; private Effect managedEffect;
#endregion
public Effect_Metro(GraphicsDevice device, Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) #region Public
{
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;
}
//internal Dx11.Effect NativeEffect //internal Dx11.Effect NativeEffect
//{ //{
// get // 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 public IEnumerable<EffectTechnique> Techniques
{ {
get 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;
using System.Runtime.InteropServices;
using ANX.Framework; using ANX.Framework;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using ANX.PlatformSystem.Metro;
using SharpDX.DXGI; using SharpDX.DXGI;
using Dx11 = SharpDX.Direct3D11; using Dx11 = SharpDX.Direct3D11;
@ -237,6 +235,7 @@ namespace ANX.RenderSystem.Windows.Metro
NativeDevice.NativeContext.InputAssembler.InputLayout = layout; NativeDevice.NativeContext.InputAssembler.InputLayout = layout;
}*/ }*/
#region CalculateVertexCount
private int CalculateVertexCount(PrimitiveType type, int primitiveCount) private int CalculateVertexCount(PrimitiveType type, int primitiveCount)
{ {
if (type == PrimitiveType.TriangleList) 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() + "'"); throw new NotImplementedException("couldn't calculate vertex count for PrimitiveType '" + type.ToString() + "'");
} }
} }
#endregion
#region SetIndexBuffer
public void SetIndexBuffer(IndexBuffer indexBuffer) public void SetIndexBuffer(IndexBuffer indexBuffer)
{ {
if (indexBuffer == null) if (indexBuffer == null)
@ -281,7 +282,9 @@ namespace ANX.RenderSystem.Windows.Metro
throw new Exception("couldn't fetch native DirectX10 IndexBuffer"); throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
} }
} }
#endregion
#region SetVertexBuffers
public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers) public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers)
{ {
if (vertexBuffers == null) if (vertexBuffers == null)
@ -309,11 +312,16 @@ namespace ANX.RenderSystem.Windows.Metro
NativeDevice.NativeContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); NativeDevice.NativeContext.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
} }
#endregion
#region SetViewport
public void SetViewport(Viewport viewport) 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> /// <summary>
/// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives. The VertexDeclaration of ANX/XNA needs to be mapped /// 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); return new Dx11.InputLayout(device, data, inputElements);
}*/ }*/
#region CreateInputElementFromVertexElement
private Dx11.InputElement CreateInputElementFromVertexElement(VertexElement vertexElement) private Dx11.InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
{ {
string elementName = FormatConverter.Translate(vertexElement.VertexElementUsage); 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); return new Dx11.InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
} }
#endregion
#region SetRenderTargets (TODO)
public void SetRenderTargets(params RenderTargetBinding[] renderTargets) public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
{ {
/*if (renderTargets == null) /*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 public void GetBackBufferData<T>(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -425,13 +438,17 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
#region ResizeBuffers
public void ResizeBuffers(PresentationParameters presentationParameters) public void ResizeBuffers(PresentationParameters presentationParameters)
{ {
NativeDevice.Resize(presentationParameters); NativeDevice.Resize(presentationParameters);
ResizeRenderWindow(presentationParameters); ResizeRenderWindow(presentationParameters);
} }
#endregion
#region ResizeRenderWindow (TODO)
private void ResizeRenderWindow(PresentationParameters presentationParameters) private void ResizeRenderWindow(PresentationParameters presentationParameters)
{ {
// TODO // TODO
@ -441,6 +458,7 @@ namespace ANX.RenderSystem.Windows.Metro
//gameWindow.Form.Bounds //gameWindow.Form.Bounds
//} //}
} }
#endregion
#region Dispose #region Dispose
public void Dispose() public void Dispose()

View File

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

View File

@ -9,7 +9,7 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro namespace ANX.RenderSystem.Windows.Metro
{ {
public class RasterizerState_Metro : INativeRasterizerState public class RasterizerState_Metro : BaseStateObject, INativeRasterizerState
{ {
#region Constants #region Constants
private const int intMaxOver16 = int.MaxValue / 16; private const int intMaxOver16 = int.MaxValue / 16;
@ -18,19 +18,9 @@ namespace ANX.RenderSystem.Windows.Metro
#region Private #region Private
private Dx11.RasterizerDescription1 description; private Dx11.RasterizerDescription1 description;
private Dx11.RasterizerState1 nativeRasterizerState; private Dx11.RasterizerState1 nativeRasterizerState;
private bool nativeRasterizerStateDirty;
private bool bound;
#endregion #endregion
#region Public #region Public
public bool IsBound
{
get
{
return bound;
}
}
public CullMode CullMode public CullMode CullMode
{ {
set set
@ -67,7 +57,7 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
if (description.MultisampleEnable != value) if (description.MultisampleEnable != value)
{ {
nativeRasterizerStateDirty = true; isDirty = true;
description.MultisampleEnable = value; description.MultisampleEnable = value;
} }
} }
@ -79,7 +69,7 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
if (description.ScissorEnable != value) if (description.ScissorEnable != value)
{ {
nativeRasterizerStateDirty = true; isDirty = true;
description.ScissorEnable = value; description.ScissorEnable = value;
} }
} }
@ -100,7 +90,7 @@ namespace ANX.RenderSystem.Windows.Metro
description = new Dx11.RasterizerDescription1(); description = new Dx11.RasterizerDescription1();
description.AntialiasedLineEnable = false; description.AntialiasedLineEnable = false;
nativeRasterizerStateDirty = true; isDirty = true;
} }
#endregion #endregion
@ -118,13 +108,6 @@ namespace ANX.RenderSystem.Windows.Metro
} }
#endregion #endregion
#region Release
public void Release()
{
bound = false;
}
#endregion
#region Dispose #region Dispose
public void Dispose() public void Dispose()
{ {
@ -139,15 +122,16 @@ namespace ANX.RenderSystem.Windows.Metro
#region UpdateNativeRasterizerState #region UpdateNativeRasterizerState
private void UpdateNativeRasterizerState(Dx11.Device1 device) private void UpdateNativeRasterizerState(Dx11.Device1 device)
{ {
if (nativeRasterizerStateDirty == true || if (isDirty == true ||
nativeRasterizerState == null) nativeRasterizerState == null)
{ {
Dispose(); Dispose();
try try
{ {
nativeRasterizerState = new Dx11.RasterizerState1(device, description); nativeRasterizerState =
nativeRasterizerStateDirty = false; new Dx11.RasterizerState1(device, description);
isDirty = false;
} }
catch catch
{ {
@ -155,16 +139,5 @@ namespace ANX.RenderSystem.Windows.Metro
} }
} }
#endregion #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 public class RenderTarget2D_Metro : Texture2D_Metro, INativeRenderTarget2D, INativeTexture2D
{ {
#region Private Members #region Constructor
public RenderTarget2D_Metro(GraphicsDevice graphics, int width, int height,
#endregion // Private Members bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat,
int preferredMultiSampleCount, RenderTargetUsage usage)
public RenderTarget2D_Metro(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
: base(graphics) : base(graphics)
{ {
if (mipMap) if (mipMap)
@ -25,7 +24,7 @@ namespace ANX.RenderSystem.Windows.Metro
this.surfaceFormat = surfaceFormat; this.surfaceFormat = surfaceFormat;
GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; var graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = graphicsMetro.NativeDevice.NativeDevice; Dx11.Device1 device = graphicsMetro.NativeDevice.NativeDevice;
var description = new Dx11.Texture2DDescription() var description = new Dx11.Texture2DDescription()
@ -49,6 +48,6 @@ namespace ANX.RenderSystem.Windows.Metro
this.formatSize = FormatConverter.FormatSize(surfaceFormat); this.formatSize = FormatConverter.FormatSize(surfaceFormat);
} }
#endregion
} }
} }

View File

@ -9,60 +9,21 @@ using Dx11 = SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.Metro 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.SamplerStateDescription description;
private Dx11.SamplerState nativeSamplerState; private Dx11.SamplerState nativeSamplerState;
private bool nativeSamplerStateDirty; #endregion
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;
}
}
#region Public
public TextureAddressMode AddressU public TextureAddressMode AddressU
{ {
set set
{ {
Dx11.TextureAddressMode mode = FormatConverter.Translate(value); Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.AddressU != mode) ref description.AddressU, ref mode);
{
description.AddressU = mode;
nativeSamplerStateDirty = true;
}
} }
} }
@ -71,12 +32,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.TextureAddressMode mode = FormatConverter.Translate(value); Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.AddressV != mode) ref description.AddressV, ref mode);
{
description.AddressV = mode;
nativeSamplerStateDirty = true;
}
} }
} }
@ -85,12 +42,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.TextureAddressMode mode = FormatConverter.Translate(value); Dx11.TextureAddressMode mode = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.AddressW != mode) ref description.AddressW, ref mode);
{
description.AddressW = mode;
nativeSamplerStateDirty = true;
}
} }
} }
@ -99,12 +52,8 @@ namespace ANX.RenderSystem.Windows.Metro
set set
{ {
Dx11.Filter filter = FormatConverter.Translate(value); Dx11.Filter filter = FormatConverter.Translate(value);
SetValueIfDifferentAndMarkDirty(
if (description.Filter != filter) ref description.Filter, ref filter);
{
description.Filter = filter;
nativeSamplerStateDirty = true;
}
} }
} }
@ -112,11 +61,8 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
set set
{ {
if (description.MaximumAnisotropy != value) SetValueIfDifferentAndMarkDirty(
{ ref description.MaximumAnisotropy, ref value);
description.MaximumAnisotropy = value;
nativeSamplerStateDirty = true;
}
} }
} }
@ -127,7 +73,7 @@ namespace ANX.RenderSystem.Windows.Metro
if (description.MaximumLod != value) if (description.MaximumLod != value)
{ {
description.MaximumLod = value; description.MaximumLod = value;
nativeSamplerStateDirty = true; isDirty = true;
} }
} }
} }
@ -136,37 +82,62 @@ namespace ANX.RenderSystem.Windows.Metro
{ {
set set
{ {
if (description.MipLodBias != value) SetValueIfDifferentAndMarkDirty(
{ ref description.MipLodBias, ref value);
description.MipLodBias = value;
nativeSamplerStateDirty = true;
}
} }
} }
#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() public void Dispose()
{ {
if (this.nativeSamplerState != null) if (nativeSamplerState != null)
{ {
this.nativeSamplerState.Dispose(); nativeSamplerState.Dispose();
this.nativeSamplerState = null; nativeSamplerState = null;
} }
} }
#endregion
#region UpdateNativeSamplerState
private void UpdateNativeSamplerState(Dx11.Device1 device) 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(); nativeSamplerState.Dispose();
this.nativeSamplerState = null; 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;
using SharpDX.Direct3D11; using SharpDX.Direct3D11;
using SharpDX.DXGI; using SharpDX.DXGI;
using Windows.UI.Core;
using PresentationParameters = ANX.Framework.Graphics.PresentationParameters; using PresentationParameters = ANX.Framework.Graphics.PresentationParameters;
// This file is part of the ANX.Framework created by the // 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 public class Texture2D_Metro : INativeTexture2D
{ {
#region Private Members #region Private
protected internal Dx11.Texture2D nativeTexture; protected internal Dx11.Texture2D nativeTexture;
protected internal Dx11.ShaderResourceView nativeShaderResourceView; protected internal Dx11.ShaderResourceView nativeShaderResourceView;
protected internal int formatSize; protected internal int formatSize;
protected internal SurfaceFormat surfaceFormat; protected internal SurfaceFormat surfaceFormat;
protected internal GraphicsDevice graphicsDevice; 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) internal Texture2D_Metro(GraphicsDevice graphicsDevice)
{ {
this.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) if (mipCount > 1)
{ {
@ -41,7 +112,7 @@ namespace ANX.RenderSystem.Windows.Metro
GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; GraphicsDeviceWindowsMetro graphicsMetro = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = graphicsMetro.NativeDevice.NativeDevice; Dx11.Device1 device = graphicsMetro.NativeDevice.NativeDevice;
Dx11.Texture2DDescription description = new Dx11.Texture2DDescription() var description = new Dx11.Texture2DDescription()
{ {
Width = width, Width = width,
Height = height, Height = height,
@ -62,69 +133,42 @@ namespace ANX.RenderSystem.Windows.Metro
this.formatSize = FormatConverter.FormatSize(surfaceFormat); this.formatSize = FormatConverter.FormatSize(surfaceFormat);
} }
#endregion
#region GetHashCode
public override int GetHashCode() public override int GetHashCode()
{ {
return NativeTexture.NativePointer.ToInt32(); 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 throw new NotImplementedException();
{
return this.nativeTexture;
}
set
{
if (this.nativeTexture != value)
{
if (this.nativeTexture != null)
{
this.nativeTexture.Dispose();
}
this.nativeTexture = value;
}
}
} }
internal Dx11.ShaderResourceView NativeShaderResourceView public void SetData<T>(GraphicsDevice graphicsDevice, T[] data)
{ where T : struct
get
{
return this.nativeShaderResourceView;
}
set
{
if (this.nativeShaderResourceView != value)
{
if (this.nativeShaderResourceView != null)
{
this.nativeShaderResourceView.Dispose();
}
this.nativeShaderResourceView = value;
}
}
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
{ {
SetData<T>(graphicsDevice, 0, data, 0, data.Length); 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); 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 offsetInBytes parameter
//TODO: handle startIndex parameter //TODO: handle startIndex parameter
//TODO: handle elementCount parameter //TODO: handle elementCount parameter
GraphicsDeviceWindowsMetro metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro; var metroGraphicsDevice = graphicsDevice.NativeDevice as GraphicsDeviceWindowsMetro;
Dx11.Device1 device = metroGraphicsDevice.NativeDevice.NativeDevice; Dx11.Device1 device = metroGraphicsDevice.NativeDevice.NativeDevice;
Dx11.DeviceContext1 context = metroGraphicsDevice.NativeDevice.NativeContext; 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())); throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString()));
} }
} }
#endregion
public int Width #region Dispose
{
get
{
if (this.nativeTexture != null)
{
return this.nativeTexture.Description.Width;
}
return 0;
}
}
public int Height
{
get
{
if (this.nativeTexture != null)
{
return this.nativeTexture.Description.Height;
}
return 0;
}
}
public GraphicsDevice GraphicsDevice
{
get
{
return this.graphicsDevice;
}
}
public void Dispose() public void Dispose()
{ {
if (this.nativeShaderResourceView != null) if (nativeShaderResourceView != null)
{ {
this.nativeShaderResourceView.Dispose(); nativeShaderResourceView.Dispose();
this.nativeShaderResourceView = null; nativeShaderResourceView = null;
} }
if (this.nativeTexture != null) if (nativeTexture != null)
{ {
this.nativeTexture.Dispose(); nativeTexture.Dispose();
this.nativeTexture = null; nativeTexture = null;
} }
} }
#endregion
#region SaveAsJpeg (TODO) #region SaveAsJpeg (TODO)
public void SaveAsJpeg(Stream stream, int width, int height) public void SaveAsJpeg(Stream stream, int width, int height)
@ -280,34 +293,23 @@ namespace ANX.RenderSystem.Windows.Metro
} }
#endregion #endregion
#region INativeTexture2D Member #region GetData (TODO)
public void GetData<T>(int level, Rectangle? rect, T[] data,
int startIndex, int elementCount) where T : struct
public void GetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{ {
throw new NotImplementedException(); 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 public void GetData<T>(T[] data) where T : struct
{ {
throw new NotImplementedException(); 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(); throw new NotImplementedException();
} }
#endregion #endregion
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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