refactor ImGUI code files

This commit is contained in:
2022-02-10 19:58:51 +08:00
parent bb33972616
commit 06cd549eb7
13 changed files with 172 additions and 50 deletions

View File

@@ -6,7 +6,7 @@ import (
"os"
"time"
"edgaru089.ml/go/gl01/internal/igwrap"
"edgaru089.ml/go/gl01/internal/igwrap/backend"
"edgaru089.ml/go/gl01/internal/io"
"edgaru089.ml/go/gl01/internal/render"
"edgaru089.ml/go/gl01/internal/util/itype"
@@ -105,13 +105,13 @@ func (g *Game) Init(win *glfw.Window) {
win.SetMouseButtonCallback(func(w *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey) {
if g.paused {
igwrap.MouseButtonCallback(button, action)
backend.MouseButtonCallback(button, action)
}
})
win.SetKeyCallback(func(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
if g.paused {
igwrap.KeyCallback(key, action)
backend.KeyCallback(key, action)
}
if action == glfw.Press {
if g.paused {
@@ -157,13 +157,13 @@ func (g *Game) Init(win *glfw.Window) {
win.SetCharCallback(func(w *glfw.Window, char rune) {
if g.paused {
igwrap.InputCallback(char)
backend.InputCallback(char)
}
})
win.SetScrollCallback(func(w *glfw.Window, xpos, ypos float64) {
if g.paused {
igwrap.MouseScrollCallback(xpos, ypos)
backend.MouseScrollCallback(xpos, ypos)
}
})
@@ -173,7 +173,7 @@ const airAccel = 0.1
// Update updates the game state, not necessarily in the main thread.
func (g *Game) Update(win *glfw.Window, delta time.Duration) {
igwrap.NewFrame()
backend.NewFrame()
imgui.ShowDemoWindow(nil)
if !g.paused {
@@ -251,5 +251,5 @@ func (g *Game) Render(win *glfw.Window) {
g.worldrender.Render(g.world, g.view)
render.Framewire.Render(g.view)
igwrap.Render(win)
backend.Render(win)
}