} // DisableRenderTarget /// <summary> /// Back to back buffer (frame buffer). /// </summary> public static void DisableCurrentRenderTargets() { if (currentRenderTarget != null) currentRenderTarget.alreadyResolved = true; currentRenderTarget = null; EngineManager.Device.SetRenderTarget(null); } // DisableCurrentRenderTargets
} // RecreateResource #endregion #region Enable Render Target /// <summary> /// Set render target for render. /// </summary> public void EnableRenderTarget(CubeMapFace cubeMapFace) { if (currentRenderTarget != null) throw new InvalidOperationException("Render Target Cube: unable to set render target. Another render target is still set. If you want to set multiple render targets use the static method called EnableRenderTargets."); EngineManager.Device.SetRenderTarget(renderTarget, cubeMapFace); currentRenderTarget = this; alreadyResolved = false; } // EnableRenderTarget
} // Clear #endregion #region Disable Render Target /// <summary> /// Resolve render target. /// This method will only work if the render target was set before with SetRenderTarget. /// </summary> public void DisableRenderTarget() { // Make sure this render target is currently set! if (currentRenderTarget != this) { throw new InvalidOperationException("Render Target: Cannot call disable to a render target without first setting it."); } alreadyResolved = true; currentRenderTarget = null; EngineManager.Device.SetRenderTarget(null); } // DisableRenderTarget
} // Fetch /// <summary> /// Release the render target. /// </summary> public static void Release(RenderTargetCube rendertarget) { if (rendertarget == null) return; for (int i = 0; i < renderTargets.Count; i++) { if (rendertarget == renderTargets[i]) { rendertarget.looked = false; return; } } // If not do nothing. //throw new ArgumentException("Render Target: Cannot release render target. The render target is not present in the pool."); } // Release
} // Begin /// <summary> /// Begins the rendering of the depth information from the light point of view over a cube render target. /// </summary> internal void Begin(RenderTargetCube lightDepthTexture, Vector3 lightPosition, float lightRadius) { try { // Creates the render target textures lightDepthTextureCube = lightDepthTexture; spLightPosition.Value = lightPosition; spLightRadius.Value = lightRadius; } catch (Exception e) { throw new InvalidOperationException("Shadow Map Shader: Unable to begin the rendering.", e); } } // Begin
} // Begin /// <summary> /// Begins the rendering of the depth information from the light point of view over a cube render target. /// </summary> internal void Begin(int lightDepthTextureSize, Vector3 lightPosition, float lightRadius) { try { // Creates the render target textures lightDepthTextureCube = RenderTargetCube.Fetch(lightDepthTextureSize, SurfaceFormat.Single, DepthFormat.Depth24, RenderTarget.AntialiasingType.NoAntialiasing); spLightPosition.Value = lightPosition; spLightRadius.Value = lightRadius; } catch (Exception e) { throw new InvalidOperationException("Shadow Map Shader: Unable to begin the rendering.", e); } } // Begin