diff --git a/examples/02-metaballs/metaballs.cpp b/examples/02-metaballs/metaballs.cpp index 60dc8a94..2d1ff7c7 100644 --- a/examples/02-metaballs/metaballs.cpp +++ b/examples/02-metaballs/metaballs.cpp @@ -572,6 +572,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) const uint32_t zpitch = DIMS*DIMS; const float invdim = 1.0f/float(DIMS-1); + int64_t timeOffset = bx::getHPCounter(); + while (!processEvents(width, height, debug, reset) ) { // Set view 0 default viewport. @@ -587,6 +589,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) last = now; const double freq = double(bx::getHPFrequency() ); const double toMs = 1000.0/freq; + float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) ); // Use debug font to print information about this example. bgfx::dbgTextClear(); @@ -604,8 +607,6 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); - float time = (float)(bx::getHPCounter()/double(bx::getHPFrequency() ) ); - // Stats. uint32_t numVertices = 0; int64_t profUpdate = 0; diff --git a/examples/05-instancing/instancing.cpp b/examples/05-instancing/instancing.cpp index 379cafbe..16daffeb 100644 --- a/examples/05-instancing/instancing.cpp +++ b/examples/05-instancing/instancing.cpp @@ -172,6 +172,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) bgfx::destroyVertexShader(vsh); bgfx::destroyFragmentShader(fsh); + int64_t timeOffset = bx::getHPCounter(); + while (!processEvents(width, height, debug, reset) ) { // Set view 0 default viewport. @@ -187,6 +189,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) last = now; const double freq = double(bx::getHPFrequency() ); const double toMs = 1000.0/freq; + float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) ); // Use debug font to print information about this example. bgfx::dbgTextClear(); @@ -205,8 +208,6 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); - float time = (float)(bx::getHPCounter()/double(bx::getHPFrequency() ) ); - const uint16_t instanceStride = 80; const bgfx::InstanceDataBuffer* idb = bgfx::allocInstanceDataBuffer(121, instanceStride); if (NULL != idb) diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index c979bbd7..a6ec145e 100644 --- a/examples/08-update/update.cpp +++ b/examples/08-update/update.cpp @@ -228,6 +228,8 @@ int _main_(int /*_argc*/, char** /*_argv*/) uint32_t miss = 0; std::list quads; + int64_t timeOffset = bx::getHPCounter(); + while (!processEvents(width, height, debug, reset) ) { // Set view 0 default viewport. @@ -243,6 +245,7 @@ int _main_(int /*_argc*/, char** /*_argv*/) last = now; const int64_t freq = bx::getHPFrequency(); const double toMs = 1000.0/double(freq); + float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) ); // Use debug font to print information about this example. bgfx::dbgTextClear(); @@ -310,8 +313,6 @@ int _main_(int /*_argc*/, char** /*_argv*/) // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); - float time = (float)(bx::getHPCounter()/double(bx::getHPFrequency() ) ); - float mtx[16]; mtxRotateXY(mtx, time, time*0.37f);