internal void Clear(DepthStencilClearFlags clearFlags, float depth, byte stencil) { if (clearFlags.HasFlag(DepthStencilClearFlags.Depth)) { _innerView.Clear(depth); } }
public void Clear(ClearOptions clearOptions, Color color, float depth, byte stencil) { if (clearOptions.HasFlag(ClearOptions.Color)) { Clear(color); } if (depth < 0 || depth > 1) { throw new ArgumentOutOfRangeException("Depth must be between 0 and 1", "depth"); } DepthStencilClearFlags clearFlags = 0; if (clearOptions.HasFlag(ClearOptions.Depth)) { clearFlags |= DepthStencilClearFlags.Depth; } if (clearOptions.HasFlag(ClearOptions.Stencil)) { clearFlags |= DepthStencilClearFlags.Stencil; } if (clearFlags != 0) { if (currentDepthTarget == null) { throw new InvalidOperationException("No render target set for depth."); } Context.ClearDepthStencilView(currentDepthTarget, clearFlags, depth, stencil); } }
internal void ClearDsv(IDepthStencil ds, DepthStencilClearFlags clearFlags, float depth, byte stencil) { IDepthStencilInternal dsInternal = (IDepthStencilInternal)ds; m_deviceContext.ClearDepthStencilView(dsInternal.Dsv, clearFlags, depth, stencil); CheckErrors(); }
/// <summary> /// 深度ステンシル リソースをクリアします。 /// </summary> /// <param name="clearFlags">クリアするデータの型を特定します (「D3D11_CLEAR_FLAG」を参照してください)。</param> /// <param name="depth">この値で深度バッファーをクリアします。この値は、0 ~ 1 の範囲にクランプされます。</param> /// <param name="stencil">この値でステンシル バッファーをクリアします。</param> public void ClearDepthStencilView(DepthStencilClearFlags flag = DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, float depth = 1.0f, byte stencil = 0) { if (m_depthStencilView == null) { Debug.Assert(false); throw new NotCreatedException(); } App.ImmediateContext.ClearDepthStencilView(m_depthStencilView, flag, depth, stencil); }
public static void ClearDepth(LayerSettings settings, bool depth, float depthValue, bool stencil, byte stencilValue) { var stackelement = settings.RenderContext.RenderTargetStack.Peek(); if (stackelement.DepthStencil != null && depth || stencil) { DepthStencilClearFlags flags = 0; flags |= depth ? DepthStencilClearFlags.Depth : flags; flags |= stencil ? DepthStencilClearFlags.Stencil : flags; settings.RenderContext.Context.ClearDepthStencilView(stackelement.DepthStencil.DepthView, flags, depthValue, stencilValue); } }
public void SetRenderTarget(DepthStencilView dsv, RenderTargetView rtv, bool clearRTV, Color4 color, bool clearDSV, DepthStencilClearFlags flags = DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, float depth = 1, byte stencil = 0) { if (clearRTV && rtv != null) { ClearRenderTargetView(rtv, color); } if (clearDSV && dsv != null) { ClearDepthStencilView(dsv, flags, depth, stencil); } SetRenderTarget(dsv, rtv); }
public void Clear(bool cleardepth = true, bool clearstencil = true, float depth = 1.0f, byte stencil = 0) { if (cleardepth || clearstencil) { DepthStencilClearFlags flags = (DepthStencilClearFlags)0; if (cleardepth) { flags = DepthStencilClearFlags.Depth; } if (clearstencil) { flags |= DepthStencilClearFlags.Stencil; } this.context.CurrentDeviceContext.ClearDepthStencilView(this.DSV, flags, depth, stencil); } }
public void Clear(RenderContext context, bool cleardepth = true, bool clearstencil = true, float depth = 1.0f, byte stencil = 0) { if (cleardepth || clearstencil) { DepthStencilClearFlags flags = (DepthStencilClearFlags)0; if (cleardepth) { flags = DepthStencilClearFlags.Depth; } if (clearstencil) { flags |= DepthStencilClearFlags.Stencil; } context.Context.ClearDepthStencilView(this.DepthView, flags, depth, stencil); } }
public void SetRenderTarget(DepthStencilView dsv, RenderTargetView rtv, int width, int height, bool clearRTV, Color4 color, bool clearDSV, DepthStencilClearFlags flags = DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, float depth = 1, byte stencil = 0) { if (clearRTV && rtv != null) { ClearRenderTargetView(rtv, color); } if (clearDSV && dsv != null) { ClearDepthStencilView(dsv, flags, depth, stencil); } SetRenderTarget(dsv, rtv); SetViewport(0, 0, width, height); SetScissorRectangle(0, 0, width, height); }
public void ClearDepthStencilView(DepthStencilView view, DepthStencilClearFlags clearFlag, float depth = 1, byte stencil = 0) { deviceContext.ClearDepthStencilView(view, clearFlag, depth, stencil); }
public virtual void ClearDepthStencilView(DepthStencilView depthStencilView, DepthStencilClearFlags clearFlags, float depth, byte stencil) { DiagnosticUtilities.RaiseEvent(this, ClearingDepthStencilView, DiagnosticUtilities.GetID(depthStencilView), clearFlags, depth, stencil); depthStencilView.Clear(clearFlags, depth, stencil); }
public void ClearDepthStencilView(Texture texture, DepthStencilClearFlags flags, int depth = 1, byte stencil = 0) { NativeDeviceContext.ClearDepthStencilView(texture.NativeDepthStencilView, flags, depth, stencil); }
internal void Clear(DepthStencilClearFlags clearFlags, float depth, byte stencil) { if (clearFlags.HasFlag(DepthStencilClearFlags.Depth)) _innerView.Clear(depth); }
internal void ClearDsv(IDsvBindable dsv, DepthStencilClearFlags clearFlags, float depth, byte stencil) { m_deviceContext.ClearDepthStencilView(dsv.Dsv, clearFlags, depth, stencil); CheckErrors(); }
public Framework(string title, int width, int height, bool depth, bool stencil, bool _VSync) { // Create the display to display on Window = new Form() { StartPosition = FormStartPosition.CenterScreen, ClientSize = new Size(width, height), Text = title, TopMost = true, }; Window.StartPosition = FormStartPosition.Manual; Window.Location = new Point(1100, 80); Window.FormBorderStyle = FormBorderStyle.Fixed3D; Window.WindowState =FormWindowState.Normal; Window.CreateControl(); VerticalSyncEnabled = _VSync; CreateDevice(); // Create a description of the display mode var modeDescription = new ModeDescription() { Format = Format.R8G8B8A8_UNorm, RefreshRate = new Rational(60, 1), Scaling = DisplayModeScaling.Unspecified, ScanlineOrdering = DisplayModeScanlineOrder.Unspecified, Width = width, Height = height, }; // Create a description of the sampling for multisampling or antialiasing var sampleDescription = new SampleDescription() { Count = 1, Quality = 0, }; // Create a description of the swap chain or front and back buffers var swapDescription = new SwapChainDescription() { ModeDescription = modeDescription, SampleDescription = sampleDescription, BufferCount = 1, Flags = SwapChainFlags.None, IsWindowed = true, OutputHandle = Window.Handle, SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput, }; // Create the DirectX 11 Device SharpDX.Direct3D11.Device.CreateWithSwapChain(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.BgraSupport|DeviceCreationFlags.Debug, swapDescription, out Device, out swapChain); DContext = Device.ImmediateContext; // Create the factory which manages general graphics resources // Ignore all windows events Factory = swapChain.GetParent<Factory>(); Factory.MakeWindowAssociation(Window.Handle, WindowAssociationFlags.IgnoreAll); Factory.Dispose(); // New RenderTargetView from the backbuffer var backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0); RenderTargetView = new RenderTargetView(Device, backBuffer); RenderTargetView.DebugName = "std"; // Release pointer to the back buffer as we no longer need it. backBuffer.Dispose(); frame_width=Window.ClientSize.Width; frame_height=Window.ClientSize.Height; #region Zdepth if (depth || stencil) { _depth=true; var textureDescription = new Texture2DDescription() { Width = frame_width, Height = frame_height, MipLevels = 1, ArraySize = 1, Format = (stencil) ? Format.D32_Float : Format.D24_UNorm_S8_UInt, SampleDescription = sampleDescription, Usage = ResourceUsage.Default, BindFlags = BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, }; var texture = new Texture2D(Device, textureDescription); var depthStencilViewDescription = new DepthStencilViewDescription() { Format = textureDescription.Format, Dimension = DepthStencilViewDimension.Texture2DMultisampled }; DepthStencilView = new DepthStencilView(Device, texture, depthStencilViewDescription); DContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView); } else { DContext.OutputMerger.SetTargets(RenderTargetView); } if (depth && !stencil) depthStencilClear = DepthStencilClearFlags.Depth; else if (stencil && !depth) depthStencilClear = DepthStencilClearFlags.Stencil; else if (stencil && depth) depthStencilClear = DepthStencilClearFlags.Stencil | DepthStencilClearFlags.Depth; #endregion #region Rasterizer RasterizerStateDescription RAS = new RasterizerStateDescription(); RAS.IsMultisampleEnabled = true; //important for AA RAS.CullMode = CullMode.Back; RAS.DepthBias = 0; RAS.DepthBiasClamp = 0.0f; RAS.FillMode = FillMode.Solid; RAS.IsDepthClipEnabled = false; RAS.IsFrontCounterClockwise = true; DContext.Rasterizer.State = new RasterizerState(Device, RAS); #endregion // Setup the camera viewport var viewport = new Viewport() { TopLeftX = 0, TopLeftY = 0, Width = width, Height = height, MinDepth = 0.0f, MaxDepth = 1.0f, }; DContext.Rasterizer.SetViewports(viewport); Stopwatch = new Stopwatch(); }