using System; namespace Veldrid.OpenGLBinding { /// /// A boolean value stored in an unsigned byte. /// public struct GLboolean : IEquatable { /// /// The raw value of the . A value of 0 represents "false", all other values represent "true". /// public byte Value; /// /// Constructs a new with the given raw value. /// /// public GLboolean(byte value) { Value = value; } /// /// Represents the boolean "true" value. Has a raw value of 1. /// public static readonly GLboolean True = new GLboolean(1); /// /// Represents the boolean "true" value. Has a raw value of 0. /// public static readonly GLboolean False = new GLboolean(0); /// /// Returns whether another value is considered equal to this one. /// Two s are considered equal when their raw values are equal. /// /// The value to compare to. /// True if the other value's underlying raw value is equal to this instance's. False otherwise. public bool Equals(GLboolean other) { return Value.Equals(other.Value); } public override bool Equals(object obj) { return obj is GLboolean b && Equals(b); } public override int GetHashCode() { return Value.GetHashCode(); } public override string ToString() { return $"{(this ? "True" : "False")} ({Value})"; } public static implicit operator bool(GLboolean b) => b.Value != 0; public static implicit operator uint(GLboolean b) => b.Value; public static implicit operator GLboolean(bool b) => b ? True : False; public static implicit operator GLboolean(byte value) => new GLboolean(value); public static bool operator ==(GLboolean left, GLboolean right) => left.Value == right.Value; public static bool operator !=(GLboolean left, GLboolean right) => left.Value != right.Value; } }