From 5d4acbfc435fc257c3fa59dfe917e0db749acea4 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sat, 5 Mar 2022 18:54:46 +0800 Subject: [PATCH] rescaling of the timebars --- internal/game/render_debuginfo.go | 35 +++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/internal/game/render_debuginfo.go b/internal/game/render_debuginfo.go index 91efbbb..f452f92 100644 --- a/internal/game/render_debuginfo.go +++ b/internal/game/render_debuginfo.go @@ -13,14 +13,14 @@ import ( ) const ( - timebarN = 700 - timebarScale = 128 + timebarN = 700 ) var ( - colorset = [...]imgui.PackedColor{4289753676, 4283598045, 4285048917, 4283584196, 4289950337, 4284512403, 4291005402, 4287401100, 4285839820, 4291671396} - timebars [timebarN][]int // height of each bar set - timebari int + colorset = [...]imgui.PackedColor{4289753676, 4283598045, 4285048917, 4283584196, 4289950337, 4284512403, 4291005402, 4287401100, 4285839820, 4291671396} + timebars [timebarN][]int // height of each bar set + timebari int + timebarScale int = 64 ) func (g *Game) renderDebugInfo() { @@ -41,11 +41,23 @@ func (g *Game) renderDebugInfo() { igwrap.TextBackgroundV(colorset[3], pad, "Lighting") imgui.SameLine() igwrap.TextBackgroundV(colorset[4], pad, "Postfx") + imgui.SameLine() + igwrap.TextBackground("[Hover]") + if imgui.IsItemHoveredV(imgui.HoveredFlagsAllowWhenDisabled) { + _, wheely := imgui.CurrentIO().MouseWheel() + if math.Abs(float64(wheely)) > 1e-3 { + if wheely > 0 { + timebarScale = util.Mini(timebarScale*2, 128) + } else { // < 0 + timebarScale = util.Maxi(timebarScale/2, 1) + } + } + } isize := asset.WorldTextureAtlas.ImageSize igwrap.TextBackground("Texture Atlas Size: (%dx%d)", isize[0], isize[1]) imgui.SameLine() - igwrap.TextBackground("[Hover]") + igwrap.TextBackground("[Scroll]") if imgui.IsItemHoveredV(imgui.HoveredFlagsAllowWhenDisabled) { _, wheely := imgui.CurrentIO().MouseWheel() if math.Abs(float64(wheely)) > 1e-3 { @@ -79,11 +91,11 @@ func (g *Game) renderDebugInfo() { // Push the next bar timebars[timebari] = []int{ - int(io.Diagnostics.Times.RenderPasses.Depthmap.Nanoseconds() * timebarScale / 1024 / 1024), - int(io.Diagnostics.Times.RenderPasses.Geometry.Nanoseconds() * timebarScale / 1024 / 1024), - int(io.Diagnostics.Times.RenderPasses.SSAO.Nanoseconds() * timebarScale / 1024 / 1024), - int(io.Diagnostics.Times.RenderPasses.Lighting.Nanoseconds() * timebarScale / 1024 / 1024), - int(io.Diagnostics.Times.RenderPasses.Postfx.Nanoseconds() * timebarScale / 1024 / 1024), + int(io.Diagnostics.Times.RenderPasses.Depthmap.Nanoseconds()), + int(io.Diagnostics.Times.RenderPasses.Geometry.Nanoseconds()), + int(io.Diagnostics.Times.RenderPasses.SSAO.Nanoseconds()), + int(io.Diagnostics.Times.RenderPasses.Lighting.Nanoseconds()), + int(io.Diagnostics.Times.RenderPasses.Postfx.Nanoseconds()), } timebari++ if timebari >= len(timebars) { @@ -96,6 +108,7 @@ func (g *Game) renderDebugInfo() { for i, l := range timebars { ex := 0 for j, d := range l { + d = d * timebarScale / 1024 / 1024 dl.AddLine(imgui.Vec2{X: float32(i), Y: float32(size[1] - ex)}, imgui.Vec2{X: float32(i), Y: float32(size[1] - ex - d)}, colorset[j]) ex += d }