// You have two options for the main viewer loop
// viewer->run() or
// while(!viewer->done()) { viewer->frame(); }
//viewer->run();
while(!viewer->done())
{
osg->PreFrameUpdate();
viewer->frame();
osg->PostFrameUpdate();
//Sleep(10); // Use this command if you need to allow other processes to have cpu time
}