From 8249b75f42f03f008eeb43a9b58d82123cecb3f2 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Tue, 25 Nov 2008 16:44:52 +0000 Subject: [PATCH] Added IEquatable interface to allow use as key in dictionaries. --- Source/Utilities/Graphics/Texture2D.cs | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Source/Utilities/Graphics/Texture2D.cs b/Source/Utilities/Graphics/Texture2D.cs index 6ab7cbc1..6e487425 100644 --- a/Source/Utilities/Graphics/Texture2D.cs +++ b/Source/Utilities/Graphics/Texture2D.cs @@ -33,7 +33,7 @@ using System.Drawing.Imaging; namespace OpenTK.Graphics { - abstract class Texture2D : IGraphicsResource + abstract class Texture2D : IGraphicsResource, IEquatable { #region Fields @@ -165,6 +165,23 @@ namespace OpenTK.Graphics #endregion + #region Equals + + public override bool Equals(object obj) + { + if (obj is Texture2D) + return this.Equals((Texture2D)obj); + + return false; + } + + #endregion + + //public override int GetHashCode() + //{ + // return (this as IGraphicsResource).Id; + //} + #endregion #region Protected Members @@ -227,6 +244,15 @@ namespace OpenTK.Graphics #endregion + #region IEquatable Members + + public bool Equals(Texture2D other) + { + return (this as IGraphicsResource).Id == (other as IGraphicsResource).Id; + } + + #endregion + #region IDisposable Members public void Dispose()