SND\AstrorEnales_cp 5505f7dcbf - Added PlatformSystem Plugins layer
- Started Windows, Metro and Linux Platform-Plugins
- Moved the RecordingSample to the Samples folder
- Started two samples for using the graphics device in a WinForms and Wpf Editor
- Refactorings in the AddIn-System
- Moved the Window initialization-code to the Platform modules
- Changed the License text in all code files which is now way smaller
- Started ProjectConverter tool which converts all the projects and solution to the target configuration
- Changed the SupportedPlatform names in the Resource files
- Changed the WIN8 define to WINDOWSMETRO which is actually meant
- Removed NLog and started our own Logger class
- Many more stuff...
2012-08-09 09:45:04 +00:00

99 lines
2.6 KiB
C#

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