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

◆ Clear() [1/3]

unsafe void Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear ( ClearOptions options,
Color color,
float depth,
int stencil )
inline

Definition at line 1717 of file GraphicsDevice.cs.

1718 {
1719 IntPtr intPtr = (IntPtr)pComPtr;
1720 Helpers.CheckDisposed(this, intPtr);
1721 uint num = 0u;
1722 IDirect3DDevice9* ptr = pComPtr;
1723 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint*, int>)(int)(*(uint*)(*(int*)ptr + 232)))((nint)ptr, (_D3DRENDERSTATETYPE)174, &num);
1724 if (num != 0)
1725 {
1726 ptr = pComPtr;
1727 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)ptr + 228)))((nint)ptr, (_D3DRENDERSTATETYPE)174, 0u);
1728 }
1729 int num2;
1730 int num3;
1732 {
1733 RenderTargetHelper renderTargetHelper = currentRenderTargets[0];
1734 num2 = renderTargetHelper.width;
1735 num3 = renderTargetHelper.height;
1736 }
1737 else
1738 {
1741 }
1742 bool flag = false;
1743 if (currentViewport.X != 0 || currentViewport.Y != 0 || currentViewport.Width != num2 || currentViewport.Height != num3)
1744 {
1745 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DVIEWPORT9 d3DVIEWPORT);
1746 *(int*)(&d3DVIEWPORT) = 0;
1747 System.Runtime.CompilerServices.Unsafe.As<_D3DVIEWPORT9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVIEWPORT, 4)) = 0;
1748 System.Runtime.CompilerServices.Unsafe.As<_D3DVIEWPORT9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVIEWPORT, 8)) = num2;
1749 System.Runtime.CompilerServices.Unsafe.As<_D3DVIEWPORT9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVIEWPORT, 12)) = num3;
1750 System.Runtime.CompilerServices.Unsafe.As<_D3DVIEWPORT9, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVIEWPORT, 16)) = 0f;
1751 System.Runtime.CompilerServices.Unsafe.As<_D3DVIEWPORT9, float>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DVIEWPORT, 20)) = 1f;
1752 ptr = pComPtr;
1753 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DVIEWPORT9*, int>)(int)(*(uint*)(*(int*)ptr + 188)))((nint)ptr, &d3DVIEWPORT);
1754 flag = true;
1755 }
1756 uint num4 = (uint)(color.A << 8);
1757 uint num5 = (color.R | num4) << 8;
1758 uint num6 = (color.G | num5) << 8;
1759 uint num7 = color.B | num6;
1760 IDirect3DDevice9* ptr2 = pComPtr;
1761 int num8 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DRECT*, uint, uint, float, uint, int>)(int)(*(uint*)(*(int*)ptr2 + 172)))((nint)ptr2, 0u, null, (uint)options, num7, depth, (uint)stencil);
1762 if (num != 0)
1763 {
1764 ptr2 = pComPtr;
1765 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DRENDERSTATETYPE, uint, int>)(int)(*(uint*)(*(int*)ptr2 + 228)))((nint)ptr2, (_D3DRENDERSTATETYPE)174, num);
1766 }
1767 if (flag)
1768 {
1769 Viewport viewport = currentViewport;
1770 ptr2 = pComPtr;
1771 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DVIEWPORT9*, int>)(int)(*(uint*)(*(int*)ptr2 + 188)))((nint)ptr2, (_D3DVIEWPORT9*)(int)(ref viewport));
1772 }
1773 if (num8 < 0)
1774 {
1775 ClearOptions clearOptions = options & (ClearOptions.DepthBuffer | ClearOptions.Stencil);
1776 if ((DefaultClearOptions & clearOptions) != clearOptions)
1777 {
1778 throw new InvalidOperationException(FrameworkResources.CannotClearNullDepth);
1779 }
1780 throw GraphicsHelpers.GetExceptionFromResult((uint)num8);
1781 }
1782 int num9 = 0;
1784 {
1785 do
1786 {
1787 currentRenderTargets[num9].pTexture.SetContentLost(isContentLost: false);
1788 num9++;
1789 }
1790 while (num9 < currentRenderTargetCount);
1791 }
1792 lazyClearFlags &= (int)(~options);
1793 }
void SetContentLost([MarshalAs(UnmanagedType.U1)] bool isContentLost)

References Microsoft.Xna.Framework.Color.A, Microsoft.Xna.Framework.Graphics.PresentationParameters.BackBufferHeight, Microsoft.Xna.Framework.Graphics.PresentationParameters.BackBufferWidth, Microsoft.Xna.Framework.FrameworkResources.CannotClearNullDepth, Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentRenderTargetCount, Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentRenderTargets, Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentViewport, Microsoft.Xna.Framework.Graphics.GraphicsDevice.DefaultClearOptions, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.RenderTargetHelper.height, Microsoft.Xna.Framework.Graphics.Viewport.Height, Microsoft.Xna.Framework.Graphics.GraphicsDevice.lazyClearFlags, System.options, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pInternalCachedParams, Microsoft.Xna.Framework.Graphics.RenderTargetHelper.pTexture, Microsoft.Xna.Framework.Graphics.IDynamicGraphicsResource.SetContentLost(), Microsoft.Xna.Framework.Graphics.RenderTargetHelper.width, Microsoft.Xna.Framework.Graphics.Viewport.Width, Microsoft.Xna.Framework.Graphics.Viewport.X, and Microsoft.Xna.Framework.Graphics.Viewport.Y.