Perform ImGui calls only when a context is available.
PiperOrigin-RevId: 865072901 Change-Id: I4b35d953df2f686d2f02f8e0aede7109729b5e04
This commit is contained in:
committed by
Copybara-Service
parent
144a8a9e85
commit
1bd72428f1
@@ -208,6 +208,10 @@ void GuiView::DestroyTexture(ImTextureData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GuiView::UpdateRenderable() {
|
void GuiView::UpdateRenderable() {
|
||||||
|
if (!ImGui::GetCurrentContext()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare the imgui draw commands. We must call this function even if we do
|
// Prepare the imgui draw commands. We must call this function even if we do
|
||||||
// not plan on rendering anything to ensure imgui state is updated.
|
// not plan on rendering anything to ensure imgui state is updated.
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ Renderer::Renderer(void* native_window) : native_window_(native_window) {
|
|||||||
if (native_window == nullptr) {
|
if (native_window == nullptr) {
|
||||||
graphics_api_context_ = CreateEglContext();
|
graphics_api_context_ = CreateEglContext();
|
||||||
}
|
}
|
||||||
ImGui_ImplOpenGL3_Init();
|
if (ImGui::GetCurrentContext()) {
|
||||||
|
ImGui_ImplOpenGL3_Init();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,9 +119,11 @@ void Renderer::Render(const mjModel* model, mjData* data,
|
|||||||
// The filament backend knows how to renders the ImGui draw data. For the
|
// The filament backend knows how to renders the ImGui draw data. For the
|
||||||
// classic backend, we need to render the ImGui draw data ourselves.
|
// classic backend, we need to render the ImGui draw data ourselves.
|
||||||
#ifdef MUJOCO_RENDERER_CLASSIC_OPENGL
|
#ifdef MUJOCO_RENDERER_CLASSIC_OPENGL
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
if (ImGui::GetCurrentContext()) {
|
||||||
ImGui::Render();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui::Render();
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (render_to_texture) {
|
if (render_to_texture) {
|
||||||
|
|||||||
Reference in New Issue
Block a user