odd fps reading

I use the following code to determine the fps:

frametime = timer.getClockTicks();
                  clientTick(interpolation); //render logic
                  fps = timer.getTicksPerSecond()/(timer.getClockTicks()-frametime);
                  System.out.println(fps);

I use the http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Tuning;action=display;num=1058296748 timing loop. My probelm is that the fps displayed is always around 60 because the refrrsh rate of my monitor. If I turn the refresh rate up to 85 hz then the fps will be around 85. Is the fps value false? If not then how can I get around this limit? I would like to have the paint render logic run as often as possible.

This is probably to do with the graphics card synchronising redraw to vertical retrace. There is normally a setting in the driver control panel.

However, relying on this to be set to off isn’t a great idea since you don’t know what most end users (gamers) will do.

Either you make your logic cope with running as low as 60fps or go to the dreaded extra thread. I suspect you’re already got your logic coping with 60 fps anyway.

Kev

OK you said your Monitor refresh rate was at 60Hz and u got 60FPS.

60Hz and 60FPS hmm not many people understand these 2 words, let me explain u how this works

f=60Hz or f=60[s**-1] means 60 T cycles a second, your GDA is drawing 60 frames a second, so if u draw 120 rendered frames a second what will happen ? 60 frames will be dropped.

so FPS <= f is the formula, if u get a higher FPS its a rounding error.

[quote]I would like to have the paint render logic run as often as possible.
[/quote]
impossible its like going behind light speed its impossible.

In Fullscreen mode the show() method of the BufferStrategy also waits for vertical sync, means whenevery the ray of your CRT is starting again in row 0, a IRQ is triggered.

Be happy everything is OK with your rendering engine !!

OK cool I will settle for what I have. But then the question: I have downloaded and ran other peoples demos that display that their framerates are higher than my refresh rate. So if a demo is running and it says that it is going at 150 fps is this a lie? There is another thread about fps in 2d platform games where some people have stated that they get 150-1000 fps. How is that possible?

Hmmm my app is running in a 640 x 480 fullscreen window with 16Bit Color Depth i get max 150FPS and checked my refresh Rate ( it was 150Hz WOW :o )

but ppl with 800FPS in fullscreen mode are liars.

but perhaps they spoke about windowed apps, in windowed mode the BufferStrategy method show will NOT wait for V-sync.

Thats a big problem u render 800 frames a second and your monitor is capable of displaying only for e.g. 100 then you render 700 frames for the trashcan ;D

so windowed mode needs some tweaking.

you are fine if your FPS Rate is around 70 - 100 anything above or below is not usefull, low FPS rates lag like hell and high FPS rates are not increasing the quality for a humany being by 1%, your mind is not capable of seeing or feeling higher FPS rates behind 100Hz ( i like the 100Hz TV sets, they oWn yOu )

Running in a window, with v-sync turned off you can expect the application to run faster than refresh rate, but only because the graphics card is being allowed to draw faster than vertical retrace.

Kev

I am happy with my code then. I get around 60 fps at 60 hz and 85 fps at 85 hz. My frame rate is always consistent with the refresh rate so I guess I dont have any poblems. Now to go figure out how to implement real time physics with Marcus Persson’s loop… :slight_smile:

real time physics is easy to implement in the same thread as the render thread.

i use a GameEvent class, every GameObject derives from this. in the render loop i loop thru all GameEvents in a vector and check the ticks

for e.g. i created a event that wants key and mouse events and wants a tick every 100ms, so after 100ms it gets a tick. every key event it gets a key event and so on, its very very flexible and high reliable, the tick also get a double how many subticks have passed

for e.g. after lag 1 tick got skipped so the next tick is called with 2.4 ( and i know what happened )

so all my GameObjects can

render
get ticks every x ms
get key events
get mouse events
get mouse motion events

if wanted and enabled, this GameEvent class has some basic functions also ( the main reason for having one base class instead of using a interface, and two many classes increase the overall size of the applet )

So do you call rener as much as possible and then you call other methods at certain time intervals (like every 100ms) and you have a mechanism for handling lag. Is this correct?

yes render is limited by the V-Sync ( BufferStrategy show() waits for vsync in fullscreen, windowed mode needs some tweaks here )

when i have network lag, game freezes ( thats normal, but i found some methods to work around that )

ever played uo ? then u know what i mean

after BufferStrategy show i go thru a Vector of GameEvents with given properties.

Maybe Object a has a period of 50ms so every time i go thru the vector i check for elapsed time since start of GameEvent

One example for 100Hz Mode ( 10ms loops )

  1. render, then check event 10 < 50
  2. render, then check event 20 < 50
  3. render, then check event 30 < 50
  4. render, then check event 40 < 50
  5. render, then check event 50 < 50
    ok tick the event and reset and if infinite do not decrement counter otherwise decrement counter of event and if 0 delete from global list

the event object also gets the tick count and can calc home many ticks passed sinced last call ( so i manage any kind of lag )

Its easy i you have written many c++ programs with DirectX before, its the same way you write code