add background for F3 text, fix single-channel texture display

This commit is contained in:
2022-02-10 21:13:55 +08:00
parent a17a43505c
commit a628fdb434
7 changed files with 44 additions and 11 deletions

View File

@ -54,13 +54,18 @@ func (g *Game) initImgui(win *glfw.Window) {
func (g *Game) imgui() {
if io.ShowDebugInfo {
imgui.SetNextWindowPosV(imgui.Vec2{}, imgui.ConditionAlways, imgui.Vec2{})
imgui.SetNextWindowSize(imgui.Vec2{X: float32(io.DisplaySize[0]), Y: float32(io.DisplaySize[1])})
if igwrap.Begin("F3", nil, imgui.WindowFlagsAlwaysAutoResize|imgui.WindowFlagsNoBackground|imgui.WindowFlagsNoNavFocus|imgui.WindowFlagsNoDecoration|imgui.WindowFlagsNoInputs|imgui.WindowFlagsNoSavedSettings|imgui.WindowFlagsNoFocusOnAppearing) {
igwrap.Text("Gl01(glfw%s, imgui%s) - compiled by %s[%s/%s]", glfw.GetVersionString(), imgui.Version(), runtime.Version(), runtime.GOOS, runtime.GOARCH)
igwrap.Text("CgoCalls:%d (%d lastframe), Goroutines:%d", runtime.NumCgoCall(), runtime.NumCgoCall()-g.gui.lastframeCgoCalls, runtime.NumGoroutine())
imgui.Text("")
bg := itype.Vec4f{0, 0, 0, 0.5}
pad := igwrap.Vec2f(imgui.CurrentStyle().ItemSpacing())
igwrap.TextBackground(bg, pad, "Gl01 compiled by %s/%s [%s/%s] (120AVG) %.1f FPS (%.3f frame)", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH, imgui.CurrentIO().Framerate(), 1000/imgui.CurrentIO().Framerate())
igwrap.TextBackground(bg, pad, "GLFW %s, Dear ImGUI %s", glfw.GetVersionString(), imgui.Version())
igwrap.TextBackground(bg, pad, "CgoCalls:%d (%d lastframe), Goroutines:%d", runtime.NumCgoCall(), runtime.NumCgoCall()-g.gui.lastframeCgoCalls, runtime.NumGoroutine())
imgui.Dummy(imgui.Vec2{X: 8, Y: 8})
pos := g.player.Position()
igwrap.Text("Player: (%.3f, %.5f, %.3f) - (Y%.2f, Z%.2f)", pos[0], pos[1], pos[2], g.rotY.Degrees(), g.rotZ)
igwrap.TextBackground(bg, pad, "Player: (%.3f, %.5f, %.3f) (Y%.2f, Z%.2f)", pos[0], pos[1], pos[2], g.rotY.Degrees(), g.rotZ)
imgui.End()
}
}