-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGraphicsState.cs
67 lines (58 loc) · 1.94 KB
/
GraphicsState.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
using System;
namespace OpenWheels.Rendering
{
/// <summary>
/// Holds graphics state for rendering.
/// </summary>
public struct GraphicsState : IEquatable<GraphicsState>
{
/// <summary>
/// The texture to render.
/// </summary>
public readonly int Texture;
/// <summary>
/// Sampler state to apply.
/// </summary>
public readonly SamplerState SamplerState;
/// <summary>
/// Create a new <see cref="GraphicsState"/> instance.
/// </summary>
/// <param name="texture">Id of the texture to render.</param>
/// <param name="samplerState">Sampler state.</param>
public GraphicsState(int texture, SamplerState samplerState)
{
Texture = texture;
SamplerState = samplerState;
}
public bool Equals(GraphicsState other)
{
return Texture == other.Texture && SamplerState == other.SamplerState;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is GraphicsState && Equals((GraphicsState) obj);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = Texture;
hashCode = (hashCode * 397) ^ (int) SamplerState;
return hashCode;
}
}
public static bool operator ==(GraphicsState left, GraphicsState right)
{
return left.Equals(right);
}
public static bool operator !=(GraphicsState left, GraphicsState right)
{
return !left.Equals(right);
}
/// <summary>
/// Get the default <see cref="GraphicsState"/>.
/// </summary>
public static GraphicsState Default => new GraphicsState(-1, 0);
}
}