示例#1
0
 /// <summary>
 /// Applies a <see cref="PostShader"/> to the <see cref="OmegaEngine.Graphics.RenderTarget"/> and outputs the result to the back-buffer
 /// </summary>
 /// <param name="shader">The <see cref="PostShader"/> to apply</param>
 /// <param name="alpha">The level of transparency from 0 (solid) to 255 (invisible)</param>
 private void ShaderToBackBuffer(PostShader shader, int alpha)
 {
     Engine.State.AlphaBlend = alpha;
     using (new ProfilerEvent(() => "Apply " + shader))
     {
         shader.Apply(delegate
         {
             Engine.Device.BeginScene();
             Engine.DrawQuadShader();
             Engine.Device.EndScene();
         }, _area.Size, shader.OverlayRendering ? null : RenderTarget);
     }
 }
示例#2
0
        /// <summary>
        /// Updates the <see cref="OmegaEngine.Graphics.RenderTarget"/> using a <see cref="PostShader"/>
        /// </summary>
        /// <param name="shader">The <see cref="PostShader"/> to apply</param>
        protected void ShaderToRenderTarget(PostShader shader)
        {
            #region Sanity checks
            if (shader == null)
            {
                throw new ArgumentNullException(nameof(shader));
            }
            #endregion

            // Make sure input and output texture aren't the same
            var sceneMap = RenderTarget;
            if (!shader.OverlayRendering)
            {
                SwapRenderTarget();
            }

            // Apply the shader and move data from one texture to the other
            using (new ProfilerEvent(() => "Apply " + shader))
                shader.Apply(() => RenderTarget.RenderTo(Engine.DrawQuadShader), sceneMap.Size, shader.OverlayRendering ? null : sceneMap);
        }