Pārlūkot izejas kodu

Fixing update time.

bkaradzic 12 gadi atpakaļ
vecāks
revīzija
9780828b98
2 mainītis faili ar 7 papildinājumiem un 3 dzēšanām
  1. 4 2
      examples/01-cubes/cubes.cpp
  2. 3 1
      examples/06-bump/bump.cpp

+ 4 - 2
examples/01-cubes/cubes.cpp

@@ -183,6 +183,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 	// Set view and projection matrix for view 0.
 	bgfx::setViewTransform(0, view, proj);
 
+	int64_t timeOffset = bx::getHPCounter();
+
 	while (!processEvents(width, height, debug, reset) )
 	{
 		// Set view 0 default viewport.
@@ -199,14 +201,14 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 		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();
 		bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/01-cube");
 		bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Rendering simple static mesh.");
 		bgfx::dbgTextPrintf(0, 3, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
 
-		float time = (float)(bx::getHPCounter()/double(bx::getHPFrequency() ) );
-
 		// Submit 11x11 cubes.
 		for (uint32_t yy = 0; yy < 11; ++yy)
 		{

+ 3 - 1
examples/06-bump/bump.cpp

@@ -348,6 +348,8 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 	mem = loadTexture("fieldstone-n.dds");
 	bgfx::TextureHandle textureNormal = bgfx::createTexture(mem);
 
+	int64_t timeOffset = bx::getHPCounter();
+
 	while (!processEvents(width, height, debug, reset) )
 	{
 		// Set view 0 default viewport.
@@ -364,7 +366,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
 		const double freq = double(bx::getHPFrequency() );
 		const double toMs = 1000.0/freq;
 
-		float time = (float)(now/freq);
+		float time = (float)( (now-timeOffset)/freq);
 
 		// Use debug font to print information about this example.
 		bgfx::dbgTextClear();