high resolution timer

As every1 knows, under Windows, Java uses getTickCount for retrieving the system time. Every1 also knows that under win9x the resolution of this timer is 50[ish]ms, and under WinNT its around 10ms.

For most simple Java games, 10ms would be fine, however, after W2K died on me last week, im back to developing on win9x - and the 50ms granuality is *realy* bad (effectively limiting the framerate to 20fps).

So far i've identified 2 solutions, and was wondering if any1 knew of another alternative.

solution 1 - Use the System Timer accessed through the JMF API.

the JMF class, javax.media.SystemTimeBase gives hi-resolution timing.

This is fine for development, but im fairly sure no1 else but a developer is likely to have the JMF classes installed.

solution 2 - use JNI to access the PerformanceCounter available under Win32.

This would be an ideal solution, but.... C++ is scarrrey :P

( though I have found a webpage that makes it sound incredibly simple - http://www.fawcette.com/archives/premier/mgznarch/javapro/2001/08aug01/km0108/km0108-2.asp )

so, is there a 3rd way?

also, can any1 think of a good reason why System.currentTimeMillis() is still using getTickCount >:(

perhaps Its time we all voted for an RFE....

[1298 byte] By [Abusea] at [2007-9-28 2:20:14]
# 1
Sometimes I don't know what they're thinking, but I know this needs to be addressed. Though I didn't really look through this thoroughly, it looks interesting: http://www.javagaming.org/cgi-bin/JGOForums/YaBB.cgi?board=share;action=display;num=1035418761
Ceranitha at 2007-7-7 21:52:54 > top of Java-index,Other Topics,Java Game Development...
# 2

I've done the 2nd method, it was infact dead ez - and works like a dream. (Timer resolution of 0.01ms under win9x!)

However, its specific to Windows atm (but with a few changes, I could make it fall back on the currenTimeMillis() method on none Windows setups)

Only problem now, is the massive amount of garbage that AffineTransform generates at 90fps :P

**** I wish Sun would fix AffineTransforms >:( (another RFE vote perhaps :P)

also, does any1 know if MouseEvents are reused by the event delivery system?

If not, thats another source of major garbage (move your mouse quickly, and you can generate around 30 MouseEvents/second on a windows machine with a USB/PS2 mouse)

******! there are so many fundamental problems with Java for games, I don't know why I bother :(

Abusea at 2007-7-7 21:52:54 > top of Java-index,Other Topics,Java Game Development...
# 3
com.sun.j3d.utils.timer.J3DTimer.getValue(); in Java3D is another option. I would go with the link to JGO timer hack though because with the above you still have to have the Java3D package installed.
zparticlea at 2007-7-7 21:52:54 > top of Java-index,Other Topics,Java Game Development...
# 4
hmm, that JGO Timer hack is abit inefficient :|I think i'll stick with my Windows specific stuff atm.Anyhow, its not like any1 uses Solaris/linux/macos anyway :P(atleast not for games)
Abusea at 2007-7-7 21:52:54 > top of Java-index,Other Topics,Java Game Development...