mirror of
https://github.com/tildearrow/furnace.git
synced 2024-10-31 18:12:40 +00:00
GUI: no more rectangles
when font fails to load
This commit is contained in:
parent
c98f21f1e2
commit
05b10bb50a
5 changed files with 26 additions and 7 deletions
|
@ -94,13 +94,14 @@ static void ImGui_ImplSDLRenderer_SetupRenderState()
|
|||
SDL_RenderSetClipRect(bd->SDLRenderer, NULL);
|
||||
}
|
||||
|
||||
void ImGui_ImplSDLRenderer_NewFrame()
|
||||
bool ImGui_ImplSDLRenderer_NewFrame()
|
||||
{
|
||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
||||
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplSDLRenderer_Init()?");
|
||||
|
||||
if (!bd->FontTexture)
|
||||
ImGui_ImplSDLRenderer_CreateDeviceObjects();
|
||||
return ImGui_ImplSDLRenderer_CreateDeviceObjects();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
||||
|
|
|
@ -21,7 +21,7 @@ struct SDL_Renderer;
|
|||
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer);
|
||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_NewFrame();
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// Called by Init/NewFrame/Shutdown
|
||||
|
|
|
@ -95,13 +95,15 @@ static void ImGui_ImplSDLRenderer_SetupRenderState()
|
|||
SDL_RenderSetClipRect(bd->SDLRenderer, NULL);
|
||||
}
|
||||
|
||||
void ImGui_ImplSDLRenderer_NewFrame()
|
||||
bool ImGui_ImplSDLRenderer_NewFrame()
|
||||
{
|
||||
ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData();
|
||||
IM_ASSERT(bd != NULL && "Did you call ImGui_ImplSDLRenderer_Init()?");
|
||||
|
||||
if (!bd->FontTexture)
|
||||
ImGui_ImplSDLRenderer_CreateDeviceObjects();
|
||||
return ImGui_ImplSDLRenderer_CreateDeviceObjects();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data)
|
||||
|
|
|
@ -21,7 +21,7 @@ struct SDL_Renderer;
|
|||
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer);
|
||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_NewFrame();
|
||||
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// Called by Init/NewFrame/Shutdown
|
||||
|
|
|
@ -3750,9 +3750,13 @@ bool FurnaceGUI::loop() {
|
|||
});
|
||||
}
|
||||
|
||||
bool fontsFailed=false;
|
||||
|
||||
layoutTimeBegin=SDL_GetPerformanceCounter();
|
||||
|
||||
ImGui_ImplSDLRenderer_NewFrame();
|
||||
if (!ImGui_ImplSDLRenderer_NewFrame()) {
|
||||
fontsFailed=true;
|
||||
}
|
||||
ImGui_ImplSDL2_NewFrame(sdlWin);
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
@ -5792,6 +5796,18 @@ bool FurnaceGUI::loop() {
|
|||
willCommit=false;
|
||||
}
|
||||
|
||||
if (fontsFailed) {
|
||||
showError("it appears I couldn't load these fonts. any setting you can check?");
|
||||
logE("couldn't load fonts");
|
||||
ImGui::GetIO().Fonts->Clear();
|
||||
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
|
||||
patFont=mainFont;
|
||||
ImGui_ImplSDLRenderer_DestroyFontsTexture();
|
||||
if (!ImGui::GetIO().Fonts->Build()) {
|
||||
logE("error again while building font atlas!");
|
||||
}
|
||||
}
|
||||
|
||||
if (!editOptsVisible) {
|
||||
latchTarget=0;
|
||||
latchNibble=false;
|
||||
|
|
Loading…
Reference in a new issue