mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 13:28:20 +00:00
Frame time graph
This commit is contained in:
18
main.go
18
main.go
@ -194,9 +194,14 @@ const (
|
|||||||
unscaledWindowHeight = 720
|
unscaledWindowHeight = 720
|
||||||
|
|
||||||
PROFILE_CPU = true
|
PROFILE_CPU = true
|
||||||
|
|
||||||
|
frameTimesMsSamples = 10000
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
frameTimesMsIndex int = 0
|
||||||
|
frameTimesMs []float32 = make([]float32, 0, frameTimesMsSamples)
|
||||||
|
|
||||||
window engine.Window
|
window engine.Window
|
||||||
|
|
||||||
pitch float32 = 0
|
pitch float32 = 0
|
||||||
@ -838,6 +843,19 @@ func (g *Game) showDebugWindow() {
|
|||||||
imgui.LabelText("FPS", fmt.Sprint(timing.GetAvgFPS()))
|
imgui.LabelText("FPS", fmt.Sprint(timing.GetAvgFPS()))
|
||||||
imgui.PopStyleColor()
|
imgui.PopStyleColor()
|
||||||
|
|
||||||
|
if len(frameTimesMs) < frameTimesMsSamples {
|
||||||
|
frameTimesMs = append(frameTimesMs, timing.DT()*1000)
|
||||||
|
} else {
|
||||||
|
frameTimesMs[frameTimesMsIndex] = timing.DT() * 1000
|
||||||
|
|
||||||
|
frameTimesMsIndex++
|
||||||
|
if frameTimesMsIndex >= len(frameTimesMs) {
|
||||||
|
frameTimesMsIndex = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imgui.PlotLinesFloatPtrV("Frame Times", frameTimesMs, int32(len(frameTimesMs)), 0, "", 0, 16, imgui.Vec2{Y: 200}, 4)
|
||||||
|
|
||||||
imgui.Spacing()
|
imgui.Spacing()
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
|
|||||||
Reference in New Issue
Block a user