mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 13:28:20 +00:00
Run init within an imgui frame
This commit is contained in:
@ -24,26 +24,25 @@ func Run(g Game, w *Window, ui nmageimgui.ImguiInfo) {
|
|||||||
|
|
||||||
isRunning = true
|
isRunning = true
|
||||||
|
|
||||||
// Simulate 2 imgui frames, one before and one after g.Init so any imgui calls are allowed within init.
|
// Run init with an active Imgui frame to allow init full imgui access
|
||||||
// Calling before is required for things like push font.
|
timing.FrameStarted()
|
||||||
tempWidth, tempHeight := w.SDLWin.GetSize()
|
w.handleInputs()
|
||||||
tempFBWidth, tempFBHeight := w.SDLWin.GLGetDrawableSize()
|
|
||||||
ui.FrameStart(float32(tempWidth), float32(tempHeight))
|
width, height := w.SDLWin.GetSize()
|
||||||
ui.Render(float32(tempWidth), float32(tempHeight), tempFBWidth, tempFBHeight)
|
ui.FrameStart(float32(width), float32(height))
|
||||||
|
|
||||||
g.Init()
|
g.Init()
|
||||||
|
|
||||||
// Second imgui frame
|
fbWidth, fbHeight := w.SDLWin.GLGetDrawableSize()
|
||||||
tempWidth, tempHeight = w.SDLWin.GetSize()
|
ui.Render(float32(width), float32(height), fbWidth, fbHeight)
|
||||||
tempFBWidth, tempFBHeight = w.SDLWin.GLGetDrawableSize()
|
|
||||||
ui.FrameStart(float32(tempWidth), float32(tempHeight))
|
timing.FrameEnded()
|
||||||
ui.Render(float32(tempWidth), float32(tempHeight), tempFBWidth, tempFBHeight)
|
|
||||||
|
|
||||||
for isRunning {
|
for isRunning {
|
||||||
|
|
||||||
//PERF: Cache these
|
//PERF: Cache these
|
||||||
width, height := w.SDLWin.GetSize()
|
width, height = w.SDLWin.GetSize()
|
||||||
fbWidth, fbHeight := w.SDLWin.GLGetDrawableSize()
|
fbWidth, fbHeight = w.SDLWin.GLGetDrawableSize()
|
||||||
|
|
||||||
timing.FrameStarted()
|
timing.FrameStarted()
|
||||||
w.handleInputs()
|
w.handleInputs()
|
||||||
|
|||||||
Reference in New Issue
Block a user