Skip to content

Commit

Permalink
Fixed delta time issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Ray committed Sep 11, 2020
1 parent 5a8fd29 commit bcaa791
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (ui *UI) Destroy() {

// NewFrame Call this at the beginning of the frame to tell the UI that the frame has started
func (ui *UI) NewFrame() {
if !ui.timer.IsZero() {
ui.io.SetDeltaTime(float32(time.Since(ui.timer).Seconds()))
}
ui.timer = time.Now()

// imgui requires that io be set before calling NewFrame
Expand All @@ -124,7 +127,6 @@ func (ui *UI) NewFrame() {

// update Handles general update type things and handle inputs. Called from ui.Draw.
func (ui *UI) update() {
ui.io.SetDeltaTime(float32(time.Since(ui.timer).Seconds()))
}

// Draw Draws the imgui UI to the Pixel Window
Expand Down

0 comments on commit bcaa791

Please sign in to comment.