Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DynamicVertexBuffer.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 DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsage usage)
42 {
43 try
44 {
45 VertexDeclaration vertexDeclaration = VertexDeclaration.FromType(vertexType);
46 if (vertexCount <= 0)
47 {
49 }
50 _parent = graphicsDevice;
51 CreateBuffer(vertexDeclaration, (uint)vertexCount, _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 DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
64 {
65 try
66 {
67 if (vertexDeclaration == null)
68 {
69 throw new ArgumentNullException("vertexDeclaration", FrameworkResources.NullNotAllowed);
70 }
71 if (vertexCount <= 0)
72 {
74 }
75 _parent = graphicsDevice;
76 CreateBuffer(vertexDeclaration, (uint)vertexCount, _003CModule_003E.ConvertXnaBufferUsageToDx(usage) | 0x200u, (_D3DPOOL)0);
78 return;
79 }
80 catch
81 {
82 //try-fault
83 Dispose(true);
84 throw;
85 }
86 }
87
88 public void SetData<T>(T[] data, int startIndex, int elementCount, SetDataOptions options) where T : struct
89 {
90 SetData(0, data, startIndex, elementCount, 0, options);
91 }
92
93 public void SetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount, int vertexStride, SetDataOptions options) where T : struct
94 {
95 CopyData(offsetInBytes, data, startIndex, elementCount, vertexStride, _003CModule_003E.ConvertXnaSetDataOptionsToDx(options), isSetting: true);
96 }
97
98 internal override int SaveDataForRecreation()
99 {
100 return 0;
101 }
102
104 {
105 //ILSpy generated this explicit interface implementation from .override directive in SaveDataForRecreation
106 return this.SaveDataForRecreation();
107 }
108
109 internal unsafe override int RecreateAndPopulateObject()
110 {
111 if (pComPtr != null)
112 {
113 return -2147467259;
114 }
115 if (_size == 0)
116 {
117 return -2147467259;
118 }
119 fixed (IDirect3DVertexBuffer9** ptr2 = &pComPtr)
120 {
121 GraphicsDevice parent = _parent;
122 IDirect3DDevice9* ptr = parent.pComPtr;
123 GraphicsDevice graphicsDevice = parent;
124 int num = *(int*)ptr + 104;
125 int num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, uint, _D3DPOOL, IDirect3DVertexBuffer9**, void**, int>)(int)(*(uint*)num))((nint)ptr, _size, graphicsDevice.GetBufferUsage(_usage) | 0x200u, 0u, (_D3DPOOL)0, ptr2, null);
126 if (num2 >= 0)
127 {
129 }
130 return num2;
131 }
132 }
133
135 {
136 //ILSpy generated this explicit interface implementation from .override directive in RecreateAndPopulateObject
137 return this.RecreateAndPopulateObject();
138 }
139
140 internal virtual void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
141 {
142 _contentLost = isContentLost;
143 if (isContentLost)
144 {
146 }
147 }
148
149 void IDynamicGraphicsResource.SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
150 {
151 //ILSpy generated this explicit interface implementation from .override directive in SetContentLost
152 this.SetContentLost(isContentLost);
153 }
154
155 [SpecialName]
156 protected virtual void raise_ContentLost(object value0, EventArgs value1)
157 {
158 _003Cbacking_store_003EContentLost?.Invoke(value0, value1);
159 }
160}
unsafe void AddTrackedObject(object managedObject, void *pComPtr, uint resourceManagementMode, ulong handle, ref ulong updatedHandle)
unsafe DynamicVertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
void SetData< T >(T[] data, int startIndex, int elementCount, SetDataOptions options)
virtual void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)
virtual void raise_ContentLost(object value0, EventArgs value1)
unsafe DynamicVertexBuffer(GraphicsDevice graphicsDevice, Type vertexType, int vertexCount, BufferUsage usage)
unsafe IDirect3DVertexBuffer9 * pComPtr
unsafe void CreateBuffer(VertexDeclaration vertexDeclaration, uint dwVertexCount, uint usage, _D3DPOOL pool)
static VertexDeclaration FromType(Type vertexType)
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
void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)