From d1f47316ae3936b4b7b3feeecf4def5993cb90ed Mon Sep 17 00:00:00 2001 From: bloeys Date: Sun, 27 Feb 2022 11:11:20 +0400 Subject: [PATCH] Allow imgui within init --- engine/game.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engine/game.go b/engine/game.go index 1b46247..9cf12fb 100755 --- a/engine/game.go +++ b/engine/game.go @@ -23,12 +23,19 @@ type Game interface { func Run(g Game) { - g.Init() - w := g.GetWindow() ui := g.GetImGUI() + + //Simulate an imgui frame during init so any imgui calls are allowed within init + tempWidth, tempHeight := w.SDLWin.GetSize() + tempFBWidth, tempFBHeight := w.SDLWin.GLGetDrawableSize() + ui.FrameStart(float32(tempWidth), float32(tempHeight)) + g.Init() + ui.Render(float32(tempWidth), float32(tempHeight), tempFBWidth, tempFBHeight) + for g.ShouldRun() { + //PERF: Cache these width, height := w.SDLWin.GetSize() fbWidth, fbHeight := w.SDLWin.GLGetDrawableSize()