Added IEquatable interface to allow use as key in dictionaries.

This commit is contained in:
the_fiddler 2008-11-25 16:44:52 +00:00
parent d840251dbd
commit 8249b75f42

View file

@ -33,7 +33,7 @@ using System.Drawing.Imaging;
namespace OpenTK.Graphics namespace OpenTK.Graphics
{ {
abstract class Texture2D : IGraphicsResource abstract class Texture2D : IGraphicsResource, IEquatable<Texture2D>
{ {
#region Fields #region Fields
@ -165,6 +165,23 @@ namespace OpenTK.Graphics
#endregion #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 #endregion
#region Protected Members #region Protected Members
@ -227,6 +244,15 @@ namespace OpenTK.Graphics
#endregion #endregion
#region IEquatable<Texture2D> Members
public bool Equals(Texture2D other)
{
return (this as IGraphicsResource).Id == (other as IGraphicsResource).Id;
}
#endregion
#region IDisposable Members #region IDisposable Members
public void Dispose() public void Dispose()