/// <summary> /// Renders the scene to the given render target. /// Clears the scene, then draws all shapes /// </summary> /// <param name="renderTarget">The render target.</param> private void RenderScene(RenderTarget renderTarget) { Cursor c = null; if (renderMode != RenderModes.HwndRenderTarget) { c = Cursor; Cursor = Cursors.WaitCursor; } renderTarget.BeginDraw(); renderTarget.Clear(BackColorF); for (int i = 0; i < drawingShapes.Count; i++) { DrawingShape shape = drawingShapes[i]; //tag with shape index for debugging renderTarget.Tags = new Tags((ulong)i, 0); shape.Draw(renderTarget); } Tags tags; ErrorCode errorCode; if (!renderTarget.TryEndDraw(out tags, out errorCode)) { Debug.WriteLine(String.Format("Failed EndDraw. Error: {0}, tag1: {1}, tag2: {2}, shape[{1}]: {3}", errorCode, tags.Tag1, tags.Tag2, (int)tags.Tag1 < drawingShapes.Count ? drawingShapes[(int)tags.Tag1].ToString() : "<none>")); } if (renderMode != RenderModes.HwndRenderTarget) { Cursor = c; } }
/// <summary> /// Adds a shape to compatible render target - avoids the need to redraw all shapes. /// </summary> /// <param name="shape">The shape.</param> private void AddToCompatibleRenderTarget(DrawingShape shape) { lock (renderSyncObject) { bitmapRenderTarget.BeginDraw(); shape.Draw(bitmapRenderTarget); bitmapRenderTarget.EndDraw(); } }