static void Main() { try { using (AntRenderForm window = new AntRenderForm("Insight Library Sample")) { using (Renderer renderer = new Renderer(window)) { RenderLoop.Run(window, () => { renderer.Update(); renderer.Render(); }); } } } catch (Exception ex) { Console.WriteLine(ex); // TODO: better error reporting later on MessageBox.Show(ex.Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void Main(string[] args) { using (var device = new Device(DriverType.Hardware)) { using (var form = new ATBRenderForm("DX11 AntTweakBar Sample")) { using (var renderer = new Renderer(device, form)) { // At this point we can initialize the AntTweakBar context // (since the renderer has now created the D3D device) using (var context = new Context(Tw.GraphicsAPI.D3D11, renderer.DevicePointer)) { form.Context = context; // Add a bar with some variables in it var exampleBar = new Bar(form.Context); exampleBar.Label = "Example Bar"; exampleBar.Contained = true; // here we bind the variables to the renderer variables with their Changed event // (their initial value is whatever the renderer currently has set them to) var color1Var = new ColorVariable(exampleBar, renderer.P1Color.X, renderer.P1Color.Y, renderer.P1Color.Z); color1Var.Label = "P1 color"; color1Var.Changed += delegate { renderer.P1Color = new Vector3(color1Var.R, color1Var.G, color1Var.G); }; var color2Var = new ColorVariable(exampleBar, renderer.P2Color.X, renderer.P2Color.Y, renderer.P2Color.Z); color2Var.Label = "P2 color"; color2Var.Changed += delegate { renderer.P2Color = new Vector3(color2Var.R, color2Var.G, color2Var.G); }; var color3Var = new ColorVariable(exampleBar, renderer.P3Color.X, renderer.P3Color.Y, renderer.P3Color.Z); color3Var.Label = "P3 color"; color3Var.Changed += delegate { renderer.P3Color = new Vector3(color3Var.R, color3Var.G, color3Var.G); }; // Put the color selection variables in their own group var colorGroup = new Group(exampleBar, "Colors", color1Var, color2Var, color3Var); var wireframeVar = new BoolVariable(exampleBar); wireframeVar.Label = "Wireframe"; wireframeVar.Changed += delegate { renderer.Wireframe = wireframeVar.Value; }; var scaleVar = new FloatVariable(exampleBar, renderer.Scale); scaleVar.Label = "Scale"; scaleVar.Changed += delegate { renderer.Scale = scaleVar.Value; }; scaleVar.SetDefinition("min=-2 max=2 step=0.01 precision=2"); var separator = new Separator(exampleBar); var testButton = new AntTweakBar.Button(exampleBar); testButton.Label = "Click me!"; testButton.Clicked += delegate { MessageBox.Show("Button Clicked!"); }; // The renderer needs to recreate some resources on window resize form.Resize += delegate { renderer.Resize(form.ClientSize); }; // In the main loop, render stuff, then the bar(s), then present to screen RenderLoop.Run(form, () => { renderer.Render(); form.Context.Draw(); renderer.Present(); }); } } } } }
/// <summary> /// Entry point - pass "verbose" as a command-line /// argument to initialize Embree in verbose mode. /// </summary> public static int Main(String[] args) { try { var verbose = (args.Length == 1 && args[0].ToLower() == "verbose"); if (verbose) { Console.WriteLine("Embree.NET Sample [VERBOSE]"); Console.WriteLine("==========================="); RTC.Register("verbose=999"); // max verbosity? } else { Console.WriteLine("Embree.NET Sample"); Console.WriteLine("================="); } Console.WriteLine(""); // this is for debugging Console.WriteLine("[+] " + Bits + "-bit mode."); Console.WriteLine("[+] Building a test scene."); using (var renderer = new Renderer()) { var pixBuf = new PixelBuffer(1920, 1080); Console.WriteLine("[+] Now rendering."); renderer.Render(pixBuf); // benchmark? Console.WriteLine("[+] Saving image to 'render.png'."); pixBuf.SaveToFile("render.png"); // save to png format } if (verbose) RTC.Unregister(); return EXIT_SUCCESS; } catch (Exception e) { var msg = e is AggregateException ? e.InnerException.Message : e.Message; Console.WriteLine(String.Format("[!] Error: {0}.", msg)); Console.WriteLine("\n========= STACK TRACE =========\n"); Console.WriteLine(e.StackTrace); return EXIT_FAILURE; } }
/// <summary> /// Entry point - pass "verbose" as a command-line /// argument to initialize Embree in verbose mode. /// </summary> public static int Main(String[] args) { try { var verbose = (args.Select(s => s.ToLower()).Contains("verbose")); var flags = ParseCommandLineArguments(args); if (verbose) { Console.WriteLine("Embree.NET Sample [VERBOSE]"); Console.WriteLine("==========================="); } else { Console.WriteLine("Embree.NET Sample"); Console.WriteLine("================="); } Console.WriteLine(""); // this is for debugging Console.WriteLine("[+] " + Bits + "-bit mode."); Console.WriteLine("[+] Building a test scene."); using (Device device = new Device(verbose)) { using (var renderer = new Renderer(device)) { if (flags.HasFlag(TraversalFlags.Single)) { var pixBuf = new PixelBuffer(1920, 1080); Console.WriteLine("[+] Now rendering single."); renderer.Render(pixBuf, TraversalFlags.Single); // benchmark? Console.WriteLine("[+] Saving image to 'render_single.png'."); pixBuf.SaveToFile("render_single.png"); // save to png format } if (flags.HasFlag(TraversalFlags.Packet4)) { var pixBuf = new PixelBuffer(1920, 1080); Console.WriteLine("[+] Now rendering packet 4."); renderer.Render(pixBuf, TraversalFlags.Packet4); // benchmark? Console.WriteLine("[+] Saving image to 'render_packet4.png'."); pixBuf.SaveToFile("render_packet4.png"); // save to png format } if (flags.HasFlag(TraversalFlags.Packet8)) { var pixBuf = new PixelBuffer(1920, 1080); Console.WriteLine("[+] Now rendering packet 8."); renderer.Render(pixBuf, TraversalFlags.Packet8); // benchmark? Console.WriteLine("[+] Saving image to 'render_packet8.png'."); pixBuf.SaveToFile("render_packet8.png"); // save to png format } } } return(EXIT_SUCCESS); } catch (Exception e) { var msg = e is AggregateException ? e.InnerException.Message : e.Message; Console.WriteLine(String.Format("[!] Error: {0}.", msg)); Console.WriteLine("\n========= STACK TRACE =========\n"); Console.WriteLine(e.StackTrace); return(EXIT_FAILURE); } }