private void InternalDraw(Microsoft.Xna.Framework.GameTime gameTime) { #if DEBUG Graphics.SpriteBatch.ResetMetrics(); PrimitiveBatch.ResetMetrics(); #endif OnBeforeRender(); MainCanvas.Begin(BackgroundColor); foreach (Renderer renderer in Instance.Renderers) { renderer.Begin(); } Render(); foreach (Renderer renderer in Instance.Renderers) { renderer.End(); } MainCanvas.End(); OnRenderToMainCanvas?.Invoke(); #if DEBUG // debug render DebugCanvas.Begin(Color.Transparent); DebugRender(); DebugCanvas.End(); #endif // draw main render target to screen GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(ScreenBackgroundColor); ScreenRenderer.Begin(); ScreenRenderer.Draw( MainCanvas, MainCanvas.Position + _gameCanvasPosition, null, MainCanvas.Rotation, MainCanvas.Scale * new Vector2(PixelScale * KeepProportionsScale), MainCanvas.Flipped, MainCanvas.Color, MainCanvas.Origin, MainCanvas.Scroll, MainCanvas.Shader, MainCanvas.ShaderParameters ); OnAfterMainCanvasRender?.Invoke(); #if DEBUG ScreenRenderer.Draw( DebugCanvas, DebugCanvas.Position + _gameCanvasPosition, null, 0f, Vector2.One, ImageFlip.None, Color.White, Vector2.Zero, Vector2.One ); #endif OnLateRender?.Invoke(); ScreenRenderer.End(); _fpsCount++; }