Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DynamicIndexBuffer.cs
Go to the documentation of this file.
1using System;
4
6
8{
9 internal bool _contentLost;
10
11 private EventHandler<EventArgs> _003Cbacking_store_003EContentLost;
12
13 public bool IsContentLost
14 {
15 [return: MarshalAs(UnmanagedType.U1)]
16 get
17 {
18 if (!_contentLost)
19 {
21 }
22 return _contentLost;
23 }
24 }
25
26 [SpecialName]
27 public virtual event EventHandler<EventArgs> ContentLost
28 {
29 [MethodImpl(MethodImplOptions.Synchronized)]
30 add
31 {
33 }
34 [MethodImpl(MethodImplOptions.Synchronized)]
35 remove
36 {
38 }
39 }
40
41 public unsafe DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
42 {
43 try
44 {
45 if (indexCount <= 0)
46 {
48 }
49 _parent = graphicsDevice;
50 uint indexSize = (uint)Marshal.SizeOf(indexType);
51 CreateBuffer((uint)indexCount, indexSize, _003CModule_003E.ConvertXnaBufferUsageToDx(usage) | 0x200u, (_D3DPOOL)0);
53 return;
54 }
55 catch
56 {
57 //try-fault
58 Dispose(true);
59 throw;
60 }
61 }
62
63 public unsafe DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage)
64 {
65 try
66 {
67 if (indexCount <= 0)
68 {
70 }
71 _parent = graphicsDevice;
72 int indexSize = ((indexElementSize == IndexElementSize.SixteenBits) ? 2 : 4);
73 CreateBuffer((uint)indexCount, (uint)indexSize, _003CModule_003E.ConvertXnaBufferUsageToDx(usage) | 0x200u, (_D3DPOOL)0);
75 return;
76 }
77 catch
78 {
79 //try-fault
80 Dispose(true);
81 throw;
82 }
83 }
84
85 public void SetData<T>(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
86 {
87 SetData(0, data, startIndex, elementCount, options);
88 }
89
90 public void SetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
91 {
92 CopyData(offsetInBytes, data, startIndex, elementCount, _003CModule_003E.ConvertXnaSetDataOptionsToDx(options), isSetting: true);
93 }
94
95 internal override int SaveDataForRecreation()
96 {
97 return 0;
98 }
99
101 {
102 //ILSpy generated this explicit interface implementation from .override directive in SaveDataForRecreation
103 return this.SaveDataForRecreation();
104 }
105
106 internal unsafe override int RecreateAndPopulateObject()
107 {
108 if (pComPtr != null)
109 {
110 return -2147467259;
111 }
112 if (_bufferSize == 0)
113 {
114 return -2147467259;
115 }
116 fixed (IDirect3DIndexBuffer9** ptr2 = &pComPtr)
117 {
118 _D3DFORMAT d3DFORMAT = ((_indexSize == 4) ? ((_D3DFORMAT)102) : ((_D3DFORMAT)101));
119 GraphicsDevice parent = _parent;
120 IDirect3DDevice9* ptr = parent.pComPtr;
121 GraphicsDevice graphicsDevice = parent;
122 int num = *(int*)ptr + 108;
123 int num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, _D3DFORMAT, _D3DPOOL, IDirect3DIndexBuffer9**, void**, int>)(int)(*(uint*)num))((nint)ptr, _bufferSize, graphicsDevice.GetBufferUsage(_usage) | 0x200u, d3DFORMAT, (_D3DPOOL)0, ptr2, null);
124 if (num2 >= 0)
125 {
127 }
128 return num2;
129 }
130 }
131
133 {
134 //ILSpy generated this explicit interface implementation from .override directive in RecreateAndPopulateObject
135 return this.RecreateAndPopulateObject();
136 }
137
138 internal virtual void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
139 {
140 _contentLost = isContentLost;
141 if (isContentLost)
142 {
144 }
145 }
146
147 void IDynamicGraphicsResource.SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
148 {
149 //ILSpy generated this explicit interface implementation from .override directive in SetContentLost
150 this.SetContentLost(isContentLost);
151 }
152
153 [SpecialName]
154 protected virtual void raise_ContentLost(object value0, EventArgs value1)
155 {
156 _003Cbacking_store_003EContentLost?.Invoke(value0, value1);
157 }
158}
unsafe void AddTrackedObject(object managedObject, void *pComPtr, uint resourceManagementMode, ulong handle, ref ulong updatedHandle)
unsafe DynamicIndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
virtual void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
unsafe DynamicIndexBuffer(GraphicsDevice graphicsDevice, IndexElementSize indexElementSize, int indexCount, BufferUsage usage)
virtual void raise_ContentLost(object value0, EventArgs value1)
void SetData< T >(T[] data, int startIndex, int elementCount, SetDataOptions options)
unsafe void CreateBuffer(uint indexCount, uint indexSize, uint usage, _D3DPOOL pool)
unsafe IDirect3DIndexBuffer9 * pComPtr
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static ? Delegate Combine(Delegate? a, Delegate? b)
Definition Delegate.cs:379
static readonly EventArgs Empty
Definition EventArgs.cs:9
static int SizeOf(object structure)
Definition Marshal.cs:697
void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)