Separate imgui contexts for TV and Pad windows. (#664)

This commit is contained in:
goeiecool9999 2023-02-18 11:56:43 +01:00 committed by GitHub
parent daf3ef060a
commit cbb79fd34c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 131 additions and 184 deletions

View file

@ -37,6 +37,34 @@ bool Renderer::GetVRAMInfo(int& usageInMB, int& totalInMB) const
return false;
}
void Renderer::Initialize()
{
// imgui
imguiFontAtlas = new ImFontAtlas();
imguiFontAtlas->AddFontDefault();
auto setupContext = [](ImGuiContext* context){
ImGui::SetCurrentContext(context);
ImGuiIO& io = ImGui::GetIO();
io.WantSaveIniSettings = false;
io.IniFilename = nullptr;
};
imguiTVContext = ImGui::CreateContext(imguiFontAtlas);
imguiPadContext = ImGui::CreateContext(imguiFontAtlas);
setupContext(imguiTVContext);
setupContext(imguiPadContext);
}
void Renderer::Shutdown()
{
// imgui
ImGui::DestroyContext(imguiTVContext);
ImGui::DestroyContext(imguiPadContext);
delete imguiFontAtlas;
}
bool Renderer::ImguiBegin(bool mainWindow)
{
sint32 w = 0, h = 0;
@ -50,6 +78,9 @@ bool Renderer::ImguiBegin(bool mainWindow)
if (w == 0 || h == 0)
return false;
// select the right context
ImGui::SetCurrentContext(mainWindow ? imguiTVContext : imguiPadContext);
const Vector2f window_size{ (float)w,(float)h };
auto& io = ImGui::GetIO();
io.DisplaySize = { window_size.x, window_size.y }; // should be only updated in the renderer and only when needed