Code Request: JNI timer

I was thinking that it might help if we could get both a Windows and a Mac version that would not be subject to the licensing issues of the J3D timer. I would do this myself but I have no idea how to access anything Windows-based. Oh yeah, perhaps a Linux version as well.

Anyone know how easy/hard this is? I’d love to learn how to do this.

Look in the lwjgl source in the Sys class. We have native timers for linux and win32 in there. It’s bsd licenced so you can steal it if you like it. Or better yet - use the entire lwjgl for your gaming desires :wink:

P.S … And the mac version is under way - gregory is working on it in these days.

  • elias

See this article about JNI timer. Maybe it gives you some ideas.
http://www.javaworld.com/javaworld/javaqa/2003-01/01-qa-0110-timing.html?

Thanks for the article. Anyone know anything about the Mac version of such a thing?

GAWD I need to learn low-level UNIX programming again.

[quote]Oh yeah, perhaps a Linux version as well.
[/quote]
I was under the impression that linux already has millisecond accuracy with System.currentTimeMillis(). Is that mistaken? I’ve never had any granularity issues before.

No, I think you are right. But with JNI it is possible for a timer to give sub-millisecond timings… I think it is in the order of 10 MICROsecond at that point.

Which is MORE than fine for animation. :slight_smile:

There seems to be some sort of timer in the MIDI stuff of Java Sound… I know nothing about it though… but i’m windering, if you have a MIDI device (i.e. most game PC will have one on the sound card) could you use it somehow?

I think someone tried it once, and reported back on this forum that it did not work… similar problems as with System.getCurrentTimeMillis()

I think someone tried it once, and reported back on this forum that it did not work… similar problems as with System.getCurrentTimeMillis()

LWJGL has a good timer so why not use it? :slight_smile:

LWJGL is on my list of technologies to use when we move my game in six months to a year from a 2D to a 3D model. It makes NO sense at that point to stay pure Java, and OpenGL is the only way to go. Unfortunately, at this time the support i need, which is Mac, Windows, and Linux, isn’t yet completed… so I have to wait.

But I will be using it… it’s a GREAT project.