Adding new windows dynamically #901
-
Hi, I'm wondering if it's currently possible to create and open new windows dynamically, and if so where is the best time and place place to do it? I've experimented by modifying the vsgdynamicview example (unsuccessfully so far), by creating and adding a new Window and CommandGraph in a vsg::Operation and compiling the commandGraph, then addding it with addRecordAndSubmitTaskAndPresentation before calling updateViewer, but I get the impression from the errors though that there's a bit more to it when it comes to adding windows/ CommandGraph's than rather than just views. Any advice welcome. Thanks Jamie |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
It's hard to provide advice without seeing the code to be able to comment on. Code for adding/removing windows is a very recent addition so there isn't yet a neat example illustrating/testing it. The vsgdynamcview example is focused on just adding new vsg::View, but is probably a good starting place. Perhaps a vsgdynamicwindows would be a good follow up example. If you've modified vsgdynamicview for your own testing could you post these changes so we can review the code and test it out ourselves. |
Beta Was this translation helpful? Give feedback.
-
I have done some further work and got a solution that works without any Vulkan debug errors, but requires a bit of awkward finishing and beginning of the new frame to cope with how this example uses an update operation to do the merge: I think the best way to handle the addition of the new window to viewer is to do the merge after the present frame's viewer.present() call. Modifying the main frame loop loop to have a list of post viewer.present() update operations would be a bit cumbersome but would properly be the cleanest way to do things. |
Beta Was this translation helpful? Give feedback.
-
I have got the multi-thread load and window creation working well enough now that I've made it an official vsgdynamicwindows example, which can now part of vsgExamples master: I added two models & window combination to the multi-thread load part and found that when one of the windows was a paged database the DatabasePager could be assigned to the Viewer then subsequently discarded by the next load. To fix bug this I had to modify the Viewer::assignRecordAndSubmitTaskAndPresentation(..) method to assign any DatabasePager that had been previously assigned. This fix is merged with VSG master: 5dcb64f. With the latest incarnation of the vsgdynamicwindows code I use a vsg::OperationQueue to schedule merge operations that are then called in the frame loop just after the viewer.present(). // rendering main loop
while (viewer->advanceToNextFrame() && (numFrames < 0 || (numFrames--) > 0))
{
// pass any events into EventHandlers assigned to the Viewer
viewer->handleEvents();
viewer->update();
viewer->recordAndSubmit();
viewer->present();
// do any viewer additions after present
while(auto op = postPresentOperationQueue->take()) op->run();
} This is a bit clunky so I'm now considering whether the vsg::UpdateOperation to is current just used for Viewer::update() operations could be generalized so that the we could have vsg::FrameOperations that we can specify which point in the frame the operation should be run, rather than tying it just to update operations. I will ponder on this, and update the VSG and the new vsgdynamicwindows example if I decide to go this route. |
Beta Was this translation helpful? Give feedback.
I have got the multi-thread load and window creation working well enough now that I've made it an official vsgdynamicwindows example, which can now part of vsgExamples master:
vsg-dev/vsgExamples#237
I added two models & window combination to the multi-thread load part and found that when one of the windows was a paged database the DatabasePager could be assigned to the Viewer then subsequently discarded by the next load. To fix bug this I had to modify the Viewer::assignRecordAndSubmitTaskAndPresentation(..) method to assign any DatabasePager that had been previously assigned. This fix is merged with VSG master: 5dcb64f.
With the latest incarnation of the vsgdynamicwindows code I use a v…