studio: share ImGui and ImPlot contexts across python child extension modules.

Each pybind extension module holds its own copy of the ImGui/ImPlot globals (extension modules are loaded RTLD_LOCAL), so the viewer that owns the contexts must share the pointers explicitly. Without this, client plotting GUIs and user plotting scripts (e.g. the implot sample) crash on null context pointers.

PiperOrigin-RevId: 951917287
Change-Id: I639a173c2ae9f1af4feaf57aff7b5c81854b7393
This commit is contained in:
Matija Kecman
2026-07-21 23:40:32 -07:00
committed by Copybara-Service
parent 91bb075108
commit e0224c6440
5 changed files with 54 additions and 19 deletions
@@ -55,10 +55,11 @@ class Renderer {
std::vector<std::byte> pixels(width * height * 3);
{
py::gil_scoped_release no_gil;
impl_->Render(
model.get(), data.get(), perturb ? perturb.value().get() : nullptr,
camera ? camera.value().get() : nullptr,
vis_option ? vis_option.value().get() : nullptr, width, height, pixels);
impl_->Render(model.get(), data.get(),
perturb ? perturb.value().get() : nullptr,
camera ? camera.value().get() : nullptr,
vis_option ? vis_option.value().get() : nullptr, width,
height, pixels);
}
return pybind11::bytes((const char*)pixels.data(), pixels.size());
}