public RenderWindow() : base(DefaultWidth, DefaultHeight, GraphicsMode.Default, MainTitle, GameWindowFlags.Default, DisplayDevice.Default, 0, 0, GraphicsContextFlags.ForwardCompatible) { _interop = new GraphicsInterop(); _input = new InputManager(Keyboard); _kernelManager = new KernelManager(_interop, _input, EmbeddedResourceManager.GetText("kernel.cl")); }
public static void RenderGif(KernelManager manager) { RenderWindow.SetStatus("Rendering gif swish"); var camera = InputManager.LoadState(); var left = Vector3d.Cross(camera.Lookat, camera.Up); var originalPos = camera.Position; var directory = Ext.UniqueDirectory("temp"); Directory.CreateDirectory(directory); var filenames = new string[Frames]; for (var i = 0; i < Frames; i++) { var offset = Math.Sin((double)i / Frames * (Math.PI * 2)) * camera.MoveSpeed / ReductionAmount; camera.Position = originalPos + offset * left; var bitmap = manager.GetScreenshot(camera, 480, 1); var filename = Ext.UniqueFileInDirectory(directory, "swish", "png"); bitmap.Save(filename); filenames[i] = filename; } RenderWindow.SetStatus("Converting to gif"); var file = Ext.UniqueFilename("render", "gif"); var psi = new ProcessStartInfo("C:\\Program Files\\ImageMagick-6.8.7-Q16\\Convert.exe", "\"" + string.Join("\" \"", filenames) + "\" \"" + file + "\"") { WorkingDirectory = directory }; Process.Start(psi).WaitForExit(); Directory.Delete(directory, true); RenderWindow.SetStatus("Done rendering gif swish"); }
public static bool CheckForVideo(KernelManager kernelManager) { if (_frame == null) { return(false); } var i = _frame.Value / StepsPerPoint; if (i >= Frames.Count - 1) { _frame = null; _aviManager.Close(); RenderWindow.SetStatus("Finished video"); return(false); } RenderWindow.SetStatus("Rendering frame " + _frame.Value + " of " + (Frames.Count - 1) * StepsPerPoint); var d0 = i == 0 ? Frames[0] : Frames[i - 1]; var d1 = Frames[i]; var d2 = Frames[i + 1]; var d3 = i == Frames.Count - 2 ? Frames[Frames.Count - 1] : Frames[i + 2]; var t = (float)(_frame.Value % StepsPerPoint) / StepsPerPoint; var config = CameraConfig.CatmullRom(d0, d1, d2, d3, t); var bmp = kernelManager.GetScreenshot(config, 720, 2); if (_frame.Value % 256 == 0 || _aviManager == null) { if (_aviManager != null) { _aviManager.Close(); } _videoStream = null; _aviManager = new AviManager(Ext.UniqueFilename("video", "avi"), false); } if (_videoStream == null) { _videoStream = _aviManager.AddVideoStream(false, 25, bmp); } else { _videoStream.AddFrame(bmp); } _frame = _frame.Value + 1; return(true); }
public static bool CheckForVideo(KernelManager kernelManager) { if (_frame == null) return false; var i = _frame.Value / StepsPerPoint; if (i >= Frames.Count - 1) { _frame = null; _aviManager.Close(); RenderWindow.SetStatus("Finished video"); return false; } RenderWindow.SetStatus("Rendering frame " + _frame.Value + " of " + (Frames.Count - 1) * StepsPerPoint); var d0 = i == 0 ? Frames[0] : Frames[i - 1]; var d1 = Frames[i]; var d2 = Frames[i + 1]; var d3 = i == Frames.Count - 2 ? Frames[Frames.Count - 1] : Frames[i + 2]; var t = (float)(_frame.Value % StepsPerPoint) / StepsPerPoint; var config = CameraConfig.CatmullRom(d0, d1, d2, d3, t); var bmp = kernelManager.GetScreenshot(config, 720, 2); if (_frame.Value % 256 == 0 || _aviManager == null) { if (_aviManager != null) _aviManager.Close(); _videoStream = null; _aviManager = new AviManager(Ext.UniqueFilename("video", "avi"), false); } if (_videoStream == null) _videoStream = _aviManager.AddVideoStream(false, 25, bmp); else _videoStream.AddFrame(bmp); _frame = _frame.Value + 1; return true; }