-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathGLXContext.cs
91 lines (82 loc) · 3.4 KB
/
GLXContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Runtime.InteropServices;
namespace GLFW
{
/// <summary>
/// Wrapper around a GLX context pointer.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
// ReSharper disable once InconsistentNaming
public struct GLXContext : IEquatable<GLXContext>
{
/// <summary>
/// Describes a default/null instance.
/// </summary>
public static readonly GLXContext None;
/// <summary>
/// Internal pointer.
/// </summary>
private readonly IntPtr handle;
/// <summary>
/// Performs an implicit conversion from <see cref="GLXContext" /> to <see cref="IntPtr" />.
/// </summary>
/// <param name="context">The context.</param>
/// <returns>
/// The result of the conversion.
/// </returns>
public static implicit operator IntPtr(GLXContext context) { return context.handle; }
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this instance.
/// </returns>
public override string ToString() { return handle.ToString(); }
/// <summary>
/// Determines whether the specified <see cref="GLXContext" />, is equal to this instance.
/// </summary>
/// <param name="other">The <see cref="GLXContext" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="GLXContext" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public bool Equals(GLXContext other) { return handle.Equals(other.handle); }
/// <summary>
/// Determines whether the specified <see cref="object" />, is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (obj is GLXContext context)
return Equals(context);
return false;
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode() { return handle.GetHashCode(); }
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator ==(GLXContext left, GLXContext right) { return left.Equals(right); }
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator !=(GLXContext left, GLXContext right) { return !left.Equals(right); }
}
}