Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ this[int index]

unsafe Texture Microsoft.Xna.Framework.Graphics.TextureCollection.this[int index]
getset

Definition at line 14 of file TextureCollection.cs.

15 {
16 get
17 {
18 IntPtr pComPtr = (IntPtr)_parent.pComPtr;
19 Helpers.CheckDisposed(_parent, pComPtr);
20 if (index >= 0 && index < _maxTextures)
21 {
22 IDirect3DBaseTexture9* ptr = null;
23 IDirect3DTexture9* ptr2 = null;
24 IDirect3DCubeTexture9* ptr3 = null;
25 IDirect3DVolumeTexture9* ptr4 = null;
26 try
27 {
28 IDirect3DDevice9* pComPtr2 = _parent.pComPtr;
29 int num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, IDirect3DBaseTexture9**, int>)(int)(*(uint*)(*(int*)pComPtr2 + 256)))((nint)pComPtr2, (uint)(_textureOffset + index), &ptr);
30 if (num < 0)
31 {
32 throw GraphicsHelpers.GetExceptionFromResult((uint)num);
33 }
34 if (ptr == null)
35 {
36 return null;
37 }
38 int num2;
39 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _GUID*, void**, int>)(int)(*(uint*)(int)(*(uint*)ptr)))((nint)ptr, (_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _003CModule_003E.IID_IDirect3DTexture9), (void**)(&ptr2)) >= 0)
40 {
41 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DSURFACE_DESC d3DSURFACE_DESC);
42 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DSURFACE_DESC*, int>)(int)(*(uint*)(*(int*)ptr2 + 68)))((nint)ptr2, 0u, &d3DSURFACE_DESC);
43 if (num2 >= 0)
44 {
45 return Texture2D.GetManagedObject(ptr2, _parent, System.Runtime.CompilerServices.Unsafe.As<_D3DSURFACE_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DSURFACE_DESC, 12)));
46 }
47 }
48 else if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _GUID*, void**, int>)(int)(*(uint*)(int)(*(uint*)ptr)))((nint)ptr, (_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _003CModule_003E.IID_IDirect3DCubeTexture9), (void**)(&ptr3)) >= 0)
49 {
50 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DSURFACE_DESC d3DSURFACE_DESC2);
51 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DSURFACE_DESC*, int>)(int)(*(uint*)(*(int*)ptr3 + 68)))((nint)ptr3, 0u, &d3DSURFACE_DESC2);
52 if (num2 >= 0)
53 {
54 return TextureCube.GetManagedObject(ptr3, _parent, System.Runtime.CompilerServices.Unsafe.As<_D3DSURFACE_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DSURFACE_DESC2, 12)));
55 }
56 }
57 else
58 {
59 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _GUID*, void**, int>)(int)(*(uint*)(int)(*(uint*)ptr)))((nint)ptr, (_GUID*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref _003CModule_003E.IID_IDirect3DVolumeTexture9), (void**)(&ptr4));
60 if (num2 >= 0)
61 {
62 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DVOLUME_DESC d3DVOLUME_DESC);
63 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DVOLUME_DESC*, int>)(int)(*(uint*)(*(int*)ptr4 + 68)))((nint)ptr4, 0u, &d3DVOLUME_DESC);
64 if (num2 >= 0)
65 {
66 return Texture3D.GetManagedObject(ptr4, _parent, System.Runtime.CompilerServices.Unsafe.As<_D3DVOLUME_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVOLUME_DESC, 12)));
67 }
68 }
69 }
70 throw GraphicsHelpers.GetExceptionFromResult((uint)num2);
71 }
72 finally
73 {
74 if (ptr != null)
75 {
76 IDirect3DBaseTexture9* intPtr = ptr;
77 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr + 8)))((nint)intPtr);
78 ptr = null;
79 }
80 }
81 }
82 throw new ArgumentOutOfRangeException("index");
83 }
84 set
85 {
86 IntPtr pComPtr = (IntPtr)_parent.pComPtr;
87 Helpers.CheckDisposed(_parent, pComPtr);
88 IDirect3DBaseTexture9* ptr = null;
89 if (value != null)
90 {
91 ptr = value.GetComPtr();
92 IntPtr pComPtr2 = (IntPtr)ptr;
93 Helpers.CheckDisposed(value, pComPtr2);
94 if (value.isActiveRenderTarget)
95 {
96 throw new InvalidOperationException(FrameworkResources.MustResolveRenderTarget);
97 }
98 if (_textureOffset > 0 && ((byte*)value.pStateTracker)[16] == 0)
99 {
100 _parent._profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileVertexTextureFormatNotSupported, value.Format);
101 }
102 }
103 if (index >= 0 && index < _maxTextures)
104 {
105 int num = _textureOffset + index;
106 int num2 = ((num < 257) ? num : (num - 241));
107 uint num3 = (uint)(1 << num2);
108 EffectPass activePass = _parent.activePass;
109 if (activePass != null && (activePass._textureFlags & num3) != 0)
110 {
111 activePass.EndPass();
112 _parent.activePass = null;
113 }
114 IDirect3DDevice9* pComPtr3 = _parent.pComPtr;
115 int num4 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, IDirect3DBaseTexture9*, int>)(int)(*(uint*)(*(int*)pComPtr3 + 260)))((nint)pComPtr3, (uint)num, ptr);
116 if (num4 < 0)
117 {
118 if (value != null && value.GraphicsDevice != _parent)
119 {
120 throw new InvalidOperationException(FrameworkResources.InvalidDevice);
121 }
122 throw GraphicsHelpers.GetExceptionFromResult((uint)num4);
123 }
124 StateTrackerDevice* pStateTracker = _parent.pStateTracker;
125 uint num5 = ~num3;
126 if (value != null)
127 {
128 StateTrackerTexture* pStateTracker2 = value.pStateTracker;
129 *(int*)((byte*)pStateTracker + 136) = (*(int*)((byte*)pStateTracker2 + 20) << num2) | (*(int*)((byte*)pStateTracker + 136) & (int)num5);
130 *(int*)((byte*)pStateTracker + 140) = (*(int*)((byte*)pStateTracker2 + 24) << num2) | (*(int*)((byte*)pStateTracker + 140) & (int)num5);
131 }
132 else
133 {
134 *(int*)((byte*)pStateTracker + 136) &= (int)num5;
135 *(int*)((byte*)pStateTracker + 140) &= (int)num5;
136 }
137 return;
138 }
139 throw new ArgumentOutOfRangeException("index");
140 }
141 }