- 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\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" /> <Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" /> <Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />
<Compile Include="NonXNA\ThreadHelper.cs" />
<Compile Include="NonXNA\Windows8\AssetsHelper.cs" /> <Compile Include="NonXNA\Windows8\AssetsHelper.cs" />
<Compile Include="NonXNA\Windows8\IServiceProvider.cs" /> <Compile Include="NonXNA\Windows8\IServiceProvider.cs" />
<Compile Include="NonXNA\NoInputDeviceException.cs" /> <Compile Include="NonXNA\NoInputDeviceException.cs" />

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,90 +1,77 @@
#region Using Statements
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#endregion // Using Statements
// 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
namespace ANX.Framework.Graphics namespace ANX.Framework.Graphics
{ {
public class VertexDeclaration : GraphicsResource public class VertexDeclaration : GraphicsResource
{ {
private int vertexStride; private VertexElement[] elements;
private VertexElement[] elements;
public VertexDeclaration(params VertexElement[] elements) public int VertexStride
{ {
this.elements = elements; get;
private set;
}
public VertexDeclaration(params VertexElement[] elements)
{
this.elements = elements;
for (int i = 0; i < this.elements.Length; i++) for (int i = 0; i < this.elements.Length; i++)
{ VertexStride += GetElementStride(this.elements[i].VertexElementFormat);
this.vertexStride += GetElementStride(this.elements[i].VertexElementFormat); }
}
}
public VertexDeclaration(int vertexStride, params VertexElement[] elements) public VertexDeclaration(int vertexStride, params VertexElement[] elements)
{ {
this.elements = elements; this.elements = elements;
this.vertexStride = vertexStride; VertexStride = vertexStride;
} }
public override void Dispose() public VertexElement[] GetVertexElements()
{ {
throw new NotImplementedException(); if (elements != null)
} return elements.Clone() as VertexElement[];
else
return null;
}
public int VertexStride public override void Dispose()
{ {
get Dispose(true);
{ }
return this.vertexStride;
}
}
public VertexElement[] GetVertexElements() protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged)
{ {
if (elements != null) // Nothing to dispose
{ }
return elements.Clone() as VertexElement[];
}
else
{
return null;
}
}
protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) private int GetElementStride(VertexElementFormat format)
{ {
throw new NotImplementedException(); switch (format)
} {
case VertexElementFormat.NormalizedShort2:
private int GetElementStride(VertexElementFormat format) case VertexElementFormat.Byte4:
{ case VertexElementFormat.Color:
switch (format) case VertexElementFormat.HalfVector2:
{ case VertexElementFormat.Short2:
case VertexElementFormat.NormalizedShort2: case VertexElementFormat.Single:
case VertexElementFormat.Byte4: return 4;
case VertexElementFormat.Color: case VertexElementFormat.HalfVector4:
case VertexElementFormat.HalfVector2: case VertexElementFormat.NormalizedShort4:
case VertexElementFormat.Short2: case VertexElementFormat.Short4:
case VertexElementFormat.Single: case VertexElementFormat.Vector2:
return 4; return 8;
case VertexElementFormat.HalfVector4: case VertexElementFormat.Vector3:
case VertexElementFormat.NormalizedShort4: return 12;
case VertexElementFormat.Short4: case VertexElementFormat.Vector4:
case VertexElementFormat.Vector2: return 16;
return 8; default:
case VertexElementFormat.Vector3: throw new ArgumentException("unknown VertexElementFormat size '" + format + "'");
return 12; }
case VertexElementFormat.Vector4: }
return 16; }
default:
throw new ArgumentException("unknown VertexElementFormat size '" + format.ToString() + "'");
}
}
}
} }

View File

@ -172,12 +172,27 @@ namespace ANX.Framework
public void Dispose() public void Dispose()
{ {
throw new NotImplementedException(); Dispose(true);
GC.SuppressFinalize(this);
} }
protected virtual void Dispose(bool disposing) 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) protected GraphicsDeviceInformation FindBestDevice(bool anySuitableDevice)

View File

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

View File

@ -97,6 +97,17 @@ namespace ANX.Framework.NonXNA
} }
#endregion #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 #region BuildStackTrace
private static string BuildStackTrace() private static string BuildStackTrace()
{ {

View File

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

View File

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

View File

@ -1,50 +1,52 @@
#region Using Statements
using System; using System;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
#endregion // Using Statements
// 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
namespace ANX.Framework.NonXNA namespace ANX.Framework.NonXNA
{ {
public interface INativeGraphicsDevice : IDisposable public interface INativeGraphicsDevice : IDisposable
{ {
void Clear(ref Color color); void Clear(ref Color color);
void Clear(ClearOptions options, Vector4 color, float depth, int stencil); void Clear(ClearOptions options, Vector4 color, float depth, int stencil);
void Present(); 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); void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount);
#if XNAEXT #if XNAEXT
void SetConstantBuffer(int slot, ConstantBuffer constantBuffer); void SetConstantBuffer(int slot, ConstantBuffer constantBuffer);
#endif #endif
void SetVertexBuffers(VertexBufferBinding[] vertexBuffers); void SetVertexBuffers(VertexBufferBinding[] vertexBuffers);
void SetIndexBuffer(IndexBuffer indexBuffer); void SetIndexBuffer(IndexBuffer indexBuffer);
void SetViewport(Viewport viewport); void SetViewport(Viewport viewport);
void SetRenderTargets(params RenderTargetBinding[] renderTargets); void SetRenderTargets(params RenderTargetBinding[] renderTargets);
void GetBackBufferData<T>(Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct; void GetBackBufferData<T>(Nullable<Rectangle> rect, T[] data, int startIndex, int elementCount) where T : struct;
void GetBackBufferData<T>(T[] data) where T : struct; void GetBackBufferData<T>(T[] data) where T : struct;
void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct; void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct;
void ResizeBuffers(PresentationParameters presentationParameters); void ResizeBuffers(PresentationParameters presentationParameters);
bool VSync { get; set; } bool VSync { get; set; }
} }
} }

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> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -54,10 +54,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -54,10 +54,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>

View File

@ -56,10 +56,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

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

View File

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

View File

@ -57,10 +57,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -57,10 +57,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -57,10 +57,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>

View File

@ -59,10 +59,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath> <HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
</Reference> </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" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -2,9 +2,9 @@
using System.IO; using System.IO;
using ANX.Framework.Audio; using ANX.Framework.Audio;
using ANX.Framework.NonXNA.SoundSystem; using ANX.Framework.NonXNA.SoundSystem;
using OpenTK.Audio; using OpenTK.Audio.OpenAL;
using WaveUtils; using WaveUtils;
using ALFormat = OpenTK.Audio.ALFormat; using ALFormat = OpenTK.Audio.OpenAL.ALFormat;
// 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.

View File

@ -1,7 +1,7 @@
using System; using System;
using ANX.Framework.Audio; using ANX.Framework.Audio;
using ANX.Framework.NonXNA.SoundSystem; using ANX.Framework.NonXNA.SoundSystem;
using OpenTK.Audio; using OpenTK.Audio.OpenAL;
// 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.