[client] imgui: render twice for alerts

When using jitRender, or on the first frame of an alert the window
doesn't get resized immediately causing it to cut off the end of the
text.

ImGui needs two passes to calulate the bounding box for automatically
sized windows, this is per it's design and not a bug, see:

https://github.com/ocornut/imgui/issues/2158#issuecomment-434223618
This commit is contained in:
Geoffrey McRae 2022-01-08 00:46:16 +11:00
parent ec0bd6adc8
commit 35334333ac
2 changed files with 15 additions and 0 deletions

View File

@ -637,6 +637,8 @@ void app_alert(LG_MsgAlert type, const char * fmt, ...)
g_state.alertTimeout = microtime() + ALERT_TIMEOUT;
g_state.alertType = type;
g_state.alertShow = true;
g_state.renderImGuiTwice = true;
app_invalidateWindow(false);
}
@ -803,6 +805,8 @@ int app_renderOverlay(struct Rect * rects, int maxRects)
g_state.io->DeltaTime = (now - g_state.lastImGuiFrame) * 1e-9f;
g_state.lastImGuiFrame = now;
render_again:
igNewFrame();
if (g_state.overlayInput)
@ -871,6 +875,16 @@ int app_renderOverlay(struct Rect * rects, int maxRects)
igRender();
/* imgui requires two passes to calculate the bounding box of auto sized
* windows, this is by design
* ref: https://github.com/ocornut/imgui/issues/2158#issuecomment-434223618
*/
if (g_state.renderImGuiTwice)
{
g_state.renderImGuiTwice = false;
goto render_again;
}
return totalDamage ? -1 : totalRects;
}

View File

@ -61,6 +61,7 @@ struct AppState
bool modAlt;
bool modSuper;
uint64_t lastImGuiFrame;
bool renderImGuiTwice;
bool alertShow;
char * alertMessage;