diff --git a/ZenKit/Texture.cs b/ZenKit/Texture.cs index 85ecc0b..cee508e 100644 --- a/ZenKit/Texture.cs +++ b/ZenKit/Texture.cs @@ -47,6 +47,7 @@ public interface ITexture : ICacheable [Serializable] public struct CachedTexture : ITexture { + internal UIntPtr Handle; public TextureFormat Format { get; set; } public int Width { get; set; } public int Height { get; set; } @@ -87,6 +88,20 @@ public int GetHeight(int level) { return Height >> level; } + + public override bool Equals(object other) + { + if (other == null || !(other is CachedTexture)) + { + return false; + } + return ((CachedTexture)other).Handle == Handle; + } + + public override int GetHashCode() + { + return (int)Handle; + } } public class Texture : ITexture @@ -185,7 +200,8 @@ public ITexture Cache() AverageColor = AverageColor, Palette = Palette, AllMipmapsRgba = AllMipmapsRgba, - AllMipmapsRaw = AllMipmapsRaw + AllMipmapsRaw = AllMipmapsRaw, + Handle = Handle }; } @@ -220,6 +236,20 @@ public int GetHeight(int level) { if (_delete) Native.ZkTexture_del(Handle); } + + public override bool Equals(object other) + { + if (other == null || !(other is Texture)) + { + return false; + } + return ((Texture)other).Handle == Handle; + } + + public override int GetHashCode() + { + return (int)Handle; + } } public class TextureBuilder