|
From: <axl...@us...> - 2008-12-30 22:35:32
|
Revision: 114
http://hgengine.svn.sourceforge.net/hgengine/?rev=114&view=rev
Author: axlecrusher
Date: 2008-12-30 22:35:28 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
use microseconds
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryUtil.cpp
Mercury2/src/MercuryUtil.h
Mercury2/src/TransformNode.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/Mercury2.cpp 2008-12-30 22:35:28 UTC (rev 114)
@@ -8,6 +8,8 @@
#include <RenderableNode.h>
+#include <sys/time.h>
+
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
@@ -35,7 +37,7 @@
int main()
{
unsigned long m_count = 0;
- long m_time;
+// long m_time;
cnset_execute_on_crash( SignalHandler );
@@ -51,22 +53,29 @@
// MercuryThread updateThread;
- m_time = time(NULL);
+// m_time = time(NULL);
+ uint64_t oTime = GetTimeInMicroSeconds();
+ uint64_t m_time = oTime;
+
// updateThread.Create( UpdateThread, root, false);
do
{
- root->RecursiveUpdate(0.01f);
+ uint64_t curTime = GetTimeInMicroSeconds();
+ root->RecursiveUpdate((curTime-oTime)/1000000.0f);
// updateThread.Create( UpdateThread, root, false);
RenderableNode::RecursiveRender(root);
w->SwapBuffers();
++m_count;
- if (time(NULL) > m_time)
+ float seconds = (curTime-m_time)/1000000.0f;
+ if (seconds > 1)
{
- m_time = time(NULL);
- printf("FPS: %lu\n", m_count);
+ m_time = curTime;
+ printf("FPS: %f\n", m_count/seconds);
m_count = 0;
}
+
+ oTime = curTime;
}
while ( w->PumpMessages() );
@@ -109,3 +118,4 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
Modified: Mercury2/src/MercuryUtil.cpp
===================================================================
--- Mercury2/src/MercuryUtil.cpp 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/MercuryUtil.cpp 2008-12-30 22:35:28 UTC (rev 114)
@@ -1,6 +1,12 @@
#include <MercuryUtil.h>
#include <stdint.h>
+#ifndef WIN32
+#include <sys/time.h>
+#else
+#include <windows.h>
+#endif
+
MString ToUpper(const MString& s)
{
MString t = s;
@@ -28,6 +34,15 @@
return ptr;
}
+int64_t GetTimeInMicroSeconds()
+{
+ struct timeval tv;
+ gettimeofday( &tv, 0 );
+
+ return (int64_t(tv.tv_sec) * 1000000) + tv.tv_usec;
+
+}
+
/***************************************************************************
* Copyright (C) 2008 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/MercuryUtil.h 2008-12-30 22:35:28 UTC (rev 114)
@@ -17,6 +17,8 @@
//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)
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2008-12-30 22:10:30 UTC (rev 113)
+++ Mercury2/src/TransformNode.cpp 2008-12-30 22:35:28 UTC (rev 114)
@@ -147,8 +147,8 @@
void RotatorNode::Update(float dTime)
{
MercuryPoint r = GetRotation();
- r.x += (dTime)*2.5;
- r.y += (dTime)*5;
+ r.x += (dTime)*25;
+ r.y += (dTime)*75;
SetRotation( r );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|