Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DepthStencilState.cs
Go to the documentation of this file.
1using System;
5
7
9{
11
13
15
16 internal bool cachedStencilEnable;
17
19
21
23
25
27
29
31
33
35
36 internal int cachedStencilMask;
37
39
41
42 public static readonly DepthStencilState None = new DepthStencilState(depthEnable: false, depthWriteEnable: false, "DepthStencilState.None");
43
44 public static readonly DepthStencilState Default = new DepthStencilState(depthEnable: true, depthWriteEnable: true, "DepthStencilState.Default");
45
46 public static readonly DepthStencilState DepthRead = new DepthStencilState(depthEnable: true, depthWriteEnable: false, "DepthStencilState.DepthRead");
47
48 internal bool isBound;
49
50 internal _D3DCMPFUNC d3dDepthBufferFunction;
51
52 internal _D3DCMPFUNC d3dStencilFunction;
53
54 internal _D3DSTENCILOP d3dStencilPass;
55
56 internal _D3DSTENCILOP d3dStencilFail;
57
58 internal _D3DSTENCILOP d3dStencilDepthBufferFail;
59
61
62 internal _D3DSTENCILOP d3dCounterClockwiseStencilPass;
63
64 internal _D3DSTENCILOP d3dCounterClockwiseStencilFail;
65
67
69 {
70 get
71 {
73 }
74 set
75 {
78 }
79 }
80
82 {
83 get
84 {
86 }
87 set
88 {
91 }
92 }
93
94 public int StencilMask
95 {
96 get
97 {
98 return cachedStencilMask;
99 }
100 set
101 {
102 ThrowIfBound();
104 }
105 }
106
119
121 {
122 get
123 {
125 }
126 set
127 {
128 ThrowIfBound();
130 }
131 }
132
134 {
135 get
136 {
138 }
139 set
140 {
141 ThrowIfBound();
143 }
144 }
145
158
160 {
161 [return: MarshalAs(UnmanagedType.U1)]
162 get
163 {
165 }
166 [param: MarshalAs(UnmanagedType.U1)]
167 set
168 {
169 ThrowIfBound();
171 }
172 }
173
175 {
176 get
177 {
179 }
180 set
181 {
182 ThrowIfBound();
184 }
185 }
186
188 {
189 get
190 {
191 return cachedStencilFail;
192 }
193 set
194 {
195 ThrowIfBound();
197 }
198 }
199
201 {
202 get
203 {
204 return cachedStencilPass;
205 }
206 set
207 {
208 ThrowIfBound();
210 }
211 }
212
214 {
215 get
216 {
218 }
219 set
220 {
221 ThrowIfBound();
223 }
224 }
225
226 public bool StencilEnable
227 {
228 [return: MarshalAs(UnmanagedType.U1)]
229 get
230 {
231 return cachedStencilEnable;
232 }
233 [param: MarshalAs(UnmanagedType.U1)]
234 set
235 {
236 ThrowIfBound();
238 }
239 }
240
242 {
243 get
244 {
246 }
247 set
248 {
249 ThrowIfBound();
251 }
252 }
253
255 {
256 [return: MarshalAs(UnmanagedType.U1)]
257 get
258 {
260 }
261 [param: MarshalAs(UnmanagedType.U1)]
262 set
263 {
264 ThrowIfBound();
266 }
267 }
268
270 {
271 [return: MarshalAs(UnmanagedType.U1)]
272 get
273 {
275 }
276 [param: MarshalAs(UnmanagedType.U1)]
277 set
278 {
279 ThrowIfBound();
281 }
282 }
283
319
321 {
322 try
323 {
324 SetDefaults();
325 isBound = false;
326 return;
327 }
328 catch
329 {
330 //try-fault
331 base.Dispose(true);
332 throw;
333 }
334 }
335
336 private DepthStencilState([MarshalAs(UnmanagedType.U1)] bool depthEnable, [MarshalAs(UnmanagedType.U1)] bool depthWriteEnable, string name)
337 {
338 try
339 {
340 SetDefaults();
341 ThrowIfBound();
342 cachedDepthBufferEnable = depthEnable;
343 ThrowIfBound();
344 cachedDepthBufferWriteEnable = depthWriteEnable;
345 base.Name = name;
346 isBound = true;
347 return;
348 }
349 catch
350 {
351 //try-fault
352 base.Dispose(true);
353 throw;
354 }
355 }
356
358 {
359 }
360
361 internal unsafe void Apply(GraphicsDevice device)
362 {
363 if (isDisposed)
364 {
366 }
367 if (_parent != device)
368 {
369 _parent = device;
370 isBound = true;
371 d3dDepthBufferFunction = _003CModule_003E.ConvertXnaComparisonToDx(cachedDepthBufferFunction);
372 d3dStencilFunction = _003CModule_003E.ConvertXnaComparisonToDx(cachedStencilFunction);
373 d3dStencilPass = _003CModule_003E.ConvertXnaStencilToDx(cachedStencilPass);
374 d3dStencilFail = _003CModule_003E.ConvertXnaStencilToDx(cachedStencilFail);
375 d3dStencilDepthBufferFail = _003CModule_003E.ConvertXnaStencilToDx(cachedStencilDepthBufferFail);
376 d3dCounterClockwiseStencilFunction = _003CModule_003E.ConvertXnaComparisonToDx(cachedCounterClockwiseStencilFunction);
377 d3dCounterClockwiseStencilPass = _003CModule_003E.ConvertXnaStencilToDx(cachedCounterClockwiseStencilPass);
378 d3dCounterClockwiseStencilFail = _003CModule_003E.ConvertXnaStencilToDx(cachedCounterClockwiseStencilFail);
380 }
381 IntPtr pComPtr = (IntPtr)device.pComPtr;
382 Helpers.CheckDisposed(device, pComPtr);
383 IDirect3DDevice9* pComPtr2 = device.pComPtr;
384 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)7, cachedDepthBufferEnable ? 1u : 0u);
385 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)14, cachedDepthBufferWriteEnable ? 1u : 0u);
386 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)23, (uint)d3dDepthBufferFunction);
387 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)52, cachedStencilEnable ? 1u : 0u);
389 {
390 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)56, (uint)d3dStencilFunction);
391 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)55, (uint)d3dStencilPass);
392 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)53, (uint)d3dStencilFail);
393 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)54, (uint)d3dStencilDepthBufferFail);
394 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)185, cachedTwoSidedStencilMode ? 1u : 0u);
396 {
397 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)189, (uint)d3dCounterClockwiseStencilFunction);
398 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)188, (uint)d3dCounterClockwiseStencilPass);
399 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)186, (uint)d3dCounterClockwiseStencilFail);
400 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)187, (uint)d3dCounterClockwiseStencilDepthBufferFail);
401 }
402 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)58, (uint)cachedStencilMask);
403 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)59, (uint)cachedStencilWriteMask);
404 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 228)))((nint)pComPtr2, (_D3DRENDERSTATETYPE)57, (uint)cachedReferenceStencil);
405 }
406 }
407
408 internal void ThrowIfBound()
409 {
410 if (isBound)
411 {
412 throw new InvalidOperationException(string.Format(args: new object[1] { typeof(DepthStencilState).Name }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.BoundStateObject));
413 }
414 }
415
416 [HandleProcessCorruptedStateExceptions]
417 protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
418 {
419 if (P_0)
420 {
421 try
422 {
423 return;
424 }
425 finally
426 {
427 base.Dispose(true);
428 }
429 }
430 base.Dispose(false);
431 }
432}
DepthStencilState([MarshalAs(UnmanagedType.U1)] bool depthEnable, [MarshalAs(UnmanagedType.U1)] bool depthWriteEnable, string name)
override void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
static void CheckDisposed(object obj, IntPtr pComPtr)
Definition Helpers.cs:188
static CultureInfo CurrentCulture