changeset 19:eb61cc181345

platform independant timing method
author Extrawurst
date Thu, 09 Dec 2010 22:20:19 +0100
parents a376e5d3eb00
children f897d96cc7c9
files trunk/tests/ChipmunkDemos/framework.d
diffstat 1 files changed, 40 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/tests/ChipmunkDemos/framework.d	Thu Dec 09 20:52:22 2010 +0100
+++ b/trunk/tests/ChipmunkDemos/framework.d	Thu Dec 09 22:20:19 2010 +0100
@@ -91,4 +91,44 @@
 void shutdown()
 {
 	SDL_Quit();
+}
+
+version (Win32)
+{
+	import std.c.windows.windows;
+
+	static long winfrequ;
+
+	static this()
+	{
+		QueryPerformanceFrequency(&winfrequ);
+	}
+
+	ulong tickCount(){
+		long ret;
+		QueryPerformanceCounter(&ret);
+		return (cast(ulong)(cast(float)ret / winfrequ * 1000));
+	}
+}
+else version (linux)
+{
+	import std.c.linux.linux;
+
+	ulong tickCount(){
+
+		timeval val;
+		gettimeofday(&val,null);
+
+		//return time(null);
+		return val.tv_usec/1000;
+	}
+}
+else version (OSX)
+{
+	import std.date;
+
+	ulong tickCount(){
+
+		 return cast(ulong)getUTCtime();
+	}
 }
\ No newline at end of file