Example #1
0
        public void RenderGame(RenderFunction renderFunction, Color clearColor)
        {
            // draw true image
            setRenderTarget(TrueGameScreen, clearColor);
            SpriteBatch.BeginPixelPerfect(trueScaleMatrix, SpriteSortMode.FrontToBack);
            renderFunction();
            SpriteBatch.End();

            // apply the shader
            setRenderTarget(ShadedGameScreen, Color.Black);
            SpriteBatch.BeginPixelPerfect(trueScaleMatrix);
            PostProcessors?.Invoke();
            SpriteBatch.Draw(TrueGameScreen, Vector2.Zero, Color.White);
            SpriteBatch.End();

            // if requested, save shaded screenshot (before scaling)
            if (takeScreenshot)
            {
                takeScreenshot = false;
                ShadedGameScreen.SaveAsTimestampedPng();
            }
        }