From 7a20268d3bed830577a2ed4f5cb9c12c16b217da Mon Sep 17 00:00:00 2001 From: "SND\\wo80_cp" Date: Tue, 27 Mar 2012 12:24:49 +0000 Subject: [PATCH] Fixed a crash (on window minimize) in the mesh renderer. git-svn-id: https://triangle.svn.codeplex.com/svn@66392 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5 --- Triangle.NET/TestApp/Controls/MeshRenderer.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Triangle.NET/TestApp/Controls/MeshRenderer.cs b/Triangle.NET/TestApp/Controls/MeshRenderer.cs index 553b0d9..a6b23c7 100644 --- a/Triangle.NET/TestApp/Controls/MeshRenderer.cs +++ b/Triangle.NET/TestApp/Controls/MeshRenderer.cs @@ -89,12 +89,27 @@ namespace TestApp private void IntializeBuffer() { - if (buffer != null) + if (this.Width > 0 && this.Height > 0) { - buffer.Dispose(); - } + if (buffer != null) + { + if (this.ClientRectangle == buffer.Graphics.VisibleClipBounds) + { + // Bounds didn't change. Probably we just restored the window + // from minimized state. + return; + } - buffer = context.Allocate(Graphics.FromHwnd(this.Handle), this.ClientRectangle); + buffer.Dispose(); + } + + buffer = context.Allocate(Graphics.FromHwnd(this.Handle), this.ClientRectangle); + + if (initialized) + { + this.Render(); + } + } } private void RenderPoints(Graphics g) @@ -296,7 +311,7 @@ namespace TestApp IntializeBuffer(); - //_coordinates.SetBounds(this.ClientRectangle); + //zoom.Initialize(this.ClientRectangle, data.Bounds); } #endregion