Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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  
  jogl fps lock  (Read 3404 times)
0 Members and 1 Guest are viewing this topic.
Offline starlord

Junior Devvie

« Posted 2003-06-20 04:31:40 »

how can i lock frame rate let's say to 50fps in jogl?

do i need to create own animator class or how?

Offline Ken Russell

JGO Coder

Java games rock!

« Reply #1 - Posted 2003-06-23 06:17:10 »

You can measure your frame time at the beginning of your display() method and Thread.sleep() or Object.wait() for the remainder of say 20 ms.

Someone was posting on the gl4java mailing list about this recently and it probably should be added to the Animator class.

However think about why you want to do this -- is it to keep CPU usage down? Or to avoid looking at wall clock time in your animation loop? If it's the latter then you should probably consider adding a notion of elapsed time to your animations, because doing so will provide framerate independence.
Offline vydias

Senior Newbie

Welcome to my world!

« Reply #2 - Posted 2003-07-05 17:24:28 »

keeping CPU usage down is always a good thing if you want to increase stablity on all systems. I've notice on one of my systems that I will lockup occassionally playing games or doing cpu intensive stuff that run at full cpu usage for prolong periods of times. Its my guess that I lock up because of the extra heat that my cpu/video card is producing.

IMO I'm thinking a frame lock might not be a bad idea since I'm sure it would have much tighter accuracy then me placing a sleep in my code. I know gage has a more accurate timer and a native timer could be used but we are talking about a Java 3d gaming API and ease of use/robustness of its current framework should be one of its aims.

Just a though,
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oneyoon

Junior Newbie

Java games rock!

« Reply #3 - Posted 2003-07-05 23:40:31 »

If you look at the code for the Animator class, the main thread runs in a tight loop with no sleep() or yield().  This is not very swing friendly, and I noticed that in some of my practice programs, the gui interaction was very jerky.

Please put in FPS functionality, so swing events can be handled in a timely fashion and so we can drive other functions like AI, etc. within controlled timeslices.

I ended up cut and pasting the Animator class to my own package and adding a sleep(33) within the run loop. Oh by the way, is the GLCanvas.willSetRenderingThread() supposed to be protected? or was the "public" modifier left off by accident?  Can it be public so we can use the NVidia bug fix from classes we make from scratch?

If you don't want to mess with the Animator class, I bet you can just put a sleep() line at the end of your display() code.  I don't bother with calculating the exact time delta, right now, because my notebook fps tops at 30fps, and I'm on winXP so the timer is not accurate anyways.

After the sleep fix, my programs run just like it did in GL4Java, except for any demo with teapots...Can anyone port the glutTeapot() soon?  I really like the teapot!

Offline starlord

Junior Devvie

« Reply #4 - Posted 2003-07-06 03:41:53 »

currently i run also own animator with sleep,hopefully they integrate GLAnimCanvas like in gl4java, this allow's FPS locking stuff..
« Reply #5 - Posted 2003-07-06 07:00:49 »

I think that a Fps-lock like we know and love it from Gl4java via myGLcanvas.setAnimateFps(50) is a must-have. (This is no complain, because Jogl is very young, it's just a suggestion. :-)

There are many cases where the animation of the GLcanvas suffices with 50 fps (or any other value).

In the model-view-controller (MVC) system of a few full-price games I know it's usual to limit the FPS of the view-part to a fixed value (changable via option maybe) so that the fixed timer based model-part driving the simulation got it's CPU time in a reliable way.
Offline gregorypierce

Senior Devvie

I come upon thee like the blue screen of death....

« Reply #6 - Posted 2003-07-10 19:10:00 »

Always better to be relatively slow consistently than to speed up and slow down all the time Smiley

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

basil_ (42 views)
2015-09-30 17:04:40

shadowstryker (21 views)
2015-09-29 15:55:06

TheSpaceHedgehog (27 views)
2015-09-29 01:58:48

GamerC4 (50 views)
2015-09-24 21:10:38

GamerC4 (70 views)
2015-09-24 21:09:48

htuy (27 views)
2015-09-24 04:57:24

htuy (36 views)
2015-09-24 04:56:35

htuy (25 views)
2015-09-24 04:56:09

htuy (26 views)
2015-09-24 04:47:33

Roquen (64 views)
2015-09-21 12:54:28
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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!