- Further implemented the Dispose chain which now prevents the OpenGL gd from leaking (still some work required)

- Logging OpenGL version on Device Reset with GL3 RenderSystem
This commit is contained in:
SND\AstrorEnales_cp 2012-08-30 12:05:40 +00:00
parent 4ec1977383
commit 845d8ec716
27 changed files with 930 additions and 921 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -86,8 +86,8 @@ namespace ANX.Framework
//TODO: implement draw- and update-order handling of GameComponents
this.components = new GameComponentCollection();
this.components.ComponentAdded += new EventHandler<GameComponentCollectionEventArgs>(components_ComponentAdded);
this.components.ComponentRemoved += new EventHandler<GameComponentCollectionEventArgs>(components_ComponentRemoved);
this.components.ComponentAdded += components_ComponentAdded;
this.components.ComponentRemoved += components_ComponentRemoved;
this.drawableGameComponents = new List<IGameComponent>();
Logger.Info("finished initializing new Game class");
@ -98,17 +98,17 @@ namespace ANX.Framework
this.components.ComponentAdded -= components_ComponentAdded;
this.components.ComponentRemoved -= components_ComponentRemoved;
//TODO: implement
Dispose(false);
}
#region CreateGameHost
private void CreateGameHost()
{
Logger.Info("creating GameHost");
var creator =
AddInSystemFactory.Instance.GetDefaultCreator<IPlatformSystemCreator>();
if (creator != null)
{
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IPlatformSystemCreator>();
if (creator == null)
Logger.ErrorAndThrow<NullReferenceException>("Could not fetch PlatformSystem creator to create a game host.");
host = creator.CreateGameHost(this);
host.Activated += HostActivated;
@ -118,12 +118,6 @@ namespace ANX.Framework
host.Idle += HostIdle;
host.Exiting += HostExiting;
}
else
{
Logger.Error("could not fetch PlatformSystem creator to create a game host...");
throw new NullReferenceException("could not fetch PlatformSystem creator");
}
}
#endregion
#region AddSystemCreator
@ -233,9 +227,7 @@ namespace ANX.Framework
public void Tick()
{
if (this.ShouldExit)
{
return;
}
//TODO: calculation of times is wrong
//TODO: encapsulate timing stuff in GameTimer class
@ -244,10 +236,7 @@ namespace ANX.Framework
{
while (elapsedUpdate < targetElapsedTime)
{
// TODO: search replacement
#if !WINDOWSMETRO
Thread.Sleep(TargetElapsedTime.Milliseconds - elapsedUpdate.Milliseconds);
#endif
ThreadHelper.Sleep(TargetElapsedTime.Milliseconds - elapsedUpdate.Milliseconds);
elapsedUpdate = TimeSpan.FromTicks(clock.Timestamp - elapsedUpdate.Ticks);
}
@ -281,9 +270,8 @@ namespace ANX.Framework
{
this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager;
if (this.graphicsDeviceManager != null)
{
this.graphicsDeviceManager.CreateDevice();
}
this.Initialize();
this.inRun = true;
this.BeginRun();
@ -406,11 +394,7 @@ namespace ANX.Framework
{
get
{
if (this.host != null)
{
return this.host.Window;
}
return null;
return (host != null) ? host.Window : null;
}
}
@ -482,12 +466,31 @@ namespace ANX.Framework
public void Dispose()
{
//TODO: dispose everything to dispose :-)
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
//TODO: dispose everything to dispose :-)
if (disposing)
{
IDisposable disposable;
var array = new IGameComponent[components.Count];
components.CopyTo(array, 0);
for (int i = 0; i < array.Length; i++)
{
disposable = (IDisposable)array[i];
if (disposable != null)
disposable.Dispose();
}
disposable = (IDisposable)graphicsDeviceManager;
if (disposable != null)
disposable.Dispose();
if (Disposed != null)
Disposed(this, EventArgs.Empty);
}
}
protected virtual void OnActivated(Object sender, EventArgs args)

View File

@ -15,47 +15,39 @@ namespace ANX.Framework
internal event EventHandler<EventArgs> Resume;
internal event EventHandler<EventArgs> Suspend;
public abstract GameWindow Window { get; }
public GameHost(Game game)
{
}
public abstract void Run();
public abstract GameWindow Window { get; }
public abstract void Exit();
protected void OnActivated()
{
if (this.Activated != null)
{
this.Activated(this, EventArgs.Empty);
}
InvokeIfNotNull(this.Activated);
}
protected void OnDeactivated()
{
if (this.Deactivated != null)
{
this.Deactivated(this, EventArgs.Empty);
}
InvokeIfNotNull(this.Deactivated);
}
protected void OnIdle()
{
if (this.Idle != null)
{
this.Idle(this, EventArgs.Empty);
}
InvokeIfNotNull(this.Idle);
}
protected void OnExiting()
{
if (this.Exiting != null)
InvokeIfNotNull(this.Exiting);
}
private void InvokeIfNotNull(EventHandler<EventArgs> eventHandler)
{
this.Exiting(this, EventArgs.Empty);
}
if (eventHandler != null)
eventHandler(this, EventArgs.Empty);
}
}
}

View File

@ -1,13 +1,6 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using ANX.Framework.Graphics;
using System.Runtime.InteropServices;
#endregion // Using Statements
using ANX.Framework.NonXNA;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -47,7 +40,8 @@ namespace ANX.Framework.Graphics
#endregion // Events
#region Constructor & Destructor
public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile, PresentationParameters presentationParameters)
public GraphicsDevice(GraphicsAdapter adapter, GraphicsProfile graphicsProfile,
PresentationParameters presentationParameters)
{
this.currentAdapter = adapter;
this.graphicsProfile = graphicsProfile;
@ -56,7 +50,8 @@ namespace ANX.Framework.Graphics
Recreate(presentationParameters);
this.samplerStateCollection = new SamplerStateCollection(this, 8); //TODO: get maximum number of sampler states from capabilities
// TODO: get maximum number of sampler states from capabilities
this.samplerStateCollection = new SamplerStateCollection(this, 8);
this.textureCollection = new TextureCollection();
this.vertexTextureCollection = new TextureCollection();
@ -69,7 +64,6 @@ namespace ANX.Framework.Graphics
{
this.Dispose(false);
}
#endregion // Constructor & Destructor
#region Clear
@ -129,74 +123,84 @@ namespace ANX.Framework.Graphics
#endregion // Present
#region DrawPrimitives & DrawIndexedPrimitives
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount)
{
nativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex, primitiveCount);
nativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
primitiveCount);
}
public void DrawPrimitives(PrimitiveType primitiveType, int startVertex, int primitiveCount)
{
nativeDevice.DrawPrimitives(primitiveType, startVertex, primitiveCount);
}
#endregion // DrawPrimitives & DrawIndexedPrimitives
#endregion
#region DrawInstancedPrimitives
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount)
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount)
{
nativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex, primitiveCount, instanceCount);
nativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
primitiveCount, instanceCount);
}
#endregion // DrawInstancedPrimitives
#endregion
#region DrawUserIndexedPrimitives<T>
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
short[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
{
//TODO: cache the instances to avoid reflection overhead
IVertexType vertexType = Activator.CreateInstance<T>();
VertexDeclaration vertexDeclaration = vertexType.VertexDeclaration;
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>();
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
}
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
short[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
where T : struct, IVertexType
{
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.SixteenBits);
}
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, int[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
int[] indexData, int indexOffset, int primitiveCount) where T : struct, IVertexType
{
//TODO: cache the instances to avoid reflection overhead
IVertexType vertexType = Activator.CreateInstance<T>();
VertexDeclaration vertexDeclaration = vertexType.VertexDeclaration;
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>();
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
}
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, int[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
int[] indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration)
where T : struct, IVertexType
{
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData, indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
nativeDevice.DrawUserIndexedPrimitives<T>(primitiveType, vertexData, vertexOffset, numVertices, indexData,
indexOffset, primitiveCount, vertexDeclaration, IndexElementSize.ThirtyTwoBits);
}
#endregion // DrawUserIndexedPrimitives<T>
#endregion
#region DrawUserPrimitives<T>
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount) where T : struct, IVertexType
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount)
where T : struct, IVertexType
{
VertexDeclaration vertexDeclaration = GetDeclarationForDraw<T>();
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
}
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount,
VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
}
#endregion
private VertexDeclaration GetDeclarationForDraw<T>() where T : struct, IVertexType
{
//TODO: cache the instances to avoid reflection overhead
IVertexType vertexType = Activator.CreateInstance<T>();
VertexDeclaration vertexDeclaration = vertexType.VertexDeclaration;
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
return vertexType.VertexDeclaration;
}
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{
nativeDevice.DrawUserPrimitives<T>(primitiveType, vertexData, vertexOffset, primitiveCount, vertexDeclaration);
}
#endregion // DrawUserPrimitives<T>
#if XNAEXT
#region SetConstantBuffer
/// <summary>
@ -351,29 +355,36 @@ namespace ANX.Framework.Graphics
// reset presentation parameters
nativeDevice.ResizeBuffers(presentationParameters);
this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight);
raise_DeviceReset(this, EventArgs.Empty);
}
#endregion // Reset
#region Dispose (TODO)
public void Dispose()
{
if (this.nativeDevice != null)
{
this.nativeDevice.Dispose();
this.nativeDevice = null;
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
if (isDisposed == false)
{
if (nativeDevice != null)
{
nativeDevice.Dispose();
nativeDevice = null;
}
raise_Disposing(this, EventArgs.Empty);
//TODO: more to dispose?
}
protected virtual void Dispose(
[MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
//TODO: implement
}
#endregion
#region Public Properties
public IndexBuffer Indices
@ -633,8 +644,10 @@ namespace ANX.Framework.Graphics
if (nativeDevice == null)
{
this.currentPresentationParameters = presentationParameters;
nativeDevice = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateGraphicsDevice(presentationParameters);
this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
var creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
nativeDevice = creator.CreateGraphicsDevice(presentationParameters);
this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth,
presentationParameters.BackBufferHeight);
raise_ResourceCreated(this, new ResourceCreatedEventArgs(nativeDevice));
GraphicsResourceTracker.Instance.UpdateGraphicsDeviceReference(this);
@ -675,55 +688,42 @@ namespace ANX.Framework.Graphics
}
}
}
}
protected void raise_Disposing(object sender, EventArgs args)
{
if (Disposing != null)
{
Disposing(sender, args);
}
}
protected void raise_DeviceResetting(object sender, EventArgs args)
{
if (DeviceResetting != null)
{
DeviceResetting(sender, args);
}
}
protected void raise_DeviceReset(object sender, EventArgs args)
{
if (DeviceReset != null)
{
DeviceReset(sender, args);
}
}
protected void raise_DeviceLost(object sender, EventArgs args)
{
if (DeviceLost != null)
{
DeviceLost(sender, args);
}
}
protected void raise_ResourceCreated(object sender, ResourceCreatedEventArgs args)
{
if (ResourceCreated != null)
{
ResourceCreated(sender, args);
}
}
protected void raise_ResourceDestroyed(object sender, ResourceDestroyedEventArgs args)
{
if (ResourceDestroyed != null)
{
ResourceDestroyed(sender, args);
}
}
}
}

View File

@ -1,9 +1,6 @@
#region Using Statements
using System;
using System.Runtime.InteropServices;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
@ -12,54 +9,44 @@ namespace ANX.Framework.Graphics
{
public class VertexDeclaration : GraphicsResource
{
private int vertexStride;
private VertexElement[] elements;
public int VertexStride
{
get;
private set;
}
public VertexDeclaration(params VertexElement[] elements)
{
this.elements = elements;
for (int i = 0; i < this.elements.Length; i++)
{
this.vertexStride += GetElementStride(this.elements[i].VertexElementFormat);
}
VertexStride += GetElementStride(this.elements[i].VertexElementFormat);
}
public VertexDeclaration(int vertexStride, params VertexElement[] elements)
{
this.elements = elements;
this.vertexStride = vertexStride;
}
public override void Dispose()
{
throw new NotImplementedException();
}
public int VertexStride
{
get
{
return this.vertexStride;
}
VertexStride = vertexStride;
}
public VertexElement[] GetVertexElements()
{
if (elements != null)
{
return elements.Clone() as VertexElement[];
}
else
{
return null;
}
public override void Dispose()
{
Dispose(true);
}
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{
throw new NotImplementedException();
// Nothing to dispose
}
private int GetElementStride(VertexElementFormat format)
@ -83,7 +70,7 @@ namespace ANX.Framework.Graphics
case VertexElementFormat.Vector4:
return 16;
default:
throw new ArgumentException("unknown VertexElementFormat size '" + format.ToString() + "'");
throw new ArgumentException("unknown VertexElementFormat size '" + format + "'");
}
}
}

View File

@ -172,12 +172,27 @@ namespace ANX.Framework
public void Dispose()
{
throw new NotImplementedException();
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
throw new NotImplementedException();
if (disposing)
{
if (game != null)
if (game.Services.GetService(typeof(IGraphicsDeviceService)) == this)
game.Services.RemoveService(typeof(IGraphicsDeviceService));
if (graphicsDevice != null)
{
graphicsDevice.Dispose();
graphicsDevice = null;
}
if (Disposed != null)
Disposed(this, EventArgs.Empty);
}
}
protected GraphicsDeviceInformation FindBestDevice(bool anySuitableDevice)

View File

@ -104,7 +104,7 @@ namespace ANX.Framework.NonXNA
this.assembly = TypeHelper.GetAssemblyFrom(creatorType);
this.creatorType = creatorType;
Type = AddInSystemFactory.GetAddInType(creatorType);
this.supportedPlatforms = (ISupportedPlatforms)Activator.CreateInstance(supportedPlatformsType);
this.supportedPlatforms = TypeHelper.Create<ISupportedPlatforms>(supportedPlatformsType);
Version = assembly.GetName().Version;
}
#endregion
@ -123,7 +123,7 @@ namespace ANX.Framework.NonXNA
{
try
{
instance = Activator.CreateInstance(creatorType) as ICreator;
instance = TypeHelper.Create<ICreator>(creatorType); ;
}
catch (Exception ex)
{
@ -131,11 +131,9 @@ namespace ANX.Framework.NonXNA
}
if (instance != null)
{
AddInSystemFactory.Instance.AddCreator(instance);
}
}
}
#endregion
}
}

View File

@ -97,6 +97,17 @@ namespace ANX.Framework.NonXNA
}
#endregion
#region ErrorAndThrow
public static void ErrorAndThrow<T>(string message) where T : Exception, new ()
{
string text = CurrentTimeStamp + "| Error: " + message + BuildStackTrace();
WriteToConsole(text);
WriteToFile(text);
throw (T)Activator.CreateInstance(typeof(T), message);
}
#endregion
#region BuildStackTrace
private static string BuildStackTrace()
{

View File

@ -65,13 +65,17 @@ namespace ANX.Framework.NonXNA.Reflection
foreach (string file in assembliesInPath)
{
if (file.EndsWith("OpenTK.dll") ||
file.EndsWith("OpenTK.GLControl.dll") ||
file.EndsWith("OpenTK.Compatibility.dll") ||
file.EndsWith("SharpDX.dll") ||
file.EndsWith("SharpDX.Direct3D11.dll") ||
file.EndsWith("SharpDX.Direct3D10.dll") ||
file.EndsWith("SharpDX.D3DCompiler.dll") ||
file.EndsWith("SharpDX.DXGI.dll") ||
file.EndsWith("SharpDX.XInput.dll") ||
file.EndsWith("SharpDX.DirectInput.dll"))
file.EndsWith("SharpDX.DirectInput.dll") ||
file.EndsWith("WaveUtils.dll") ||
file.EndsWith("SharpDX.XAudio2.dll"))
{
continue;
}
@ -166,10 +170,11 @@ namespace ANX.Framework.NonXNA.Reflection
continue;
}
bool isTypeValidInputDevice = TypeHelper.IsAnyTypeAssignableFrom(InputDeviceFactory.ValidInputDeviceCreators, type);
bool isTypeValidInputDevice = TypeHelper.IsAnyTypeAssignableFrom(InputDeviceFactory.ValidInputDeviceCreators,
type);
if (isTypeValidInputDevice && isTypeCreatable)
{
var inputCreator = Activator.CreateInstance(type) as IInputDeviceCreator;
var inputCreator = TypeHelper.Create<IInputDeviceCreator>(type);
InputDeviceFactory.Instance.AddCreator(type, inputCreator);
}
}

View File

@ -158,5 +158,12 @@ namespace ANX.Framework.NonXNA.Reflection
#endif
}
#endregion
#region Create
public static T Create<T>(Type type)
{
return (T)Activator.CreateInstance(type);
}
#endregion
}
}

View File

@ -1,9 +1,6 @@
#region Using Statements
using System;
using ANX.Framework.Graphics;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
@ -17,13 +14,18 @@ namespace ANX.Framework.NonXNA
void Present();
void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount);
void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount);
void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount);
void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount);
void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration, IndexElementSize indexFormat) where T : struct, IVertexType;
void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
IndexElementSize indexFormat) where T : struct, IVertexType;
void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType;
void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount,
VertexDeclaration vertexDeclaration) where T : struct, IVertexType;
void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount);

View File

@ -0,0 +1,17 @@
using System;
using System.Threading;
namespace ANX.Framework.NonXNA
{
internal static class ThreadHelper
{
public static void Sleep(int milliseconds)
{
#if WINDOWSMETRO
// TODO: search replacement
#else
Thread.Sleep(milliseconds);
#endif
}
}
}

View File

@ -54,10 +54,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>

View File

@ -54,10 +54,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>

View File

@ -54,10 +54,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>

View File

@ -56,10 +56,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>

View File

@ -18,6 +18,7 @@ namespace ANX.RenderSystem.Windows.GL3
{
[PercentageComplete(90)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
public class Creator : IRenderSystemCreator
{
#region Public
@ -79,8 +80,7 @@ namespace ANX.RenderSystem.Windows.GL3
#endregion
#region CreateGraphicsDevice
INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice(
PresentationParameters presentationParameters)
INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice(PresentationParameters presentationParameters)
{
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
return new GraphicsDeviceWindowsGL3(presentationParameters);
@ -145,8 +145,9 @@ namespace ANX.RenderSystem.Windows.GL3
#endregion
#if XNAEXT
#region CreateConstantBuffer
public INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer, BufferUsage usage)
#region CreateConstantBuffer (TODO)
public INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer,
BufferUsage usage)
{
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
@ -316,9 +317,11 @@ namespace ANX.RenderSystem.Windows.GL3
}
#endregion
#region IsLanguageSupported
public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage)
{
return sourceLanguage == EffectSourceLanguage.GLSL_FX || sourceLanguage == EffectSourceLanguage.GLSL;
}
#endregion
}
}

View File

@ -51,6 +51,8 @@ namespace ANX.RenderSystem.Windows.GL3
{
get
{
if (Current == null || Current.nativeContext == null)
return false;
return Current.nativeContext.IsCurrent;
}
}
@ -78,11 +80,6 @@ namespace ANX.RenderSystem.Windows.GL3
Current = this;
ResetDevice(presentationParameters);
}
~GraphicsDeviceWindowsGL3()
{
Dispose();
}
#endregion
#region ResetDevice
@ -471,16 +468,16 @@ namespace ANX.RenderSystem.Windows.GL3
activeEffect = null;
boundRenderTargets = null;
if (nativeContext != null)
{
nativeContext.Dispose();
nativeContext = null;
}
if (nativeWindowInfo != null)
{
nativeWindowInfo.Dispose();
nativeWindowInfo = null;
}
if (nativeContext != null)
{
nativeContext.Dispose();
nativeContext = null;
}
}
#endregion
}

View File

@ -57,10 +57,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>

View File

@ -57,10 +57,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>

View File

@ -57,10 +57,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>

View File

@ -59,10 +59,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>

View File

@ -2,9 +2,9 @@
using System.IO;
using ANX.Framework.Audio;
using ANX.Framework.NonXNA.SoundSystem;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
using WaveUtils;
using ALFormat = OpenTK.Audio.ALFormat;
using ALFormat = OpenTK.Audio.OpenAL.ALFormat;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.

View File

@ -1,7 +1,7 @@
using System;
using ANX.Framework.Audio;
using ANX.Framework.NonXNA.SoundSystem;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.