public void PlatformClear(ClearOptions options, Vector4 color, float depth, int stencil) { // TODO: We need to figure out how to detect if we have a // depth stencil buffer or not, and clear options relating // to them if not attached. _graphics.SetClearColor(color.ToPssVector4()); _graphics.Clear(); }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { GLDevice.Clear( options, color, depth, stencil ); }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { PlatformClear(options, color, depth, stencil); unchecked { _graphicsMetrics._clearCount++; } }
public void Clear(ClearOptions options, Color color, float depth, int stencil) { Clear( options, color.ToVector4(), depth, stencil ); }
public StateManager(Game2D game, ClearOptions clearOptions) : base(game) { _clearOptions = clearOptions; _availableStates = new Dictionary <Type, IState>(); _availableTransitions = new Dictionary <Type, ITransition>(); _sourceRenderTarget = new RenderTarget2D(Game.GraphicsDevice, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height); _targetRenderTarget = new RenderTarget2D(Game.GraphicsDevice, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height); }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { // The following was not working with Color.Transparent // Once we get some regression tests take the following out //GL.ClearColor (color.X, color.Y, color.Z, 1.0f); GL.ClearColor(color.X, color.Y, color.Z, color.W); GL.ClearDepth(depth); GL.ClearStencil(stencil); GL.Clear((ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit)); }
/// <summary> /// Construct the clear buffer modifier, clearing all buffers /// </summary> /// <param name="clearOptions"></param> /// <param name="colourValue">colour to clear the render target</param> /// <param name="depthValue">Depth to clear the render target (usuall 1.0f)</param> /// <param name="stencilValue">Stencil value to clear the stencil buffer to</param> public ClearBufferModifier(ClearOptions clearOptions, Color colourValue, float depthValue, byte stencilValue) { this.ClearColourEnabled = (clearOptions & ClearOptions.Target) == ClearOptions.Target; this.ClearColour = colourValue; this.ClearStencilEnabled = (clearOptions & ClearOptions.Stencil) == ClearOptions.Stencil; this.ClearStencilValue = stencilValue; this.ClearDepthEnabled = (clearOptions & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer; this.ClearDepth = depthValue; }
public void Clear( ClearOptions options, Vector4 color, float depth, int stencil ) { ForceToMainThread(() => { GLDevice.Clear(options, color, depth, stencil); }); // End ForceToMainThread }
public static void ClearSubstitute <T>(this T substitute, ClearOptions options = ClearOptions.All) where T : class { if (substitute == null) { throw new NullSubstituteReferenceException(); } var context = SubstitutionContext.Current; var router = context.GetCallRouterFor(substitute !); router.Clear(options); }
public void Clear(ClearOptions options, Color4 color, float depth, byte stencil) { if (options == ClearOptions.None) { return; } EnsureRenderTarget(); BindClearValues(false, options, color, depth, stencil); ClearBufferMask glClearBufferMask = 0; if ((options & ClearOptions.ColorBuffer) != 0) { glClearBufferMask |= ClearBufferMask.ColorBufferBit; if (boundColorWriteMask != ColorWriteMask.All) { GL.ColorMask(true, true, true, true); GLHelper.CheckGLErrors(); boundColorWriteMask = ColorWriteMask.All; } } if ((options & ClearOptions.DepthBuffer) != 0) { glClearBufferMask |= ClearBufferMask.DepthBufferBit; if (!boundDepthState.WriteEnable) { GL.DepthMask(true); GLHelper.CheckGLErrors(); boundDepthState.WriteEnable = true; depthStateDirty = true; } } if ((options & ClearOptions.StencilBuffer) != 0) { glClearBufferMask |= ClearBufferMask.StencilBufferBit; if (boundStencilState.WriteMask != 0xff) { GL.StencilMask(0xff); GLHelper.CheckGLErrors(); boundStencilState.WriteMask = 0xff; stencilStateDirty = true; } } if (boundScissorState.Enable) { GL.Disable(EnableCap.ScissorTest); GLHelper.CheckGLErrors(); boundScissorState.Enable = false; scissorStateDirty = true; } GL.Clear(glClearBufferMask); GLHelper.CheckGLErrors(); }
/// <inheritdoc/> public void Clear(ClearOptions options, Color color, Double depth, Int32 stencil) { Contract.EnsureNotDisposed(this, Disposed); var mask = 0u; var resetColorWriteChannels = false; var resetDepthMask = false; if ((options & ClearOptions.Target) == ClearOptions.Target && (renderTarget == null || renderTarget.HasColorBuffer)) { if (blendState.ColorWriteChannels != ColorWriteChannels.All) { resetColorWriteChannels = true; OpenGLState.ColorMask = ColorWriteChannels.All; } OpenGLState.ClearColor = color; mask |= gl.GL_COLOR_BUFFER_BIT; } if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer && (renderTarget == null || renderTarget.HasDepthBuffer)) { if (!depthStencilState.DepthBufferEnable) { resetDepthMask = true; OpenGLState.DepthMask = true; } OpenGLState.ClearDepth = depth; mask |= gl.GL_DEPTH_BUFFER_BIT; } if ((options & ClearOptions.Stencil) == ClearOptions.Stencil && (renderTarget == null || renderTarget.HasStencilBuffer)) { OpenGLState.ClearStencil = stencil; mask |= gl.GL_STENCIL_BUFFER_BIT; } gl.Clear(mask); gl.ThrowIfError(); if (resetColorWriteChannels) { OpenGLState.ColorMask = blendState.ColorWriteChannels; } if (resetDepthMask) { OpenGLState.DepthMask = depthStencilState.DepthBufferWriteEnable; } }
static int Clear(ClearOptions copts) { conf.GetInstance().debug = copts.Verbose; string wpPath = WinApi.GetCurrentWallpaperPath(); WinApi.SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, wpPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE); if (conf.GetInstance().debug) { Console.WriteLine("Desktop change request sent!"); } return(1); }
public override void Clear(ClearOptions options, Color color, float depth, int stencil) { XNA.Color c; XNAHelper.ConvertColor(ref color, out c); XFG.ClearOptions xfgClear = XFG.ClearOptions.Target; if ((options & ClearOptions.Depth) == ClearOptions.Depth) { xfgClear |= XFG.ClearOptions.DepthBuffer; } if ((options & ClearOptions.Stencil) == ClearOptions.Stencil) { xfgClear |= XFG.ClearOptions.Stencil; } _graphicsDevice.Clear(xfgClear, c, depth, stencil); }
public void Clear(ClearOptions options) { if ((options & ClearOptions.CallActions) == ClearOptions.CallActions) { _substituteState.CallActions.Clear(); } if ((options & ClearOptions.ReturnValues) == ClearOptions.ReturnValues) { _substituteState.CallResults.Clear(); _substituteState.ResultsForType.Clear(); } if ((options & ClearOptions.ReceivedCalls) == ClearOptions.ReceivedCalls) { _substituteState.ReceivedCalls.Clear(); } }
public void ShouldNotResetCachedValuesOnSubsituteClear(ClearOptions options) { // Arrange var fixture = new Fixture().Customize(new AutoConfiguredNSubstituteCustomization()); var substitute = fixture.Create <IInterfaceWithMethod>(); string arg = "argValue"; // Act var resultBefore = substitute.Method(arg); substitute.ClearSubstitute(options); var resultAfter = substitute.Method(arg); // Assert Assert.Equal(resultBefore, resultAfter); }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { if (openGLESVersion == GLContextVersion.Gles2_0) { GL20.ClearColor(color.X, color.Y, color.Z, color.W); GL20.ClearDepth(depth); GL20.ClearStencil(stencil); GL20.Clear((uint)(All20.ColorBufferBit | All20.DepthBufferBit | All20.StencilBufferBit)); } else { GL11.ClearColor(color.X, color.Y, color.Z, color.W); GL11.ClearDepth(depth); GL11.ClearStencil(stencil); GL11.Clear((uint)(All11.ColorBufferBit | All11.DepthBufferBit | All11.StencilBufferBit)); } }
public IRenderService SetRenderTarget(string Key, ClearOptions CO, Color ClearColor, float Depth) { bool didStop = false; if (IsDrawing) { spriteBatch.End(); didStop = true; } currentTarget = Key != null ? targets[Key] : null; GraphicsDevice.SetRenderTarget(currentTarget); GraphicsDevice.Clear(CO | ClearOptions.Stencil, ClearColor, Depth, 0); if (didStop) { return(Start()); } return(this); }
public void ShouldNotResetCachedValuesOnSubsituteClear(ClearOptions options) { // Fixture setup var fixture = new Fixture().Customize(new AutoConfiguredNSubstituteCustomization()); var substitute = fixture.Create <IInterfaceWithMethod>(); string arg = "argValue"; // Exercise system var resultBefore = substitute.Method(arg); substitute.ClearSubstitute(options); var resultAfter = substitute.Method(arg); // Verify outcome Assert.Equal(resultBefore, resultAfter); // Teardown }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { uint mask = 0; if (color.X != 0f || color.Y != 0f || color.Z != 0f || color.W != 0f) { GL.ClearColor(color.X, color.Y, color.Z, color.W); mask = (uint)ClearBufferMask.ColorBufferBit | mask; } GL.ClearDepth(depth); mask = (uint)ClearBufferMask.DepthBufferBit | mask; GL.ClearStencil(stencil); mask = (uint)ClearBufferMask.StencilBufferBit | mask; GL.Clear(mask); }
/// <summary> /// Everything between <c>BeginAntialising()</c> and <c>EndAntialising()</c> will be affected by MSAA. /// </summary> /// <example> /// <code> /// protected override void Draw() /// { /// base.Draw(); /// /// Editor.BeginAntialising(); /// /// Editor.spriteBatch.Begin(); /// /// //Your drawings /// /// Editor.spriteBatch.End(); /// /// Editor.EndAntialising(); /// } /// </code> /// </example> /// <param name="clearGraphics"><c>false</c> if you don't want to to call <see cref="graphics"/>.Clear() after setting the <see cref="RenderTarget2D"/>.</param> /// <param name="clearColor">The <see cref="Color"/> to be used to clear the <see cref="graphics"/> after setting the <see cref="RenderTarget2D"/>.</param> /// <param name="clearOptions">Define your custom <see cref="ClearOptions"/>.</param> /// <param name="depth">The depth.</param> /// <param name="stencil">The stencil</param> public void BeginAntialising( bool clearGraphics = true, Color?clearColor = null, ClearOptions clearOptions = ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target, float depth = 0f, int stencil = 0) { if (AntialisingRenderTarget.GetRenderTarget2D == null || AntialisingRenderTarget.IsRefreshing || !AntialisingRenderTarget.Enabled) { return; } graphics.SetRenderTarget(AntialisingRenderTarget.GetRenderTarget2D); if (clearGraphics) { graphics.Clear(clearOptions, clearColor ?? BackgroundColor, depth, stencil); } }
/// <summary> /// Sets the swapchain's backbuffer as the active render target and clears it. /// </summary> /// <param name="options">Clear option flags defining which buffer to clear.</param> /// <param name="color">Color to clear the color buffer to</param> /// <param name="depth">Depth value to clear the depth buffer to</param> /// <param name="stencil">Stencil value to clear the stencil buffer to</param> public override void Clear(ClearOptions options, Color color, float depth, int stencil) { if (_resetting) { return; } SlimDX.Color4 sc; D3D10Helper.Convert(ref color, out sc); _renderer.TargetManager.SetActiveSwapChain(this); if (_depthStencilView != null) { _graphicsDevice.OutputMerger.SetTargets(_depthStencilView, _renderTargetView); if (((options & ClearOptions.Depth) == ClearOptions.Depth) && ((options & ClearOptions.Stencil) == ClearOptions.Stencil)) { _graphicsDevice.ClearDepthStencilView(_depthStencilView, D3D.DepthStencilClearFlags.Depth | D3D.DepthStencilClearFlags.Stencil, depth, (byte)stencil); } else if ((options & ClearOptions.Depth) == ClearOptions.Depth) { _graphicsDevice.ClearDepthStencilView(_depthStencilView, D3D.DepthStencilClearFlags.Depth, depth, (byte)stencil); } else if ((options & ClearOptions.Stencil) == ClearOptions.Stencil) { _graphicsDevice.ClearDepthStencilView(_depthStencilView, D3D.DepthStencilClearFlags.Stencil, depth, (byte)stencil); } if ((options & ClearOptions.Target) == ClearOptions.Target) { _graphicsDevice.ClearRenderTargetView(_renderTargetView, sc); } } else { _graphicsDevice.OutputMerger.SetTargets(_renderTargetView); if ((options & ClearOptions.Target) == ClearOptions.Target) { _graphicsDevice.ClearRenderTargetView(_renderTargetView, sc); } } }
/// <summary> /// Everything between <c>BeginRenderTarget()</c> and <c>EndRenderTarget()</c> will be drawn to the <see cref="RenderTarget2D"/>. /// </summary> /// <example> /// <code> /// protected override void Draw() /// { /// base.Draw(); /// /// Editor.BeginRenderTarget("MyRenderTarget"); /// /// Editor.spriteBatch.Begin(); /// /// //Your drawings /// /// Editor.spriteBatch.End(); /// /// Editor.EndRenderTarget("MyRenderTarget", false); /// } /// </code> /// </example> /// <param name="key">Please enter a previously set key of the <see cref="RenderTarget2D"/> you want to begin with.</param> /// <param name="clearGraphics"><c>false</c> if you don't want to to call <see cref="graphics"/>.Clear() after setting the <see cref="RenderTarget2D"/>.</param> /// <param name="clearColor">The <see cref="Color"/> to be used to clear the <see cref="graphics"/> after setting the <see cref="RenderTarget2D"/>.</param> /// <param name="clearOptions">Define your custom <see cref="ClearOptions"/>.</param> /// <param name="depth">The depth.</param> /// <param name="stencil">The stencil</param> public void BeginRenderTarget( string key, bool clearGraphics = true, Color?clearColor = null, ClearOptions clearOptions = ClearOptions.DepthBuffer | ClearOptions.Stencil | ClearOptions.Target, float depth = 0f, int stencil = 0) { if (GetRenderTargetManager.GetRenderTarget2D(key) == null || GetRenderTargetManager.RenderTargets[key].IsRefreshing || !GetRenderTargetManager.RenderTargets[key].Enabled) { return; } graphics.SetRenderTarget(GetRenderTargetManager.GetRenderTarget2D(key)); if (clearGraphics) { graphics.Clear(clearOptions, clearColor ?? BackgroundColor, 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); }
public override void clear(Background background) { Color color1 = Color.Black; ClearOptions options = ClearOptions.Target; bool flag = false; if (background != null) { if (background.isColorClearEnabled()) { int color2 = background.getColor(); float num = 0.003921569f; color1 = new Color((float)((color2 & 16711680) >> 16) * num, (float)((color2 & 65280) >> 8) * num, (float)(color2 & (int)byte.MaxValue) * num) * ((float)(((long)color2 & 4278190080L) >> 24) * num); flag = true; } if (background.isDepthClearEnabled()) { if (background.isColorClearEnabled()) { options |= ClearOptions.DepthBuffer; flag = true; } else { options = ClearOptions.DepthBuffer; flag = true; } } } else { options = ClearOptions.Target | ClearOptions.DepthBuffer; flag = true; } if (!flag) { return; } this.device.Clear(options, color1, 1f, 0); }
//GG EDIT IMPLEMENTED public void Clear(ClearOptions options, Color color, float depth, int stencil) { Vector4 vector = color.ToEAGLColor(); GL.ClearColor(vector.X, vector.Y, vector.Z, 1.0f); switch (options) { case ClearOptions.DepthBuffer: GL.ClearDepth(depth); GL.Clear(ClearBufferMask.DepthBufferBit); break; case ClearOptions.Stencil: GL.ClearStencil(stencil); GL.Clear(ClearBufferMask.StencilBufferBit); break; case ClearOptions.Target: throw new NotImplementedException(); } }
public static void Clear(Action <GraphicsDevice, ClearOptions, Vector4, float, int> orig, GraphicsDevice self, ClearOptions options, Vector4 color, float depth, int stencil) { if (SkipClear > 0) { SkipClear--; return; } orig(self, options, color, depth, stencil); }
public static void Clear(ClearOptions options, Color color, float depth, int stencil) { Device.Clear(options, color, 0, 0); }
public static void Begin(ClearOptions options, Color color, float depth, int stencil) { Device.Clear(options, color, depth, stencil); MainEffect.Begin(); MainEffect.CurrentTechnique.Passes[0].Begin(); }
public void Clear(ClearOptions clear) { }
public abstract void Clear (ClearOptions options, Vector4 color, float depth, int stencil);
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil, Rectangle[] regions) { throw new NotImplementedException(); }
/// <inheritdoc/> public void Clear(ClearOptions options, Color color, Double depth, Int32 stencil) { Contract.EnsureNotDisposed(this, Disposed); var mask = 0u; var resetColorWriteChannels = false; var resetDepthTest = false; var resetStencilTest = false; if ((options & ClearOptions.Target) == ClearOptions.Target) { if (blendState.ColorWriteChannels != ColorWriteChannels.All) { resetColorWriteChannels = true; gl.ColorMask(true, true, true, true); } gl.ClearColor(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); mask |= gl.GL_COLOR_BUFFER_BIT; } if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer) { if (!depthStencilState.DepthBufferEnable) { resetDepthTest = true; gl.Enable(gl.GL_DEPTH_TEST); gl.DepthMask(true); } gl.ClearDepth(depth); mask |= gl.GL_DEPTH_BUFFER_BIT; } if ((options & ClearOptions.Stencil) == ClearOptions.Stencil) { if (!depthStencilState.StencilEnable) { resetStencilTest = true; gl.Enable(gl.GL_STENCIL_TEST); } gl.ClearStencil(stencil); mask |= gl.GL_STENCIL_BUFFER_BIT; } gl.Clear(mask); if (resetColorWriteChannels) { gl.ColorMask( (blendState.ColorWriteChannels & ColorWriteChannels.Red) == ColorWriteChannels.Red, (blendState.ColorWriteChannels & ColorWriteChannels.Green) == ColorWriteChannels.Green, (blendState.ColorWriteChannels & ColorWriteChannels.Blue) == ColorWriteChannels.Blue, (blendState.ColorWriteChannels & ColorWriteChannels.Alpha) == ColorWriteChannels.Alpha); gl.ThrowIfError(); } if (resetDepthTest) { gl.Enable(gl.GL_DEPTH_TEST, depthStencilState.DepthBufferEnable); gl.ThrowIfError(); gl.DepthMask(depthStencilState.DepthBufferWriteEnable); gl.ThrowIfError(); } if (resetStencilTest) { gl.Enable(gl.GL_STENCIL_TEST, depthStencilState.StencilEnable); gl.ThrowIfError(); } }
public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) { // glClear depends on the scissor rectangle! if (scissorTestEnable) { glDisable(GLenum.GL_SCISSOR_TEST); } bool clearTarget = (options & ClearOptions.Target) == ClearOptions.Target; bool clearDepth = (options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer; bool clearStencil = (options & ClearOptions.Stencil) == ClearOptions.Stencil; // Get the clear mask, set the clear properties if needed GLenum clearMask = GLenum.GL_ZERO; if (clearTarget) { clearMask |= GLenum.GL_COLOR_BUFFER_BIT; if (!color.Equals(currentClearColor)) { glClearColor( color.X, color.Y, color.Z, color.W ); currentClearColor = color; } // glClear depends on the color write mask! if (colorWriteEnable != ColorWriteChannels.All) { // FIXME: ColorWriteChannels1/2/3? -flibit glColorMask(true, true, true, true); } } if (clearDepth) { clearMask |= GLenum.GL_DEPTH_BUFFER_BIT; if (depth != currentClearDepth) { glClearDepth((double) depth); currentClearDepth = depth; } // glClear depends on the depth write mask! if (!zWriteEnable) { glDepthMask(true); } } if (clearStencil) { clearMask |= GLenum.GL_STENCIL_BUFFER_BIT; if (stencil != currentClearStencil) { glClearStencil(stencil); currentClearStencil = stencil; } // glClear depends on the stencil write mask! if (stencilWriteMask != -1) { // AKA 0xFFFFFFFF, ugh -flibit glStencilMask(-1); } } // CLEAR! glClear(clearMask); // Clean up after ourselves. if (scissorTestEnable) { glEnable(GLenum.GL_SCISSOR_TEST); } if (clearTarget && colorWriteEnable != ColorWriteChannels.All) { // FIXME: ColorWriteChannels1/2/3? -flibit glColorMask( (colorWriteEnable & ColorWriteChannels.Red) != 0, (colorWriteEnable & ColorWriteChannels.Blue) != 0, (colorWriteEnable & ColorWriteChannels.Green) != 0, (colorWriteEnable & ColorWriteChannels.Alpha) != 0 ); } if (clearDepth && !zWriteEnable) { glDepthMask(false); } if (clearStencil && stencilWriteMask != -1) // AKA 0xFFFFFFFF, ugh -flibit { glStencilMask(stencilWriteMask); } }
/// <inheritdoc/> public void Clear(ClearOptions options, Color color, Double depth, Int32 stencil) { Contract.EnsureNotDisposed(this, Disposed); }
/// <summary> /// Construct the clear buffer modifier /// </summary> /// <param name="clearOptions"></param> public ClearBufferModifier(ClearOptions clearOptions) : this(clearOptions, Color.CornflowerBlue, 1, 0) { }
/// <summary> /// Construct the clear buffer modifier /// </summary> /// <param name="clearOptions"></param> /// <param name="colourValue">Colour to clear the render target</param> public ClearBufferModifier(ClearOptions clearOptions, Color colourValue) : this(clearOptions, colourValue, 1, 0) { }
public abstract void Clear (ClearOptions options, Color color, float depth, int stencil, Rectangle[] regions);
private void PlatformClear(ClearOptions options, Vector4 color, float depth, int stencil) { // TODO: We need to figure out how to detect if we have a // depth stencil buffer or not, and clear options relating // to them if not attached. // Unlike with XNA and DirectX... GL.Clear() obeys several // different render states: // // - The color write flags. // - The scissor rectangle. // - The depth/stencil state. // // So overwrite these states with what is needed to perform // the clear correctly and restore it afterwards. // var prevScissorRect = ScissorRectangle; var prevDepthStencilState = DepthStencilState; var prevBlendState = BlendState; ScissorRectangle = _viewport.Bounds; // DepthStencilState.Default has the Stencil Test disabled; // make sure stencil test is enabled before we clear since // some drivers won't clear with stencil test disabled DepthStencilState = _clearDepthStencilState; BlendState = BlendState.Opaque; ApplyState(false); ClearBufferMask bufferMask = 0; if ((options & ClearOptions.Color) == ClearOptions.Color) { if (color != _lastClearColor) { GL.ClearColor(color.X, color.Y, color.Z, color.W); GL.CheckError(); _lastClearColor = color; } bufferMask |= ClearBufferMask.ColorBufferBit; } if ((options & ClearOptions.Stencil) == ClearOptions.Stencil) { if (stencil != _lastClearStencil) { GL.ClearStencil(stencil); GL.CheckError(); _lastClearStencil = stencil; } bufferMask |= ClearBufferMask.StencilBufferBit; } if ((options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer) { if (depth != _lastClearDepth) { if (GL.ClearDepthF != null) { GL.ClearDepthF(depth); } else { GL.ClearDepth(depth); } GL.CheckError(); _lastClearDepth = depth; } bufferMask |= ClearBufferMask.DepthBufferBit; } #if MONOMAC || IOS if (GL.CheckFramebufferStatus(FramebufferTarget.FramebufferExt) == FramebufferErrorCode.FramebufferComplete) #endif { GL.Clear(bufferMask); GL.CheckError(); } // Restore the previous render state. ScissorRectangle = prevScissorRect; DepthStencilState = prevDepthStencilState; BlendState = prevBlendState; }
public void Clear(ClearOptions clear) => throw new NotImplementedException();
public void Clear(ClearOptions options, Color color, Single depth, int stencil, Rectangle[] regions) { throw new NotImplementedException(); }
public void SetRenderTargets(params RenderTargetBinding[] renderTargets) { currentRenderTargets = renderTargets; if (currentRenderTargets != null) { // TODO: For speed we need to consider using FBO switching instead // of multiple FBO's if they are the same size. // http://www.songho.ca/opengl/gl_fbo.html // Get the currently bound frame buffer object. On most platforms this just gives 0. GL.GetInteger(All.FramebufferBindingOes, ref originalFbo); frameBufferIDs = new int[currentRenderTargets.Length]; renderBufferIDs = new int[currentRenderTargets.Length]; GL.Oes.GenRenderbuffers(currentRenderTargets.Length, renderBufferIDs); for (int i = 0; i < currentRenderTargets.Length; i++) { RenderTarget2D target = (RenderTarget2D)currentRenderTargets[i].RenderTarget; // create a renderbuffer object to store depth info GL.Oes.BindRenderbuffer(All.RenderbufferOes, renderBufferIDs[i]); ClearOptions clearOptions = ClearOptions.Target | ClearOptions.DepthBuffer; switch (target.DepthStencilFormat) { case DepthFormat.Depth16: GL.Oes.RenderbufferStorage(All.RenderbufferOes, All.DepthComponent16Oes, target.Width, target.Height); break; case DepthFormat.Depth24: GL.Oes.RenderbufferStorage(All.RenderbufferOes, All.DepthComponent24Oes, target.Width, target.Height); break; case DepthFormat.Depth24Stencil8: GL.Oes.RenderbufferStorage(All.RenderbufferOes, All.Depth24Stencil8Oes, target.Width, target.Height); GL.Oes.FramebufferRenderbuffer(All.FramebufferOes, All.StencilAttachmentOes, All.RenderbufferOes, renderBufferIDs[i]); clearOptions = clearOptions | ClearOptions.Stencil; break; default: GL.Oes.RenderbufferStorage(All.RenderbufferOes, All.DepthComponent24Oes, target.Width, target.Height); break; } // create framebuffer GL.Oes.GenFramebuffers(1, ref frameBufferIDs[i]); GL.Oes.BindFramebuffer(All.FramebufferOes, frameBufferIDs[i]); // attach the texture to FBO color attachment point GL.Oes.FramebufferTexture2D(All.FramebufferOes, All.ColorAttachment0Oes, All.Texture2D, target.ID, 0); // attach the renderbuffer to depth attachment point GL.Oes.FramebufferRenderbuffer(All.FramebufferOes, All.DepthAttachmentOes, All.RenderbufferOes, renderBufferIDs[i]); if (target.RenderTargetUsage == RenderTargetUsage.DiscardContents) { Clear(clearOptions, Color.Transparent, 0, 0); } GL.Oes.BindRenderbuffer(All.FramebufferOes, originalFbo); } All status = GL.Oes.CheckFramebufferStatus(All.FramebufferOes); if (status != All.FramebufferCompleteOes) { throw new Exception("Error creating framebuffer: " + status); } // We need to start saving off the ViewPort and setting the current ViewPort to // the width and height of the texture. Then when we pop off the rendertarget // it needs to be reset. This causes drawing problems if we do not set the viewport. // Makes sense once you follow the flow (hits head on desk) // For an example of this take a look at NetRumble's sample for the BloomPostprocess // Save off the current viewport to be reset later savedViewport = Viewport; // Create a new Viewport Viewport renderTargetViewPort = new Viewport(); // Set the new viewport to the width and height of the render target Texture2D target2 = (Texture2D)currentRenderTargets[0].RenderTarget; renderTargetViewPort.Width = target2.Width; renderTargetViewPort.Height = target2.Height; // now we set our viewport to the new rendertarget viewport just created. Viewport = renderTargetViewPort; } }
public void Clear(ClearOptions options, Vector4 color, Single depth, int stencil) { throw new NotImplementedException(); }