How to refresh the rendering of polyscope scene inside a for loop?
Polyscope is a very nice framework. how to implement the following situations?
- after click a button on UI, start a for loop
- every iteration of the loop will change the polyscope scene and refresh the rendering (it seems polyscope can not handle it now).
- as the loop is time-cost, it is possible to run it in anther theading? it seems that polyscope can not handle threading now.
Thanks.
Hi!
Yes, because Polyscope uses ImGUI for UIs, it is a bit difficult to start an updating, user-interactive loop when you click a button. Generally, the best paradigm is to write your user callback function (which gets called once per rendering iteration by Polyscope) such that one iteration of the loop gets called each time, like:
void myCallback {
static bool functionRunning = false;
if (ImGui::Button("start operation")) {
functionRunning = true;
}
if(functionRunning) {
// do one iteration of your function
}
};
// ... elsewhere ...
polyscope::userCallback = myCallback;
For threading, you're correct that Polyscope does not support threading right now. And generally speaking it would be difficult to support threading, since most Polyscope calls do some openGL work under the hood, and openGL operations generally must be called from the main thread. At most, you could spawn a thread to do your own app's work when a button is pressed, so long as that work does not make any Polyscope calls.