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

◆ DrawUserIndexedPrimitives< T >() [1/5]

unsafe void Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserIndexedPrimitives< T > ( PrimitiveType primitiveType,
T[] vertexData,
int vertexOffset,
int numVertices,
Array indexData,
int indexOffset,
int primitiveCount,
VertexDeclaration vertexDeclaration,
_D3DFORMAT indexFormat )
inlineprivate
Type Constraints
T :struct 

Definition at line 1578 of file GraphicsDevice.cs.

1578 : struct
1579 {
1580 IntPtr intPtr = (IntPtr)pComPtr;
1581 Helpers.CheckDisposed(this, intPtr);
1582 if (vertexData != null && vertexData.Length != 0)
1583 {
1584 if (indexData != null && indexData.Length != 0)
1585 {
1586 if (vertexDeclaration == null)
1587 {
1588 throw new ArgumentNullException("vertexDeclaration", FrameworkResources.NullNotAllowed);
1589 }
1590 if (numVertices <= 0)
1591 {
1592 throw new ArgumentOutOfRangeException("numVertices", FrameworkResources.NumberVerticesMustBeGreaterZero);
1593 }
1594 if (primitiveCount <= 0)
1595 {
1596 throw new ArgumentOutOfRangeException("primitiveCount", FrameworkResources.MustDrawSomething);
1597 }
1598 int maxPrimitiveCount = _profileCapabilities.MaxPrimitiveCount;
1599 if (primitiveCount > maxPrimitiveCount)
1600 {
1601 _profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileMaxPrimitiveCount, maxPrimitiveCount);
1602 }
1603 if (vertexOffset >= 0 && vertexOffset < (nint)vertexData.LongLength)
1604 {
1605 if (indexOffset >= 0 && indexOffset < indexData.Length)
1606 {
1607 if ((uint)((int)GetElementCountFromPrimitiveType(primitiveType, primitiveCount) + indexOffset) > (uint)indexData.Length)
1608 {
1609 throw new ArgumentOutOfRangeException("primitiveCount", FrameworkResources.MustBeValidIndex);
1610 }
1611 if (vertexOffset + numVertices > (nint)vertexData.LongLength)
1612 {
1613 throw new ArgumentOutOfRangeException("vertexData", FrameworkResources.MustBeValidIndex);
1614 }
1615 BeginUserPrimitives(vertexDeclaration);
1616 VerifyCanDraw(bUserPrimitives: true, bIndexedPrimitives: true);
1617 GCHandle gCHandle = GCHandle.Alloc(indexData, GCHandleType.Pinned);
1618 try
1619 {
1620 fixed (T* ptr2 = &vertexData[vertexOffset])
1621 {
1622 try
1623 {
1624 void* ptr = Marshal.UnsafeAddrOfPinnedArrayElement(indexData, indexOffset).ToPointer();
1625 int num = *(int*)pComPtr + 336;
1626 int num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DPRIMITIVETYPE, uint, uint, uint, void*, _D3DFORMAT, void*, uint, int>)(int)(*(uint*)num))((nint)pComPtr, _003CModule_003E.ConvertXnaPrimitiveTypeToDx(primitiveType), 0u, (uint)numVertices, (uint)primitiveCount, ptr, indexFormat, ptr2, (uint)System.Runtime.CompilerServices.Unsafe.SizeOf<T>());
1627 if (num2 >= 0)
1628 {
1629 return;
1630 }
1631 throw GraphicsHelpers.GetExceptionFromResult((uint)num2);
1632 }
1633 catch
1634 {
1635 //try-fault
1636 ptr2 = null;
1637 throw;
1638 }
1639 }
1640 }
1641 finally
1642 {
1643 if (gCHandle.IsAllocated)
1644 {
1645 gCHandle.Free();
1646 }
1647 _currentIB = null;
1648 }
1649 }
1650 throw new ArgumentOutOfRangeException("indexOffset", FrameworkResources.OffsetNotValid);
1651 }
1652 throw new ArgumentOutOfRangeException("vertexOffset", FrameworkResources.OffsetNotValid);
1653 }
1654 throw new ArgumentNullException("indexData", FrameworkResources.NullNotAllowed);
1655 }
1656 throw new ArgumentNullException("vertexData", FrameworkResources.NullNotAllowed);
1657 }
unsafe void BeginUserPrimitives(VertexDeclaration vertexDeclaration)
uint GetElementCountFromPrimitiveType(PrimitiveType primitiveType, int primitiveCount)
unsafe void VerifyCanDraw([MarshalAs(UnmanagedType.U1)] bool bUserPrimitives, [MarshalAs(UnmanagedType.U1)] bool bIndexedPrimitives)
int Length
Definition Array.cs:430
static unsafe IntPtr UnsafeAddrOfPinnedArrayElement(Array arr, int index)
Definition Marshal.cs:775
static GCHandle Alloc(object? value)
Definition GCHandle.cs:81

References Microsoft.Xna.Framework.Graphics.GraphicsDevice._currentIB, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, System.Runtime.InteropServices.GCHandle.Alloc(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.BeginUserPrimitives(), Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.GetElementCountFromPrimitiveType(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.ProfileCapabilities.MaxPrimitiveCount, Microsoft.Xna.Framework.FrameworkResources.MustBeValidIndex, Microsoft.Xna.Framework.FrameworkResources.MustDrawSomething, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, Microsoft.Xna.Framework.FrameworkResources.NumberVerticesMustBeGreaterZero, Microsoft.Xna.Framework.FrameworkResources.OffsetNotValid, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.FrameworkResources.ProfileMaxPrimitiveCount, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(), and Microsoft.Xna.Framework.Graphics.GraphicsDevice.VerifyCanDraw().