Author Topic: fps capping  (Read 9864 times)

0 Members and 1 Guest are viewing this topic.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #40 on: May 31, 2010, 08:19:01 am »
Tried your pseudo code Neosano, and it was also not capping FPS at all. I set maxFPS to 75, it was going at 200+ FPS.
Code: (pascal) [Select]
var
  fpsStep = 1000 / maxFPS;
  fpsTimePassed = 0;
  fpsLastTime = 0;

begin
  fpsTimePassed := fpsTimePassed + timeGetTime() + fpsLastTime;
  fpsLastTime := timeGetTime();
  if (fpsTimePassed >= fpsStep) then begin
    RenderFrame;
    fpsTimePassed := fpsTimePassed - fpsStep;
  end;
end;

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #41 on: May 31, 2010, 08:36:33 am »
what does the renderframe do enesce? does it only render the graphics in the frame, or does it make everything in the frame?

anyway, I guess you could maybe try a more mathematical way to do it.... probably with modulator ussage it should be possible...

lets say we want to limit fps to 93...

then take 1000/93 = X, make X an integer... then..

if (fpsCurrentTime mod X = 0) then
renderframe;
end;

or

if (fpsCurrentTime mod X = 1) then
renderframe;
end;

(mix around some with if/if not and 1/0)

the maths might be off and might not compile, just convert the stuff that is needed.


aaaah... but this might get really fucked up....
« Last Edit: May 31, 2010, 08:38:46 am by -Major- »

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #42 on: May 31, 2010, 09:16:40 am »
ooops.. I screwed this post
« Last Edit: June 01, 2010, 12:28:07 pm by Neosano »
KAWAAAAAAAIIIIIIIIII

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #43 on: May 31, 2010, 09:34:02 am »
It still gives the exact same result Neosano, 200+ fps.
and timeGetTime() = http://msdn.microsoft.com/en-us/library/dd757629%28VS.85%29.aspx

At the moment I've got a better method, but still seems a tiny bit off. Capped at 75, getting 74-77 FPS, when capped at 120 getting 119-122. According to FRAPS.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #44 on: May 31, 2010, 09:44:50 am »
It still gives the exact same result Neosano, 200+ fps.
and timeGetTime() = http://msdn.microsoft.com/en-us/library/dd757629%28VS.85%29.aspx

At the moment I've got a better method, but still seems a tiny bit off. Capped at 75, getting 74-77 FPS, when capped at 120 getting 119-122. According to FRAPS.
ok. When game starts it should set fpsLastTime to timeGetTime()
Otherwise it's set to 0, which makes a lot of difference.
« Last Edit: May 31, 2010, 09:46:37 am by Neosano »
KAWAAAAAAAIIIIIIIIII

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #45 on: May 31, 2010, 09:47:19 am »
It still gives the exact same result Neosano, 200+ fps.
and timeGetTime() = http://msdn.microsoft.com/en-us/library/dd757629%28VS.85%29.aspx

At the moment I've got a better method, but still seems a tiny bit off. Capped at 75, getting 74-77 FPS, when capped at 120 getting 119-122. According to FRAPS.
that little is probably because of fps drops and making stuff into integer tho...

however, what does renderframe do? is it only graphical drawing? make sure so the game doesn't update itself more than the capped fps.... otherwise the point of this is lost -.-

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #46 on: May 31, 2010, 09:58:57 am »
Ok, when I do that it sits at 76-77 with a 75 cap; however at 120 cap it sits at 125 very steadily. 168 @ 160. 63 @ 60
@Major, yeah I agree its the decimal thing now. And RenderGame only renders the screen, all the time related events are outside the cap code.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #47 on: May 31, 2010, 10:04:43 am »
Ok, when I do that it sits at 76-77 with a 75 cap; however at 120 cap it sits at 125 very steadily. 168 @ 160. 63 @ 60
@Major, yeah I agree its the decimal thing now. And RenderGame only renders the screen, all the time related events are outside the cap code.
Well, sounds way better ^_^
maybe fpsLastTime is set to timeGetTime() in a wrong place? It must be set to it exactly when this algorithm starts. Well, I did what I can ^_^

Btw, Try 100 fps. maybe the problem is in dividing?
« Last Edit: May 31, 2010, 10:10:43 am by Neosano »
KAWAAAAAAAIIIIIIIIII

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #48 on: May 31, 2010, 10:08:14 am »
Ok, when I do that it sits at 76-77 with a 75 cap; however at 120 cap it sits at 125 very steadily. 168 @ 160. 63 @ 60
@Major, yeah I agree its the decimal thing now. And RenderGame only renders the screen, all the time related events are outside the cap code.
so, then you should make the framecap code at the very base, so the game won't process any code unless a frame is supposed to be drawn~

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #49 on: May 31, 2010, 10:16:25 am »
Btw, Try 100 fps. maybe the problem is in dividing?
100 sits perfectly at 100. So yes, it is something wrong with the dividing now.

Offline SyavX

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 338
Re: fps capping
« Reply #50 on: May 31, 2010, 02:48:06 pm »
Why does (1000 / maxFPS) calculating every time?

Code: (Pascal) [Select]
var 
 maxFPS: byte = 0; 
 fpsLastFrame: DWORD = 0; 
 fpsCurrentTime: DWORD = 0; 
 fpsRenderInterval: WORD = 0;
 
// calculate render interval time after you read maxFPS value from .ini or smth
fpsRenderInterval := Round(1000 / maxFPS);

begin 
   fpsCurrentTime := timeGetTime(); 
   if (fpsCurrentTime - fpsLastFrame) >= fpsRenderInterval then begin 
     RenderFrame; 
     fpsLastFrame := fpsCurrentTime; 
   end; 
end;

The problem could be related to timeGetTime accuracy. Try to digg into timeBeginPeriod/timeEndPeriod direction or even QueryPerformanceTimer.

upd: oh, you probably did, coz of posted link to MSDN
« Last Edit: May 31, 2010, 04:03:16 pm by SyavX »

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #51 on: May 31, 2010, 02:50:27 pm »
still~

the fps capping shouldn't only cap the drawed fps, but also all the processed data.

Offline biohazard

  • Camper
  • ***
  • Posts: 337
  • B4bY NighT
    • B4bY NighT
Re: fps capping
« Reply #52 on: May 31, 2010, 03:08:44 pm »
still~

the fps capping shouldn't only cap the drawed fps, but also all the processed data.

nop, only drawed, ima quite sure thats how fps limit is supposed to work.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #53 on: May 31, 2010, 03:36:18 pm »
nah... you wanna cap the updates per second.... otherwise you can't optimize your game -.-

Offline biohazard

  • Camper
  • ***
  • Posts: 337
  • B4bY NighT
    • B4bY NighT
Re: fps capping
« Reply #54 on: May 31, 2010, 04:19:37 pm »
http://dev.koonsolo.com/7/dewitters-gameloop/

I think that Soldat already follow "Constant Game Speed with Maximum FPS" concept and cant be changed easier as like coding some lines.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #55 on: May 31, 2010, 04:37:54 pm »
http://dev.koonsolo.com/7/dewitters-gameloop/

I think that Soldat already follow "Constant Game Speed with Maximum FPS" concept and cant be changed easier as like coding some lines.
hmm? can just put the update at the same place as renderframe.

Offline echo_trail

  • Global Moderator
  • Rainbow Warrior
  • *****
  • Posts: 2222
  • ménage-à-trois
    • my last.fm
Re: fps capping
« Reply #56 on: May 31, 2010, 06:41:58 pm »
Neosano, I will have you keep a civil tone.
I fucking miss all you cunts!

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #57 on: June 01, 2010, 06:21:25 am »
Btw, Try 100 fps. maybe the problem is in dividing?
100 sits perfectly at 100. So yes, it is something wrong with the dividing now.
Um.
fpsStep mustn't be an integer or byte.. something float is needed here.
same goes for fpsTimePassed.

2echo_trail
OKies ^_^
KAWAAAAAAAIIIIIIIIII

Offline SyavX

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 338
Re: fps capping
« Reply #58 on: June 01, 2010, 07:22:14 am »
Um.
fpsStep mustn't be an integer or byte.. something float is needed here.
same goes for fpsTimePassed.

timeGetTime returns an integer value (DWORD type), so... you are wrong.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #59 on: June 01, 2010, 08:02:00 am »
Um.
fpsStep mustn't be an integer or byte.. something float is needed here.
same goes for fpsTimePassed.

timeGetTime returns an integer value (DWORD type), so... you are wrong.
fpsStep=1000/maxFPS

1000/75=13.3333 .....Definitely I'm wrong...

next time read the code... PLEASE...
« Last Edit: June 01, 2010, 08:05:20 am by Neosano »
KAWAAAAAAAIIIIIIIIII