/// <summary> /// Pushes a new render target onto the render target stack. /// </summary> /// <param name="viewport">The viewport object.</param> /// <param name="renderTargets">A structure containing all relevant render targets.</param> /// <param name="camera">The camera for the new render target.</param> /// <param name="viewInformation">The view information.</param> /// <exception cref="System.ObjectDisposedException">RenderState</exception> internal void PushRenderTarget( RenderTargets renderTargets, SharpDX.Mathematics.Interop.RawViewportF viewport, Camera3DBase camera, ViewInformation viewInformation) { if (m_disposed) { throw new ObjectDisposedException("RenderState"); } //Build new render stack entry RenderStackEntry newEntry = new RenderStackEntry(); newEntry.Matrix4Stack = new Matrix4Stack(); newEntry.Camera = camera; newEntry.RenderTargets = renderTargets; newEntry.SingleViewport = viewport; newEntry.ViewInformation = viewInformation; //Overtake device settings newEntry.Apply(m_device.DeviceImmediateContextD3D11); //Push new entry onto the stack m_renderSettingsStack.Push(m_currentRenderSettings); m_currentRenderSettings = newEntry; }
/// <summary> /// Applies current render target settings. /// </summary> public void ClearState() { if (_disposed) { throw new ObjectDisposedException("RenderState"); } // Clear material properties _lastAppliedMaterial?.Discard(this); _lastAppliedMaterial = null; _forcedMaterial = null; this.Device.DeviceImmediateContextD3D11.ClearState(); _currentRenderSettings?.Apply(this.Device.DeviceImmediateContextD3D11); }
/// <summary> /// Pops a render target from the render target stack. /// </summary> public void PopRenderTarget() { if (m_disposed) { throw new ObjectDisposedException("RenderState"); } if (m_renderSettingsStack.Count < 1) { throw new SeeingSharpGraphicsException("There is only one element on the render stack!"); } //Pop last entry m_currentRenderSettings = m_renderSettingsStack.Pop(); //Apply old configuration m_currentRenderSettings.Apply(m_device.DeviceImmediateContextD3D11); }
/// <summary> /// Resets the render state. /// </summary> /// <param name="viewport">The viewport.</param> /// <param name="camera">The camera for the new render target.</param> /// <param name="viewInformation">The view information.</param> /// <param name="renderTargets">The render targets used for rendering.</param> internal void Reset( RenderTargets renderTargets, SharpDX.Mathematics.Interop.RawViewportF viewport, Camera3DBase camera, ViewInformation viewInformation) { m_renderSettingsStack.Clear(); m_sceneStack.Clear(); m_currentScene = null; m_world = new Matrix4Stack(Matrix4x4.Identity); //Inititialize current render properties m_currentRenderSettings = new RenderStackEntry(); m_currentRenderSettings.Matrix4Stack = new Matrix4Stack(); m_currentRenderSettings.RenderTargets = renderTargets; m_currentRenderSettings.SingleViewport = viewport; m_currentRenderSettings.Camera = camera; m_currentRenderSettings.ViewInformation = viewInformation; //Apply initial render properties m_currentRenderSettings.Apply(m_device.DeviceImmediateContextD3D11); }