Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SavedDeviceState.cs
Go to the documentation of this file.
2
4
5internal class SavedDeviceState
6{
8
10
12
13 private Texture[] textures;
14
16
18
20
22
24
25 private int multiSampleMask;
26
28
29 private int referenceStencil;
30
32
34
36
37 public SavedDeviceState(GraphicsDevice device, [MarshalAs(UnmanagedType.U1)] bool saveViewport)
38 {
39 this.device = device;
40 base._002Ector();
43 int maxSamplers = device._profileCapabilities.MaxSamplers;
44 textures = new Texture[maxSamplers];
45 samplerStates = new SamplerState[maxSamplers];
46 int num = 0;
47 if (0 < maxSamplers)
48 {
49 do
50 {
51 textures[num] = device.Textures[num];
53 num++;
54 }
55 while (num < maxSamplers);
56 }
57 int maxVertexSamplers = device._profileCapabilities.MaxVertexSamplers;
58 vertexTextures = new Texture[maxVertexSamplers];
59 vertexSamplerStates = new SamplerState[maxVertexSamplers];
60 int num2 = 0;
61 if (0 < maxVertexSamplers)
62 {
63 do
64 {
67 num2++;
68 }
69 while (num2 < maxVertexSamplers);
70 }
72 Color color = device.BlendFactor;
73 blendFactor = color;
78 if (saveViewport)
79 {
81 this.viewport = viewport;
83 scissorRectangle = rectangle;
84 }
85 }
86
87 public void Restore()
88 {
90 device.Indices = indices;
91 int num = 0;
92 GraphicsDevice graphicsDevice = device;
93 if (0 < graphicsDevice._profileCapabilities.MaxSamplers)
94 {
95 do
96 {
97 Texture[] array = textures;
98 if (array[num] != null)
99 {
100 graphicsDevice.Textures[num] = array[num];
101 }
102 SamplerState[] array2 = samplerStates;
103 if (array2[num] != null)
104 {
105 device.SamplerStates[num] = array2[num];
106 }
107 num++;
108 graphicsDevice = device;
109 }
110 while (num < graphicsDevice._profileCapabilities.MaxSamplers);
111 }
112 int num2 = 0;
113 GraphicsDevice graphicsDevice2 = device;
114 if (0 < graphicsDevice2._profileCapabilities.MaxVertexSamplers)
115 {
116 do
117 {
118 Texture[] array3 = vertexTextures;
119 if (array3[num2] != null)
120 {
121 graphicsDevice2.VertexTextures[num2] = array3[num2];
122 }
124 if (array4[num2] != null)
125 {
126 device.VertexSamplerStates[num2] = array4[num2];
127 }
128 num2++;
129 graphicsDevice2 = device;
130 }
131 while (num2 < graphicsDevice2._profileCapabilities.MaxVertexSamplers);
132 }
134 if (blendState != null)
135 {
136 device.BlendState = blendState;
137 device.BlendFactor = blendFactor;
138 device.MultiSampleMask = multiSampleMask;
139 }
141 if (depthStencilState != null)
142 {
143 device.DepthStencilState = depthStencilState;
144 device.ReferenceStencil = referenceStencil;
145 }
147 if (rasterizerState != null)
148 {
149 device.RasterizerState = rasterizerState;
150 }
151 if (viewport.HasValue)
152 {
153 Viewport value = viewport.Value;
154 device.Viewport = value;
155 }
156 if (scissorRectangle.HasValue)
157 {
158 Rectangle value2 = scissorRectangle.Value;
159 device.ScissorRectangle = value2;
160 }
161 }
162}
unsafe void SetVertexBuffers(VertexBufferBinding *pBindings, int vertexBufferCount)
SavedDeviceState(GraphicsDevice device, [MarshalAs(UnmanagedType.U1)] bool saveViewport)