anx.framework/ANX.Framework/Graphics/GraphicsResource.cs
Konstantin Koch 85322e2363 Migrated Primitives, RecordingSample, RenderTarget and SimpleSprite. Also implemented DynamicBuffers and fixed many Dispose functions
increased the amount of shared code between vertex and index buffers
fixed GraphicsDevice.Reset() which didn't save the provided presentation
parameters and the backbuffer was still bound after the recent changes
about the rendertargets
Vertex and IndexBuffers that get dynamically generated for the UserDraw
methods dispose the buffers now
Added DebugNames to Index and VertexBuffers and their Dynamic version.
2015-10-04 21:30:00 +02:00

84 lines
1.7 KiB
C#

using System;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
public abstract class GraphicsResource : IDisposable
{
public event EventHandler<EventArgs> Disposing;
internal GraphicsResource()
{
GraphicsResourceTracker.Instance.RegisterTrackedObject(this);
}
public GraphicsResource(GraphicsDevice device)
: this()
{
this.GraphicsDevice = device;
}
public GraphicsDevice GraphicsDevice
{
get;
internal set;
}
public bool IsDisposed
{
get;
internal set;
}
public string Name
{
get;
set;
}
public object Tag
{
get;
set;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected void raise_Disposing(object sender, EventArgs args)
{
if (Disposing != null)
{
Disposing(sender, args);
}
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
raise_Disposing(this, EventArgs.Empty);
GraphicsResourceTracker.Instance.UnregisterTrackedObject(this);
}
}
public override string ToString()
{
return base.ToString();
}
}
}