public void Clear(ClearOptions options, Color color, float depth, byte stencil) { if (depth < 0 || depth > 1) { throw new ArgumentOutOfRangeException("Depth must be between 0 and 1", "depth"); } if (options.HasFlag(ClearOptions.Color)) { SetClearColor(ref color); currentClearBufferMask |= ClearBufferMask.ColorBufferBit; } if (options.HasFlag(ClearOptions.Depth)) { SetClearDepth(ref depth); currentClearBufferMask |= ClearBufferMask.DepthBufferBit; } if (options.HasFlag(ClearOptions.Stencil)) { SetClearStencil(ref stencil); currentClearBufferMask |= ClearBufferMask.StencilBufferBit; } }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { Rectangle scissorRectangle = this.ScissorRectangle; DepthStencilState depthStencilState = this.DepthStencilState; BlendState blendState = this.BlendState; this.ScissorRectangle = this._viewport.Bounds; this.DepthStencilState = DepthStencilState.Default; this.BlendState = BlendState.Opaque; this.ApplyState(false); ClearBufferMask mask = (ClearBufferMask)0; if (options.HasFlag((Enum)ClearOptions.Target)) { GL.ClearColor(color.X, color.Y, color.Z, color.W); mask |= ClearBufferMask.ColorBufferBit; } if (options.HasFlag((Enum)ClearOptions.Stencil)) { GL.ClearStencil(stencil); mask |= ClearBufferMask.StencilBufferBit; } if (options.HasFlag((Enum)ClearOptions.DepthBuffer)) { GL.ClearDepth((double)depth); mask |= ClearBufferMask.DepthBufferBit; } GL.Clear(mask); this.ScissorRectangle = scissorRectangle; this.DepthStencilState = depthStencilState; this.BlendState = blendState; }
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); } }
private ClearBufferMask CreateClearOptions(ClearOptions clearOptions, float depth, int stencil) { ClearBufferMask bufferMask = 0; if (clearOptions.HasFlag(ClearOptions.Target)) { bufferMask = bufferMask | ClearBufferMask.ColorBufferBit; } if (clearOptions.HasFlag(ClearOptions.Stencil)) { GL.ClearStencil(stencil); bufferMask = bufferMask | ClearBufferMask.StencilBufferBit; } if (clearOptions.HasFlag(ClearOptions.DepthBuffer)) { GL.ClearDepth(depth); bufferMask = bufferMask | ClearBufferMask.DepthBufferBit; } return(bufferMask); }