Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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 2891 times)
0 Members and 1 Guest are viewing this topic.
Offline starlord

Junior Member





« Posted 2003-06-20 06: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 08: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 19: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,
Mark
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-06 01: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 Member





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

currently i run also own animator with sleep,hopefully they integrate GLAnimCanvas like in gl4java, this allow's FPS locking stuff..
Bornter
Guest
« Reply #5 - Posted 2003-07-06 09: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 Member




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


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

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

http://www.gregorypierce.com

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!