private void OnResize(object sender, EventArgs e) { _cacheBitmap?.Dispose(); var clientSize = ClientSize; _cacheBitmap = new Bitmap(clientSize.Width, clientSize.Height); RenderLogic.Alloc(clientSize.Width, clientSize.Height); OnResize(); }
private void OnPaint(object sender, PaintEventArgs e) { Application.DoEvents(); e.Graphics.Clear(Color.Black); OnUpdate(); if (_cacheBitmap != null) { RenderLogic.Clear(); OnRender(e.Graphics, _cacheBitmap); e.Graphics.DrawImageUnscaled(_cacheBitmap, 0, 0); ++_frames; } Invalidate(); }