Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Castles-Game Prototype(Webstart)  (Read 8151 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej
« Reply #30 - Posted 2007-10-18 19:27:07 »

Umm yeah, you get a performance loss of 1ms when you use Thread.sleep(1) but that's the whole point of throttling, isn't it Grin
Of course, if you're not careful with the amount of sleeping, you might miss frames when you make use of vsync, but that's not Thread.sleep(1)'s fault.
FWIW, I'm using the same code for throttling as princec, no problems at all: Steady framerates, no performance loss.
I don't think I use vsync. When I use nanosleep instead of sleep even for a very short time, the performance falls hugely. Maybe I don't express correctly what I mean. It is not a bug but I'm not sure it is good to use it here.
Oh, and there's really no need for e.printStackTrace() (just commenting on it since you posted that in bold as if it were important).
I find it cleaner. If there is something wrong, you don't hide it silently.

Offline princec

« JGO Spiffy Duke »


Medals: 425
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #31 - Posted 2007-10-18 20:07:48 »

Don't forget that it only sleeps if there's actually time to spare. If it's using all 17ms or whatever to render then it'll never sleep. So basically only wasted time is wasted anyway.

Cas Smiley

Offline SimonH
« Reply #32 - Posted 2007-10-19 00:20:07 »

Don't forget that it only sleeps if there's actually time to spare.
Well, sort of... sleep() gives an 'ideal' sleep time not a guaranteed one, so it might be longer (and usually is for small values). You must call it though or things go bad. I did loads of tests and found that (on a typical system) sleep(10) was faster than yield() or sleep(1) because the JVM needs a certain amount of time (>1ms && <10ms) to keep things stable. Anyone done more research on this? It'd be good to have some hard facts!

People make games and games make people
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #33 - Posted 2007-10-19 06:11:19 »

Well, sort of... sleep() gives an 'ideal' sleep time not a guaranteed one, so it might be longer (and usually is for small values). You must call it though or things go bad. I did loads of tests and found that (on a typical system) sleep(10) was faster than yield() or sleep(1) because the JVM needs a certain amount of time (>1ms && <10ms) to keep things stable. Anyone done more research on this? It'd be good to have some hard facts!
I agree with you and that was why it tried to use "static void sleep(long millis, int nanos)". The JVM does not check if a VBO is being transfered and things like that on my view (related on the GPU) so the things might be unstable if you use very big VBOs (that's my case) instead of splitting them into smaller ones. When I tried to check what sleep(long millis) was doing, I realized that often the true sleep time was close to exactly 6 ms when I asked a sleep for less than 6 ms. It is not new, it was the case in C, it is not a limitation of Java.

Offline princec

« JGO Spiffy Duke »


Medals: 425
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #34 - Posted 2007-10-19 10:08:40 »

If y'all look at the code there the sleep is only called if the time since the last sleep is less than the required frame duration... so if your frames are taking longer than 17ms at 60Hz for example, it doesn't call sleep...

Cas Smiley

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #35 - Posted 2007-10-19 12:02:22 »

Well, sort of... sleep() gives an 'ideal' sleep time not a guaranteed one, so it might be longer (and usually is for small values). You must call it though or things go bad. I did loads of tests and found that (on a typical system) sleep(10) was faster than yield() or sleep(1) because the JVM needs a certain amount of time (>1ms && <10ms) to keep things stable. Anyone done more research on this? It'd be good to have some hard facts!

Maybe this has something to do with it:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6435126

Offline DzzD
« Reply #36 - Posted 2007-10-19 13:44:38 »

cant play  Huh

Quote
La page XML ne peut pas être affichée
Impossible d'afficher l'entrée XML en utilisant la feuille de style XSL. Corrigez l'erreur, puis cliquez sur le bouton Actualiser ou réessayez ultérieurement.


--------------------------------------------------------------------------------

La balise de fin information ne correspond pas à la balise de début description. Erreur de traitement de la ressource http:...

    </information>
------^

Offline gouessej
« Reply #37 - Posted 2007-10-19 18:04:05 »

cant play  Huh

It works in command line.
Enter "javaws " and the URL ending by .jnlp and it works.

Offline DzzD
« Reply #38 - Posted 2007-10-19 18:52:40 »

It works in command line.
Enter "javaws " and the URL ending by .jnlp and it works.

thanks, it's work

Offline SimonH
« Reply #39 - Posted 2007-10-20 02:03:50 »

Maybe this has something to do with it:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6435126
Could well be in some cases, but I've found this sleep(10) thing in J2ME as well - I think it's the garbage collection looking for loose handles. Just a side-effect of java I guess...

People make games and games make people
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #40 - Posted 2007-10-20 07:05:41 »

Could well be in some cases, but I've found this sleep(10) thing in J2ME as well - I think it's the garbage collection looking for loose handles. Just a side-effect of java I guess...
No no it isn't. There is the same kind of limitation in C and C++. It is a constraint of the operating system. I think it doesn't come from Java. The high resolution timing with "int nanosleep(const struct timespec *req, struct timespec *rem)" in C works not fine in some contexts. Then, if it is a limitation, it is a common limitation of C and Java.

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #41 - Posted 2007-10-26 11:06:48 »

You need to set the mime-type on the server for JNLP files to application/x-java-jnlp-file by the way.

Can't play the game because you still haven't fixed the webserver. Please make it playable. Thanks!

malloc will be first against the wall when the revolution comes...
Offline DzzD
« Reply #42 - Posted 2007-10-26 17:37:11 »

It works in command line.
Enter "javaws " and the URL ending by .jnlp and it works.

Pages: 1 [2]
  ignore  |  Print  
 
 

 
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!