mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 13:28:20 +00:00
Complete basic imgui integration
This commit is contained in:
@ -49,10 +49,25 @@ func (w *Window) handleInputs() {
|
||||
imIO.AddMouseWheelDelta(float32(xDelta), float32(yDelta))
|
||||
|
||||
case *sdl.KeyboardEvent:
|
||||
input.HandleKeyboardEvent(e)
|
||||
|
||||
if e.Type == sdl.KEYDOWN || e.Type == sdl.KEYUP {
|
||||
imIO.AddKeyEvent(nmageimgui.SdlScancodeToImGuiKey(e.Keysym.Scancode), e.Type == sdl.KEYDOWN)
|
||||
input.HandleKeyboardEvent(e)
|
||||
imIO.AddKeyEvent(nmageimgui.SdlScancodeToImGuiKey(e.Keysym.Scancode), e.Type == sdl.KEYDOWN)
|
||||
|
||||
// Send modifier key updates to imgui
|
||||
if e.Keysym.Sym == sdl.K_LCTRL || e.Keysym.Sym == sdl.K_RCTRL {
|
||||
imIO.SetKeyCtrl(e.Type == sdl.KEYDOWN)
|
||||
}
|
||||
|
||||
if e.Keysym.Sym == sdl.K_LSHIFT || e.Keysym.Sym == sdl.K_RSHIFT {
|
||||
imIO.SetKeyShift(e.Type == sdl.KEYDOWN)
|
||||
}
|
||||
|
||||
if e.Keysym.Sym == sdl.K_LALT || e.Keysym.Sym == sdl.K_RALT {
|
||||
imIO.SetKeyAlt(e.Type == sdl.KEYDOWN)
|
||||
}
|
||||
|
||||
if e.Keysym.Sym == sdl.K_LGUI || e.Keysym.Sym == sdl.K_RGUI {
|
||||
imIO.SetKeySuper(e.Type == sdl.KEYDOWN)
|
||||
}
|
||||
|
||||
case *sdl.TextInputEvent:
|
||||
|
||||
5
main.go
5
main.go
@ -287,6 +287,9 @@ func (g *OurGame) Update() {
|
||||
simpleMat.SetUnifVec3("lightColor1", lightColor1)
|
||||
}
|
||||
|
||||
// an cimgui text box using cimgui
|
||||
newimgui.InputTextWithHint("Test", "", &testString, newimgui.InputTextFlagsAllowTabInput, nil)
|
||||
|
||||
if input.KeyClicked(sdl.K_F4) {
|
||||
fmt.Printf("Pos: %s; Forward: %s; |Forward|: %f\n", cam.Pos.String(), cam.Forward.String(), cam.Forward.Mag())
|
||||
}
|
||||
@ -294,6 +297,8 @@ func (g *OurGame) Update() {
|
||||
g.Win.SDLWin.SetTitle(fmt.Sprint("nMage (", timing.GetAvgFPS(), " fps)"))
|
||||
}
|
||||
|
||||
var testString string
|
||||
|
||||
func (g *OurGame) updateCameraLookAround() {
|
||||
|
||||
mouseX, mouseY := input.GetMouseMotion()
|
||||
|
||||
Reference in New Issue
Block a user