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(); }); } } } } }
[SetUp] public new void Init() { Variable = new BoolVariable(Bar); }