Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RgbDevice.cs
Go to the documentation of this file.
3
5
6public abstract class RgbDevice
7{
8 public readonly RgbDeviceType Type;
9
10 public readonly RgbDeviceVendor Vendor;
11
12 private readonly Fragment _backBuffer;
13
14 private readonly Fragment _workingFragment;
15
17
18 public EffectDetailLevel PreferredLevelOfDetail { get; protected set; }
19
20 public int LedCount => _backBuffer.Count;
21
22 protected RgbDevice(RgbDeviceVendor vendor, RgbDeviceType type, Fragment fragment, DeviceColorProfile colorProfile)
23 {
25 Vendor = vendor;
26 Type = type;
27 _backBuffer = fragment;
28 _workingFragment = fragment.CreateCopy();
29 _colorProfile = colorProfile;
30 }
31
32 public virtual Fragment Rasterize()
33 {
34 return _workingFragment;
35 }
36
37 protected Vector4 GetProcessedLedColor(int index)
38 {
39 //IL_000c: Unknown result type (might be due to invalid IL or missing references)
40 //IL_0011: Unknown result type (might be due to invalid IL or missing references)
41 //IL_001f: Unknown result type (might be due to invalid IL or missing references)
42 Vector4 color = _backBuffer.Colors[index];
43 _colorProfile.Apply(ref color);
44 return color;
45 }
46
47 protected Vector4 GetUnprocessedLedColor(int index)
48 {
49 //IL_000c: Unknown result type (might be due to invalid IL or missing references)
50 return _backBuffer.Colors[index];
51 }
52
53 protected Color ProcessLedColor(Color color)
54 {
55 //IL_0002: Unknown result type (might be due to invalid IL or missing references)
56 //IL_0007: Unknown result type (might be due to invalid IL or missing references)
57 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
58 //IL_0016: Unknown result type (might be due to invalid IL or missing references)
59 Vector3 color2 = ((Color)(ref color)).ToVector3();
60 _colorProfile.Apply(ref color2);
61 return new Color(color2);
62 }
63
64 public void SetLedColor(int index, Vector4 color)
65 {
66 //IL_000c: Unknown result type (might be due to invalid IL or missing references)
67 //IL_000d: Unknown result type (might be due to invalid IL or missing references)
68 _backBuffer.Colors[index] = color;
69 }
70
71 public Vector2 GetLedCanvasPosition(int index)
72 {
73 //IL_0007: Unknown result type (might be due to invalid IL or missing references)
75 }
76
77 public Point GetLedGridPosition(int index)
78 {
79 //IL_0007: Unknown result type (might be due to invalid IL or missing references)
81 }
82
83 public virtual void Render(Fragment fragment, ShaderBlendState blendState)
84 {
85 //IL_008b: Unknown result type (might be due to invalid IL or missing references)
86 //IL_0097: Unknown result type (might be due to invalid IL or missing references)
87 //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
88 //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
89 //IL_00d1: Unknown result type (might be due to invalid IL or missing references)
90 //IL_00d6: Unknown result type (might be due to invalid IL or missing references)
91 //IL_002e: Unknown result type (might be due to invalid IL or missing references)
92 //IL_003a: Unknown result type (might be due to invalid IL or missing references)
93 //IL_0057: Unknown result type (might be due to invalid IL or missing references)
94 //IL_005c: Unknown result type (might be due to invalid IL or missing references)
95 switch (blendState.Mode)
96 {
97 case BlendMode.PerPixelOpacity:
98 {
99 for (int j = 0; j < fragment.Count; j++)
100 {
101 _backBuffer.Colors[j] = Vector4.Lerp(_backBuffer.Colors[j], fragment.Colors[j], blendState.GlobalOpacity * fragment.Colors[j].W);
102 }
103 break;
104 }
105 case BlendMode.GlobalOpacityOnly:
106 {
107 for (int k = 0; k < fragment.Count; k++)
108 {
109 _backBuffer.Colors[k] = Vector4.Lerp(_backBuffer.Colors[k], fragment.Colors[k], blendState.GlobalOpacity);
110 }
111 break;
112 }
113 default:
114 {
115 for (int i = 0; i < fragment.Count; i++)
116 {
117 _backBuffer.Colors[i] = fragment.Colors[i];
118 }
119 break;
120 }
121 }
122 }
123
124 public abstract void Present();
125
126 public virtual void DebugDraw(IDebugDrawer drawer, Vector2 position, float scale)
127 {
128 //IL_000e: Unknown result type (might be due to invalid IL or missing references)
129 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
130 //IL_0020: Unknown result type (might be due to invalid IL or missing references)
131 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
132 //IL_002f: Unknown result type (might be due to invalid IL or missing references)
133 //IL_0040: Unknown result type (might be due to invalid IL or missing references)
134 //IL_0051: Unknown result type (might be due to invalid IL or missing references)
135 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
136 //IL_005c: Unknown result type (might be due to invalid IL or missing references)
137 //IL_0061: Unknown result type (might be due to invalid IL or missing references)
138 //IL_0062: Unknown result type (might be due to invalid IL or missing references)
139 //IL_0075: Unknown result type (might be due to invalid IL or missing references)
140 //IL_007a: Unknown result type (might be due to invalid IL or missing references)
141 //IL_007b: Unknown result type (might be due to invalid IL or missing references)
142 for (int i = 0; i < LedCount; i++)
143 {
144 Vector2 canvasPositionOfIndex = _backBuffer.GetCanvasPositionOfIndex(i);
145 Vector4 vector = _backBuffer.Colors[i];
146 vector.X *= vector.W;
147 vector.Y *= vector.W;
148 vector.Z *= vector.W;
149 drawer.DrawSquare(new Vector4(canvasPositionOfIndex * scale + position, scale / 10f, scale / 10f), new Color(vector));
150 }
151 }
152}
Point GetGridPositionOfIndex(int index)
Definition Fragment.cs:81
readonly Vector4[] Colors
Definition Fragment.cs:8
Vector2 GetCanvasPositionOfIndex(int index)
Definition Fragment.cs:75
Color ProcessLedColor(Color color)
Definition RgbDevice.cs:53
Vector4 GetProcessedLedColor(int index)
Definition RgbDevice.cs:37
readonly Fragment _workingFragment
Definition RgbDevice.cs:14
Vector2 GetLedCanvasPosition(int index)
Definition RgbDevice.cs:71
virtual Fragment Rasterize()
Definition RgbDevice.cs:32
Vector4 GetUnprocessedLedColor(int index)
Definition RgbDevice.cs:47
void SetLedColor(int index, Vector4 color)
Definition RgbDevice.cs:64
virtual void DebugDraw(IDebugDrawer drawer, Vector2 position, float scale)
Definition RgbDevice.cs:126
Point GetLedGridPosition(int index)
Definition RgbDevice.cs:77
RgbDevice(RgbDeviceVendor vendor, RgbDeviceType type, Fragment fragment, DeviceColorProfile colorProfile)
Definition RgbDevice.cs:22
readonly DeviceColorProfile _colorProfile
Definition RgbDevice.cs:16
EffectDetailLevel PreferredLevelOfDetail
Definition RgbDevice.cs:18
virtual void Render(Fragment fragment, ShaderBlendState blendState)
Definition RgbDevice.cs:83
readonly RgbDeviceType Type
Definition RgbDevice.cs:8
readonly RgbDeviceVendor Vendor
Definition RgbDevice.cs:10
readonly Fragment _backBuffer
Definition RgbDevice.cs:12
void DrawSquare(Vector4 positionAndSize, Color color)
static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
Definition Vector4.cs:277