Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  simple question about the Timer  (Read 1798 times)
0 Members and 1 Guest are viewing this topic.
Offline Kommi

Junior Devvie

All opinions will be lined up and shot!

« Posted 2002-12-18 17:52:59 »

I know that this hi res Timer thing has been discussed to death, but please bear with me, I am new to this. The following is just simple code to display the value of the Java3DTimer:

import com.sun.j3d.utils.timer.J3DTimer;
class test
     public static void main(String[] args)
           long time;
           time = J3DTimer.getValue();

When I run the code here is the oputput:

My question is what exactly does this number mean? And how can I use this timer to have an accurate frame rate. I have a simple program with an animation loop and the statement  thread.sleep(30)  which is 30ns. Ofcourse this is inaccurate. I was wondering how exactly do I implement the Java3DTimer in my animation loop?

Also what is WakeupOnElapsedTime(30) about? and how is it used?
Any help is greatly appreciated.

Offline Captain-Goatse

Junior Devvie

I suck at teh 2D. XBOX IS BIG LOL!111

« Reply #1 - Posted 2002-12-30 07:09:47 »

First of all, if you haven't modified the thread and are talking about the same thing as me thread.sleep is ms.  1ms is 1000 000 ns. J3D timer gives out ns therefore you have to get the fps you have to use fps = (long) 1000000 /(J3DTimer.getValue() - StartTime)/ (long) Interval;

and starttime is the value you take vefore you execute the loop.

The way you implement it? It is good to use at any place where you use the System.getMillis() thing, because that is very inaccurate even in milliseconds.
Pages: [1]
  ignore  |  Print  

EgonOlsen (59 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (240 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!