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

◆ CreateBuffer()

unsafe void Microsoft.Xna.Framework.Graphics.IndexBuffer.CreateBuffer ( uint indexCount,
uint indexSize,
uint usage,
_D3DPOOL pool )
inlineprotected

Definition at line 238 of file IndexBuffer.cs.

239 {
240 isDisposed = false;
241 _D3DFORMAT d3DFORMAT;
242 if (indexSize == 4)
243 {
244 d3DFORMAT = (_D3DFORMAT)102;
246 {
247 _parent._profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileNoIndexElementSize32);
248 }
249 }
250 else
251 {
252 if (indexSize != 2)
253 {
254 throw new ArgumentException(FrameworkResources.IndexBuffersMustBeSizedCorrectly);
255 }
256 d3DFORMAT = (_D3DFORMAT)101;
257 }
258 uint num = (_bufferSize = indexCount * indexSize);
259 int maxIndexBufferSize = _parent._profileCapabilities.MaxIndexBufferSize;
260 if (num > (uint)maxIndexBufferSize)
261 {
262 _parent._profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileTooBig, typeof(IndexBuffer).Name, maxIndexBufferSize);
263 }
264 fixed (IDirect3DIndexBuffer9** ptr = &pComPtr)
265 {
266 int num2 = *(int*)_parent.pComPtr + 108;
267 int num3 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, _D3DFORMAT, _D3DPOOL, IDirect3DIndexBuffer9**, void**, int>)(int)(*(uint*)num2))((nint)_parent.pComPtr, _bufferSize, _parent.GetBufferUsage(usage), d3DFORMAT, pool, ptr, null);
268 if (num3 < 0)
269 {
270 throw GraphicsHelpers.GetExceptionFromResult((uint)num3);
271 }
272 _usage = usage;
273 _indexCount = indexCount;
274 _indexSize = indexSize;
275 _pool = (uint)pool;
276 if ((usage & 8) == 8 && pool == (_D3DPOOL)1 && (pBufferData = _003CModule_003E.new_005B_005D(_bufferSize)) == null)
277 {
278 throw new InsufficientMemoryException();
279 }
280 }
281 }
unsafe IDirect3DIndexBuffer9 * pComPtr

References Microsoft.Xna.Framework.Graphics.IndexBuffer._bufferSize, Microsoft.Xna.Framework.Graphics.IndexBuffer._indexCount, Microsoft.Xna.Framework.Graphics.IndexBuffer._indexSize, Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, Microsoft.Xna.Framework.Graphics.IndexBuffer._pool, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.Graphics.IndexBuffer._usage, Microsoft.Xna.Framework.Graphics.GraphicsDevice.GetBufferUsage(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.FrameworkResources.IndexBuffersMustBeSizedCorrectly, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.IndexElementSize32, Microsoft.Xna.Framework.Graphics.GraphicsResource.isDisposed, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxIndexBufferSize, Microsoft.Xna.Framework.Graphics.IndexBuffer.pBufferData, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.IndexBuffer.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ProfileNoIndexElementSize32, Microsoft.Xna.Framework.FrameworkResources.ProfileTooBig, and Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException().

Referenced by Microsoft.Xna.Framework.Graphics.DynamicIndexBuffer.DynamicIndexBuffer(), Microsoft.Xna.Framework.Graphics.DynamicIndexBuffer.DynamicIndexBuffer(), Microsoft.Xna.Framework.Graphics.IndexBuffer.IndexBuffer(), and Microsoft.Xna.Framework.Graphics.IndexBuffer.IndexBuffer().