private void GraphMouseDown(object sender, MouseEventArgs e) { PerfGraph g = sender as PerfGraph; if (g != null && e.Button == MouseButtons.Right) { g.Enabled = !g.Enabled; } }
public LineHandle(ref Object line, PerfGraph owner) { if (string.Compare(line.GetType().Name, "Line") != 0) { throw new ArithmeticException( "LineHandle: First Parameter must be " + "type of 'Line' cast to base 'Object'"); } _line = (Line)line; _owner = owner; }
public LineHandle(ref Object line, PerfGraph owner) { if (string.Compare(line.GetType().Name, "Line") != 0) { throw new ArithmeticException( "LineHandle: First Parameter must be " + "type of 'Line' cast to base 'Object'"); } _line = (Line) line; _owner = owner; }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); PerfGraph.UpdateGraph((float)e.Time); GL.Viewport(0, 0, Width, Height); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); NanoVG.nvgBeginFrame(ctx, Width, Height, 1); if (screen) { screen.Draw(ctx); } PerfGraph.RenderGraph(ctx, 5, 5); NanoVG.nvgEndFrame(ctx); this.SwapBuffers(); }
public RenderManager(GameWindow window, CsTerrainGenerator generator) { _window = window; _generator = generator; _fgJobs = new ConcurrentQueue <IJob>(); _bgJobs = new ConcurrentQueue <IJob>(); _nvg = GlNanoVg.CreateGl(NvgCreateFlags.StencilStrokes | NvgCreateFlags.AntiAlias); _ui = new KuatWindow(window, new KuatFont("sans", 16)); KuatButton b; KuatKnob k; KuatIndicator i; _ui.Controls.Add(b = new KuatButton("bTest") { Location = new Point(50, 50), Size = new Size(60, 23), Text = "Button" }); b.Click += (sender, args) => { Lumberjack.Info("Click!"); }; _ui.Controls.Add(new KuatCheckbox("cbTest") { Location = new Point(50, 90), Size = new Size(14, 14), Text = "Checkbox" }); _ui.Controls.Add(k = new KuatKnob("kTest") { Location = new Point(50, 130) }); _ui.Controls.Add(i = new KuatIndicator("iTest") { Location = new Point(120, 130) }); k.ValueChanged += (sender, args) => { i.Lit = k.Value > 0; }; _ui.Controls.Add(new KuatTextBox("tbTest") { Location = new Point(170, 90), Size = new Size(120, 23), ForeColor = Color.Black }); var rMono = _nvg.CreateFont("mono", EmbeddedFiles.ibmplexmono); if (rMono == -1) { throw new ApplicationException("Unable to load mono font"); } var rSans = _nvg.CreateFont("sans", EmbeddedFiles.ibmplexsans); if (rSans == -1) { throw new ApplicationException("Unable to load sans font"); } _perfGraphFps = new PerfGraph(GraphRenderStyle.Fps, null, 40); _framebuffer = new Framebuffer(8); _framebuffer.Init(window.Width, window.Height); _framebufferUi = new Framebuffer(1); _framebufferUi.Init(window.Width, window.Height); _texRandom = LoadGlTexture(EmbeddedFiles.random); _shaderModel = new ShaderProgram(EmbeddedFiles.fs_model, EmbeddedFiles.vs_model); _shaderModel.Init(); _shaderScreen = new ShaderProgram(EmbeddedFiles.fs_screen, EmbeddedFiles.vs_screen); _shaderScreen.Init(); _workerHandle = new EventWaitHandle(false, EventResetMode.ManualReset); CreateChunks(); CreateScreenVao(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); GL.ClearColor(Color.Cornsilk); GlNanoVG.nvgCreateGL(ref ctx, (int)NVGcreateFlags.NVG_ANTIALIAS | (int)NVGcreateFlags.NVG_STENCIL_STROKES | (int)NVGcreateFlags.NVG_DEBUG); Fonts.Load(ctx, "sans", "Roboto-Regular.ttf"); Fonts.Load(ctx, "sans-bold", "Roboto-Bold.ttf"); Fonts.Load(ctx, "icons", "entypo.ttf"); screen = new Widget() .WithLocalPosition(Vector2.Zero) .WithSize(new Vector2(this.Width, this.Height)); { Window window = screen.AddNewWidget <Window> (); window.WithTitle("Button demo") .WithLocalPosition(new Vector2(15f, 50f)) .WithSize(new Vector2(250f, 400f)) .WithLayout(new GroupLayout()); // -- Push buttons window.AddNewWidget <Label> () .WithCaption("Push buttons") .WithFont("sans-bold"); window.AddNewWidget <Button> () .WithCaption("Plain button") .WithClickCallback((btn) => Console.WriteLine("Click!")); window.AddNewWidget <Button> () .WithCaption("Styled") .WithIcon((int)MonoNanoGUI.Font.Entypo.ICON_ROCKET, Button.IconAnchorType.LeftCentered); // -- Toggle buttons window.AddNewWidget <Label> () .WithCaption("Toggle buttons") .WithFont("sans-bold"); window.AddNewWidget <Button> () .WithFlags(Button.Flags.ToggleButton) .WithCaption("Toggle me"); // -- Radio buttons window.AddNewWidget <Label> () .WithCaption("Radio buttons") .WithFont("sans-bold"); window.AddNewWidget <Button> () .WithCaption("Radio button 1") .WithFlags(Button.Flags.RadioButton); window.AddNewWidget <Button> () .WithCaption("Radio button 2") .WithFlags(Button.Flags.RadioButton); // -- Tool buttons palette window.AddNewWidget <Label> () .WithCaption("A tool palette") .WithFont("sans-bold"); Widget tools = window.AddNewWidget <Widget> () .WithLayout(new BoxLayout(Layout.Orientation.Horizontal, Layout.Alignment.Middle, 0, 6)); tools.AddChild(Button.MakeToolButton((int)MonoNanoGUI.Font.Entypo.ICON_CLOUD)); tools.AddChild(Button.MakeToolButton((int)MonoNanoGUI.Font.Entypo.ICON_FF)); tools.AddChild(Button.MakeToolButton((int)MonoNanoGUI.Font.Entypo.ICON_COMPASS)); tools.AddChild(Button.MakeToolButton((int)MonoNanoGUI.Font.Entypo.ICON_INSTALL)); // -- Popup buttons window.AddNewWidget <Label> () .WithCaption("Popup buttons") .WithFont("sans-bold"); PopupButton pButton = window.AddNewWidget <PopupButton> () .WithIcon((int)MonoNanoGUI.Font.Entypo.ICON_EXPORT) .WithCaption("Popup") as PopupButton; pButton.popup.WithLayout(new GroupLayout()); pButton.popup.AddNewWidget <Label> () .WithCaption("Arbitrary widgets can be placed here"); pButton.popup.AddNewWidget <CheckBox> () .WithCaption("A check box"); PopupButton rpButton = pButton.popup.AddNewWidget <PopupButton> () .WithIcon((int)MonoNanoGUI.Font.Entypo.ICON_FLASH) .WithCaption("Recursive popup") as PopupButton; rpButton.popup.WithLayout(new GroupLayout()); rpButton.popup.AddNewWidget <CheckBox> () .WithCaption("Another check box"); } screen.PerformLayout(ctx); PerfGraph.InitGraph((int)GraphrenderStyle.GRAPH_RENDER_FPS, "FPS"); Console.WriteLine("Load"); //Console.WriteLine ("Test Unicode to UTF8 = " + Fonts.UnicodeToUTF8 (0).Length); }
public DebugUserInterface() { _fpsGraph = new PerfGraph(GraphRenderStyle.Milliseconds, "render"); _tpsGraph = new PerfGraph(GraphRenderStyle.Milliseconds, "update"); }