Author Topic: fps capping  (Read 12372 times)

0 Members and 3 Guests are viewing this topic.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #20 on: May 31, 2010, 05:06:51 am »
Code: (pascal) [Select]
var
 maxFPS: byte = 0;
fpsLastFrame: DWORD = 0;
fpsCurrentTime: DWORD = 0;

begin
    fpsCurrentTime := timeGetTime();
    if not ((fpsCurrentTime - fpsLastFrame) < (1000 / maxFPS)) then begin
        RenderFrame;
       fpsFrameTime = fpsFrameTime + (1000 / maxFPS);
    end;
end;
this should be it. I doubt tho that enesce would even try to implent it because of his "pride".

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #21 on: May 31, 2010, 05:21:25 am »
lol Major, fpsFrameTime is not meant to increment like that.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #22 on: May 31, 2010, 05:26:22 am »
lol Major, fpsFrameTime is not meant to increment like that.
it is, using gametime at that point will probably just give you a unreliable value.
as I said, you won't even try it.

if your code doesn't work, then obviously there's something wrong with it... don't you think?
« Last Edit: May 31, 2010, 05:31:43 am by -Major- »

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #23 on: May 31, 2010, 05:36:58 am »
For starters, there is no fpsFrameTime variable (you also failed to use := ). I'll assume you meant fpsLastFrameTime, but even then so: DWORD can't have decimals, which is what occurs when you add (1000 / maxFPS). So I cant even try it because your code is flawed and won't even compile.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #24 on: May 31, 2010, 05:40:08 am »
For starters, there is no fpsFrameTime variable (you also failed to use := ). Secondly DWORD can't have decimals, which is what occurs when you add (1000 / maxFPS). So I cant even try it because your code is flawed and won't even compile.
I have never programmed in delphi, nor pascal. just convert the code into delphi. I also haven't done ANY programming in 3 years. I barely remember how a "for" thingy works anymore.
if DWORD can't have decimals, make a function to make the equation into an integer.

and you are really retarded, aren't you?

fpsLastFrame = fpsLastFrame + 1000/maxFPS


the MAIN issue is that you won't fix the broken code. even if my code paste doesn't work... YOUR CODE IS STILL FLAWED.
« Last Edit: May 31, 2010, 05:44:09 am by -Major- »

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #25 on: May 31, 2010, 05:43:43 am »
It's OK Major, I shall tolerate your lack of maturity.

But anyway, even when I rounded 1000/maxFPS, and set my FPS cap to 75, the framerate is 160-200. So gg your code is worse.

Adieu.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #26 on: May 31, 2010, 05:45:01 am »
It's OK Major, I shall tolerate your lack of maturity.

But anyway, even when I rounded 1000/maxFPS, and set my FPS cap to 75, the framerate is 160-200. So gg your code is worse.

Adieu.
still your code is flawed.... so is mine.... both are completely useless.

Meaning, you have to fix it... not let it go half assed.
« Last Edit: May 31, 2010, 05:50:38 am by -Major- »

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: fps capping
« Reply #27 on: May 31, 2010, 05:54:31 am »
The point of me posting the code was for someone with intelligence to point out the flaw, because there isn't one. It's being caused by something else in Soldat's original code, so your bashing of MY code is false.

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #28 on: May 31, 2010, 05:57:15 am »
The point of me posting the code was for someone with intelligence to point out the flaw, because there isn't one. It's being caused by something else in Soldat's original code, so your bashing of MY code is false.
you intend to leave it out flawed -.-. so the bashing is well deserved.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #29 on: May 31, 2010, 06:30:26 am »
Code: (pascal) [Select]
var
  maxFPS: byte = 0;
  fpsLastFrame: DWORD = 0;
  fpsCurrentTime: DWORD = 0;

begin
  fpsCurrentTime := timeGetTime();
  if not ((fpsCurrentTime - fpsLastFrame) < (1000 / maxFPS)) then begin
    RenderFrame;
    fpsLastFrame := fpsCurrentTime;
  end;
end;
You tell me what is coded wrong about that, wiseguy.
Oh I really don't understand what is happening here, and what it was intended to do.
if not ( a < b) part is just ridiculous... why not to use >= ?

The problem here is obvious. (Well, from mine non-understanding point of view)
I'll not try to post a pascal code, cuz I really don't want to remember pascal. But here's how it should work theoretically(that's not a programming language):

fpsStep = 1000 / MaxFps
timePassed
lastTime


your BEGIN here

timePassed = timePassed + GetTime() - lastTime
lastTime = GetTime()

if (timePassed >= fpsStep) {
RenderFrame()
timePassed= timePassed-fpsStep
}

end


try it. should work :]
KAWAAAAAAAIIIIIIIIII

Offline biohazard

  • Camper
  • ***
  • Posts: 337
  • B4bY NighT
    • B4bY NighT
Re: fps capping
« Reply #30 on: May 31, 2010, 06:34:44 am »
I noticied this option vsync on config.exe capping the FPS to something around 65, even if ima using 100/120hz LCD s**t. Is it truly a vsync or just your FPS-cap code. Prolly its not vsync in fact, since u cant set it with windowed mode, vsync only works on fullscreen.

Btw, this s**t http://rs487l3.rapidshare.com/files/160642187/2081482/FPS_Limiter_0.2.rar limits very the FPS on Soldat, but would be nice to have it in-game well coded. Idk, maybe some1 might try to break its source and understand how to cap the fps.

For starters, there is no fpsFrameTime variable (you also failed to use := ). I'll assume you meant fpsLastFrameTime, but even then so: DWORD can't have decimals, which is what occurs when you add (1000 / maxFPS). So I cant even try it because your code is flawed and won't even compile.

At moment, ur code works in a decent way if the maxframerate is set at 100, anything else, not.
« Last Edit: May 31, 2010, 07:07:26 am by biohazard »

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #31 on: May 31, 2010, 06:46:04 am »
he replaces last frame with the current frame at the end. however, doing that with my method should probably do about the same, except that it calculates the value instead of copying.

the not is probably not needed, could be replaced with a > instead. the "if not" means that, if statement is false, then proceed. ussualy you just use an if, which makes it, if statement is true, then proceed.

lets make max fps 100.

so, if this is false..

we start with currentTime as 1, 1 minus lastFrame (which is 0) is 1. this is less than 1000/100. so the statement is true. which ends the if thingy.

when the current time is 10 the statement is false, since 10-0 is 10, which is as big as 1000/100. the process begins.
it renders the frame and sets last frame to 10.

next frame would maybe be 13, as the check goes on again, it'll end with a result with 13-10 which is 10, and is less than 1000/100. which makes the statement true. therefore it does not proceed.


basically fpsLastFrame copies the last drawns frame game time.
using maxFPS/1000 should give the same value...

hopefully "RenderFrame" doesn't only draw it graphically, but also calculates everything that should happen that frame. otherwise this frame capping is utter bullshit...
« Last Edit: May 31, 2010, 06:48:59 am by -Major- »

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #32 on: May 31, 2010, 06:54:30 am »
So, you, damn troll, ignored my post, right?

And you FAIL.
the not is probably not needed, could be replaced with a >= instead.
« Last Edit: May 31, 2010, 06:58:02 am by Neosano »
KAWAAAAAAAIIIIIIIIII

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #33 on: May 31, 2010, 06:57:40 am »
he replaces last frame with the current frame at the end. however, doing that with my method should probably do about the same, except that it calculates the value instead of copying.

the not is probably not needed, could be replaced with a > instead. the "if not" means that, if statement is false, then proceed. ussualy you just use an if, which makes it, if statement is true, then proceed.

lets make max fps 100.

so, if this is false..

we start with currentTime as 1, 1 minus lastFrame (which is 0) is 1. this is less than 1000/100. so the statement is true. which ends the if thingy.

when the current time is 10 the statement is false, since 10-0 is 10, which is as big as 1000/100. the process begins.
it renders the frame and sets last frame to 10.

next frame would maybe be 13, as the check goes on again, it'll end with a result with 13-10 which is 10, and is less than 1000/100. which makes the statement true. therefore it does not proceed.


basically fpsLastFrame copies the last drawns frame game time.
using maxFPS/1000 should give the same value...

hopefully "RenderFrame" doesn't only draw it graphically, but also calculates everything that should happen that frame. otherwise this frame capping is utter bulls**t...
So, you, damn troll, ignored my post, right?
you didn't read what you wrote, right?

also... timepassed = timepassed  + (x+1) -x

so, the time will always increase, at a point when timepassed gets as big and bigger than the maxFPS, it'll draw every frame.
« Last Edit: May 31, 2010, 07:04:34 am by -Major- »

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #34 on: May 31, 2010, 06:59:45 am »
blah
your post is not representing my code :-S

Render thing and all calculations are different, it shouldn't be done in the same procedure. ( of course )
« Last Edit: May 31, 2010, 07:03:56 am by Neosano »
KAWAAAAAAAIIIIIIIIII

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #35 on: May 31, 2010, 07:04:59 am »
blah
your post is not representing my code :-S

Render thing and all calculations are different, it shouldn't be done in the same procedure. ( of course )
I was explaining eCs code.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #36 on: May 31, 2010, 07:07:02 am »
blah
your post is not representing my code :-S

Render thing and all calculations are different, it shouldn't be done in the same procedure. ( of course )
I was explaining eCs code.
What for? Just say that my algorithm works.

From: May 31, 2010, 07:13:03 am
also... timepassed = timepassed  + (x+1) -x

so, the time will always increase, at a point when timepassed gets as big and bigger than the maxFPS, it'll draw every frame.
no, you don't get it, it's right.
« Last Edit: May 31, 2010, 07:13:03 am by Neosano »
KAWAAAAAAAIIIIIIIIII

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #37 on: May 31, 2010, 07:17:32 am »
no.... when time is 481029, and fps step is 100, the next frame will be 481030, that is still greater than 100, so that frame will also be drawn.

adding time to fps step would probably work tho.

Offline Neosano

  • Camper
  • ***
  • Posts: 253
  • IIAWAK!
Re: fps capping
« Reply #38 on: May 31, 2010, 07:49:40 am »
no.... when time is 481029, and fps step is 100, the next frame will be 481030, that is still greater than 100, so that frame will also be drawn.

adding time to fps step would probably work tho.
What are you talking about, retard?
Did you notice this line
timePassed= timePassed-fpsStep
?
KAWAAAAAAAIIIIIIIIII

Offline -Major-

  • Veteran
  • *****
  • Posts: 1419
Re: fps capping
« Reply #39 on: May 31, 2010, 08:01:44 am »
that's timepassed, but fpsstep remains the same.