本文整理汇总了C++中osg::Timer::delta_s方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::delta_s方法的具体用法?C++ Timer::delta_s怎么用?C++ Timer::delta_s使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Timer
的用法示例。
在下文中一共展示了Timer::delta_s方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::Timer_t currTime = _timer.tick();
if (_timer.delta_s(_prevShaderUpdateTime, currTime) > 1.0) //one second interval for shader-changed-do-reload check
{
osg::ref_ptr<osg::Shader> reloadedshader;
std::string runningSource;
std::string reloadedstring;
if (_computeNode->_computeShader.valid())
{
runningSource = _computeNode->_computeShader->getShaderSource();
reloadedshader = osgDB::readRefShaderFile(osg::Shader::COMPUTE, _computeNode->_computeShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computeProgram->removeShader(_computeNode->_computeShader.get());
_computeNode->_computeShader = reloadedshader.get();
_computeNode->_computeProgram->addShader(_computeNode->_computeShader.get());
}
}
if (_computeNode->_vertexShader.valid())
{
runningSource = _computeNode->_vertexShader->getShaderSource();
reloadedshader = osgDB::readRefShaderFile(osg::Shader::VERTEX, _computeNode->_vertexShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computationResultsRenderProgram->removeShader(_computeNode->_vertexShader.get());
_computeNode->_vertexShader = reloadedshader.get();
_computeNode->_computationResultsRenderProgram->addShader(_computeNode->_vertexShader.get());
}
}
if (_computeNode->_geometryShader.valid())
{
runningSource = _computeNode->_geometryShader->getShaderSource();
reloadedshader = osgDB::readRefShaderFile(osg::Shader::GEOMETRY, _computeNode->_geometryShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computationResultsRenderProgram->removeShader(_computeNode->_geometryShader.get());
_computeNode->_geometryShader = reloadedshader.get();
_computeNode->_computationResultsRenderProgram->addShader(_computeNode->_geometryShader.get());
}
}
if (_computeNode->_fragmentShader.valid())
{
runningSource = _computeNode->_fragmentShader->getShaderSource();
reloadedshader = osgDB::readRefShaderFile(osg::Shader::FRAGMENT, _computeNode->_fragmentShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computationResultsRenderProgram->removeShader(_computeNode->_fragmentShader.get());
_computeNode->_fragmentShader = reloadedshader.get();
_computeNode->_computationResultsRenderProgram->addShader(_computeNode->_fragmentShader.get());
}
}
_prevShaderUpdateTime = _timer.tick();
}
traverse(node, nv);
}
示例2: main
//==========================================================
int main(void)
{
stitch::GlobalRand::initialiseUniformSamplerArray();
//stitch::BeamSegment::generateVolumeTexture();
{
int argc=1;
char **argv=new char *[10];
argv[0]=new char [256];
strcpy(argv[0], "Prob Calc Test");
osg::ArgumentParser arguments(&argc,argv);
g_viewer=new osgViewer::CompositeViewer(arguments);
delete [] argv[0];
delete [] argv;
}
g_viewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
g_rootGroup_=new osg::Group;
g_view3D=new stitch::View3D(g_ulWindowWidth, g_ulWindowHeight, g_rootGroup_);
g_view3D->init();
//g_view3D->getOSGView()->addEventHandler(new KeyboardEventHandler());
g_viewer->addView(g_view3D->getOSGView());
if (!g_viewer->isRealized())
{
g_viewer->realize();
}
g_view3D->setCamera(stitch::Vec3(0.0f, g_eye_distance, g_eye_distance), stitch::Vec3(0.0f, 0.0f, 0.0f), stitch::Vec3(0.0f, 0.0f, 1.0f));
g_renderInBackground=true;
std::thread displayUpdateThread(displayUpdateRun);
osg::Timer_t startTick=0.0, endTick=0.0;
startTick=timer.tick();
//========================//
//=== Start Prob Calc tests ===//
//========================//
//visualiseProbFunc();
testAccuracy();
//========================//
//========================//
//========================//
endTick=timer.tick();
std::cout << "Completed in " << timer.delta_s(startTick, endTick) << " seconds.\n\n";
std::cout.flush();
//====================================//
//=== Continue rendering until ESC ===//
//====================================//
g_renderInBackground=false;
displayUpdateThread.join();//Wait for background render thread to exit.
//Continue rendering in main thread until viewer exited.
while (!g_viewer->done())
{
g_view3D->preframe();
g_viewer->frame();
std::chrono::milliseconds dura(50);
std::this_thread::sleep_for(dura);
}
//====================================//
//====================================//
//====================================//
std::chrono::milliseconds dura(1000);
std::this_thread::sleep_for(dura);
delete g_viewer;
}