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

75 lines
2.1 KiB
C#

#region Using Statements
using System;
using ANX.Framework.NonXNA.Development;
using ANX.Framework.NonXNA.RenderSystem;
#endregion
// 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 Texture : GraphicsResource
{
internal INativeTexture nativeTexture;
public int LevelCount { get; internal set; }
public SurfaceFormat Format { get; internal set; }
internal INativeTexture NativeTexture
{
get
{
if (this.nativeTexture == null)
{
ReCreateNativeTextureSurface();
}
return this.nativeTexture;
}
}
internal Texture(GraphicsDevice graphicsDevice)
: base(graphicsDevice)
{
base.GraphicsDevice.ResourceCreated += GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed += GraphicsDevice_ResourceDestroyed;
}
protected override void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed;
if (nativeTexture != null)
{
nativeTexture.Dispose();
nativeTexture = null;
}
}
base.Dispose(disposeManaged);
}
internal abstract void ReCreateNativeTextureSurface();
private void GraphicsDevice_ResourceDestroyed(object sender, ResourceDestroyedEventArgs e)
{
Dispose(true);
}
private void GraphicsDevice_ResourceCreated(object sender, ResourceCreatedEventArgs e)
{
Dispose(true);
ReCreateNativeTextureSurface();
}
}
}