|
From: <axl...@us...> - 2009-01-01 17:04:06
|
Revision: 135
http://hgengine.svn.sourceforge.net/hgengine/?rev=135&view=rev
Author: axlecrusher
Date: 2009-01-01 17:04:02 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
use MercuryTimer
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryUtil.cpp
Mercury2/src/MercuryUtil.h
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-01-01 17:01:48 UTC (rev 134)
+++ Mercury2/src/Mercury2.cpp 2009-01-01 17:04:02 UTC (rev 135)
@@ -13,6 +13,9 @@
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
#include <MercuryMessageManager.h>
+
+#include <MercuryTimer.h>
+
MSemaphore UpdateLoopGo;
void* UpdateThread(void* node)
{
@@ -37,8 +40,6 @@
int main()
{
unsigned long m_count = 0;
- uint64_t startTime = GetTimeInMicroSeconds();
- uint64_t timeSinceStart = 0;
cnset_execute_on_crash( SignalHandler );
@@ -51,31 +52,29 @@
root->LoadFromXML( r );
SAFE_DELETE(doc);
+
+ MercuryTimer timer;
+ MercuryTimer fpsTimer;
- uint64_t oTime = timeSinceStart;
- uint64_t m_time = oTime;
-
//uncomment the next 2 lines to use threads
// MercuryThread updateThread;
// updateThread.Create( UpdateThread, root, false);
do
{
- timeSinceStart = GetTimeInMicroSeconds() - startTime;
- MESSAGEMAN::GetInstance().PumpMessages( timeSinceStart );
- root->RecursiveUpdate((timeSinceStart-oTime)/1000000.0f); //comment to use threads
+ timer.Touch();
+// MESSAGEMAN::GetInstance().PumpMessages( timer.MicrosecondsSinceInit() );
+ root->RecursiveUpdate( timer.Age() ); //comment to use threads
RenderableNode::RecursiveRender(root);
w->SwapBuffers();
++m_count;
- float seconds = (timeSinceStart-m_time)/1000000.0f;
- if (seconds > 1)
+ fpsTimer.Touch(timer);
+ if (fpsTimer.Age() > 1)
{
- m_time = timeSinceStart;
- printf("FPS: %f\n", m_count/seconds);
+ printf("FPS: %f\n", m_count/fpsTimer.Age());
m_count = 0;
+ fpsTimer = timer;
}
-
- oTime = timeSinceStart;
}
while ( w->PumpMessages() );
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2009-01-01 17:01:48 UTC (rev 134)
+++ Mercury2/src/MercuryUtil.cpp 2009-01-01 17:04:02 UTC (rev 135)
@@ -2,12 +2,6 @@
#include <MercuryFile.h>
#include <stdint.h>
-#ifndef WIN32
-#include <sys/time.h>
-#else
-#include <windows.h>
-#endif
-
MString ToUpper(const MString& s)
{
MString t = s;
@@ -35,15 +29,6 @@
return ptr;
}
-int64_t GetTimeInMicroSeconds()
-{
- struct timeval tv;
- gettimeofday( &tv, 0 );
-
- return (int64_t(tv.tv_sec) * 1000000) + tv.tv_usec;
-
-}
-
long FileToString( const MString & sFileName, char * & data )
{
data = 0;
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2009-01-01 17:01:48 UTC (rev 134)
+++ Mercury2/src/MercuryUtil.h 2009-01-01 17:04:02 UTC (rev 135)
@@ -17,8 +17,6 @@
//returns an aligned pointer, mem is the actual (unaligned) pointer for freeing
void* mmemalign(size_t align, size_t size, void*& mem);
-int64_t GetTimeInMicroSeconds();
-
#if defined(__GNUC__)
#define M_ALIGN(n) __attribute__((aligned(n)))
//#define MMALLOC(n) memalign(32, n)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|