To see what changes you will need to make to your own applications/libs have a look at the changes to the vsgExamples example vsgviewer below, the key changes are replacing use of vsg::GraphicsStage with the new vsg::CommandGraph/RenderGraph, and calling new Viewer update(), recordAndSubmit() and present() methods to kick off the traversal and rendering:
diff --git a/Desktop/vsgviewer/vsgviewer.cpp b/Desktop/vsgviewer/vsgviewer.cpp
index 0304a4e..1d46019 100644
--- a/Desktop/vsgviewer/vsgviewer.cpp
+++ b/Desktop/vsgviewer/vsgviewer.cpp
@@ -167,18 +167,9 @@ int main(int argc, char** argv)
if (maxPageLOD>=0) databasePager->targetMaxNumPagedLODWithHighResSubgraphs = maxPageLOD;
}
- // add a GraphicsStage to the Window to do dispatch of the command graph to the command buffer(s)
- auto graphicsStage = vsg::GraphicsStage::create(vsg_scene, camera);
- graphicsStage->databasePager = databasePager;
- window->addStage(graphicsStage);
-
- // compile the Vulkan objects
- viewer->compile();
-
// add close handler to respond the close window button and pressing escape
viewer->addEventHandler(vsg::CloseHandler::create(viewer));
-
if (pathFilename.empty())
{
viewer->addEventHandler(vsg::Trackball::create(camera));
@@ -198,18 +189,22 @@ int main(int argc, char** argv)
viewer->addEventHandler(vsg::AnimationPathHandler::create(camera, animationPath, viewer->start_point()));
}
+ auto commandGraph = vsg::createCommandGraphForView(window, camera, vsg_scene);
+ viewer->assignRecordAndSubmitTaskAndPresentation({commandGraph}, databasePager);
+
+ viewer->compile();
// rendering main loop
while (viewer->advanceToNextFrame() && (numFrames<0 || (numFrames--)>0))
{
- if (databasePager) databasePager->updateSceneGraph(viewer->getFrameStamp());
-
// pass any events into EventHandlers assigned to the Viewer
viewer->handleEvents();
- viewer->populateNextFrame();
+ viewer->update();
+
+ viewer->recordAndSubmit();
- viewer->submitNextFrame();
+ viewer->present();
}
// clean up done automatically thanks to ref_ptr<>