public static IDepthStencilState New(VideoTypes videoType, IDisposableResource parent, IDepthStencilStateDesc desc) { IDepthStencilState api = null; #if WIN32 if (videoType == VideoTypes.D3D9) api = new D3D9.DepthStencilState(parent, desc); #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) api = new D3D11.DepthStencilState(parent, desc); #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) api = new OpenGL.DepthStencilState(parent, desc); #endif #if XNA if (videoType == VideoTypes.XNA) api = new XNA.DepthStencilState(parent, desc); #endif #if VITA if (videoType == VideoTypes.Vita) api = new Vita.DepthStencilState(parent, desc); #endif if (api == null) Debug.ThrowError("DepthStencilStateAPI", "Unsuported InputType: " + videoType); return api; }
public static IDepthStencilState New(VideoTypes videoType, IDisposableResource parent, IDepthStencilStateDesc desc) { IDepthStencilState api = null; #if WIN32 if (videoType == VideoTypes.D3D9) { api = new D3D9.DepthStencilState(parent, desc); } #endif #if WIN32 || WINRT || WP8 if (videoType == VideoTypes.D3D11) { api = new D3D11.DepthStencilState(parent, desc); } #endif #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl if (videoType == VideoTypes.OpenGL) { api = new OpenGL.DepthStencilState(parent, desc); } #endif #if XNA if (videoType == VideoTypes.XNA) { api = new XNA.DepthStencilState(parent, desc); } #endif #if VITA if (videoType == VideoTypes.Vita) { api = new Vita.DepthStencilState(parent, desc); } #endif if (api == null) { Debug.ThrowError("DepthStencilStateAPI", "Unsuported InputType: " + videoType); } return(api); }
public void Resize() { m_RenderTargetView?.Dispose(); m_DepthStencilView?.Dispose(); m_DepthBuffer?.Dispose(); m_Backbuffer?.Dispose(); D2DRenderTarget?.Dispose(); SwapChain.ResizeBuffers(1, m_ApplicationInfo.Width, m_ApplicationInfo.Height, DXGI.Format.R8G8B8A8_UNorm, DXGI.SwapChainFlags.None); m_Backbuffer = SwapChain.GetBackBuffer <D3D11.Texture2D>(0); m_RenderTargetView = new D3D11.RenderTargetView(Dev, m_Backbuffer); var d2dRenderTargetProps = new D2D1.RenderTargetProperties { PixelFormat = new D2D1.PixelFormat(DXGI.Format.Unknown, D2D1.AlphaMode.Premultiplied), Type = D2D1.RenderTargetType.Default, DpiX = D2DFactory.DesktopDpi.Width, DpiY = D2DFactory.DesktopDpi.Height }; DXGI.Surface2 backBuffer = SwapChain.GetBackBuffer <DXGI.Surface2>(0); D2DRenderTarget = new D2D1.RenderTarget(D2DFactory, backBuffer, d2dRenderTargetProps); backBuffer.Dispose(); var depthBufferDesc = new D3D11.Texture2DDescription { Format = DXGI.Format.D32_Float_S8X24_UInt, ArraySize = 1, MipLevels = 1, Width = m_Backbuffer.Description.Width, Height = m_Backbuffer.Description.Height, SampleDescription = SwapChain.Description.SampleDescription, BindFlags = D3D11.BindFlags.DepthStencil, }; m_Backbuffer.Dispose(); var depthStencilViewDesc = new D3D11.DepthStencilViewDescription { Dimension = SwapChain.Description.SampleDescription.Count > 1 || SwapChain.Description.SampleDescription.Quality > 0 ? D3D11.DepthStencilViewDimension.Texture2DMultisampled : D3D11.DepthStencilViewDimension.Texture2D }; var depthStencilStateDesc = new D3D11.DepthStencilStateDescription { IsDepthEnabled = true, DepthComparison = D3D11.Comparison.Less, DepthWriteMask = D3D11.DepthWriteMask.All, IsStencilEnabled = false, StencilReadMask = 0xff, StencilWriteMask = 0xff, FrontFace = new D3D11.DepthStencilOperationDescription { Comparison = D3D11.Comparison.Always, PassOperation = D3D11.StencilOperation.Keep, FailOperation = D3D11.StencilOperation.Keep, DepthFailOperation = D3D11.StencilOperation.Increment }, BackFace = new D3D11.DepthStencilOperationDescription { Comparison = D3D11.Comparison.Always, PassOperation = D3D11.StencilOperation.Keep, FailOperation = D3D11.StencilOperation.Keep, DepthFailOperation = D3D11.StencilOperation.Decrement } }; m_DepthBuffer = new D3D11.Texture2D(Dev, depthBufferDesc); m_DepthStencilView = new D3D11.DepthStencilView(Dev, m_DepthBuffer, depthStencilViewDesc); m_DepthStencilState = new D3D11.DepthStencilState(Dev, depthStencilStateDesc); SetRenderTargets(m_DepthStencilView, m_RenderTargetView); DevCon.OutputMerger.DepthStencilState = m_DepthStencilState; m_ScreenViewport.X = 0; m_ScreenViewport.Y = 0; m_ScreenViewport.Width = m_ApplicationInfo.Width; m_ScreenViewport.Height = m_ApplicationInfo.Height; m_ScreenViewport.MinDepth = 0.0f; m_ScreenViewport.MaxDepth = 1.0f; DevCon.Rasterizer.SetViewport(m_ScreenViewport); }