0 Members and 2 Guests are viewing this topic.
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;
lol Major, fpsFrameTime is not meant to increment like that.
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.
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.
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.
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.
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;
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.
the not is probably not needed, could be replaced with a >= instead.
Quote from: -Major- on May 31, 2010, 06:46:04 amhe 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?
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...
blah
Quote from: -Major- on May 31, 2010, 06:57:40 amblahyour post is not representing my code :-SRender thing and all calculations are different, it shouldn't be done in the same procedure. ( of course )
Quote from: Neosano on May 31, 2010, 06:59:45 amQuote from: -Major- on May 31, 2010, 06:57:40 amblahyour post is not representing my code :-SRender thing and all calculations are different, it shouldn't be done in the same procedure. ( of course )I was explaining eCs code.
also... timepassed = timepassed + (x+1) -xso, the time will always increase, at a point when timepassed gets as big and bigger than the maxFPS, it'll draw every frame.
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.