void Render(string outputPath) { var width = 0; var height = 0; foreach (var control in guiRenderable.Canvas.Children) RenderBounds(control, ref width, ref height); app.RunStep(); var imageSettings = new Settings { Height = (ushort)height, Width = (ushort)width }; var renderBuffer = app.RenderDevice.Backend.CreateRenderBuffer(imageSettings); renderBuffer.CreateRenderBuffer(RenderBufferType.Color); renderBuffer.CreateRenderBuffer(RenderBufferType.Depth); renderBuffer.Context = window.RenderContext; window.view.ClearColor = Color.White; window.view.RenderTarget = renderBuffer; window.view.Size = new Vector2i(width, height); guiRenderable.Canvas.SetSize(width, height); window.device.ActiveView = window.view; if (!renderBuffer.Check()) throw new Exception("Error creating render buffer"); renderBuffer.Bind(); window.Render(); var image = renderBuffer.ReadImage(1); var imageWriter = new ImageWriter(); imageWriter.Save(image, outputPath); renderBuffer.Unbind(); }
private void Render(Canvas canvas, string outputPath) { canvas.RenderCanvas(); var width = 0; var height = 0; foreach (var control in canvas.Children) RenderBounds(control, ref width, ref height); var imageSettings = new Settings { Height = (ushort)height, Width = (ushort)width }; var renderBuffer = RenderDevice.Backend.CreateRenderBuffer(imageSettings); renderBuffer.CreateRenderBuffer(RenderBufferType.Color); renderBuffer.CreateRenderBuffer(RenderBufferType.Depth); renderBuffer.Context = MainWindow.Context; MainView.RenderTarget = renderBuffer; MainView.Size = new Vector2i(width, height); canvas.SetSize(width, height); RenderDevice.ActiveView = MainView; if (!renderBuffer.Check()) throw new Exception("Error creating render buffer"); renderBuffer.Bind(); var rb = new RenderBlock(); Renderer.Render(rb); RenderDevice.ClearView(); RenderDevice.Render(rb); Engine.StepFrame(); var image = renderBuffer.ReadImage(1); var imageWriter = new ImageWriter(); imageWriter.Save(image, outputPath); renderBuffer.Unbind(); }