Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Needing help with Frame Rate and Deltatime

Author
Message
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 6th Feb 2008 11:16 Edited at: 12th Feb 2008 11:28
Thanks Oneka, your code help me get this far.

I'm finally getting around to needing to learn management of controlling how many times rendering, input, etc... needs to be done each second... ie: FPS.

The code below is just a rough hack to see if I can get to terms of this. It grabs the desktop width,height,depth for fullscreen.

In testing in a fullscreen 1680x1050 environment with this, my "RPS" (renders per second), is dropped almost in half( ie: from 60 to around 30 ). But yet, if I rem out the if statement that calls the dbSync 60 times a second, I'll get the full capped frame rate.

I tried to follow Oneka's code to do this where I can have alot of room in the frames per second. But, I'm struggling with finding a solution in this method to keep my "RPS" at 60fps and my "FPS" at a high rate.

Plus, I noticed this code's deltatime movement get's the small annoying jitters now and then.

Any help would be apprieciated. Thanks



Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Feb 2008 01:10
dude - I don't have an answer for you but I didn't know you could do that! That is way cool!

Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Feb 2008 04:43 Edited at: 8th Feb 2008 05:13
lol... didnt know how to do what? This example isn't 100% the way it is intended to work. In fact, I shouldn't even have to try to attempt such C++ code to do what it's trying to do. As a programmer, we should be allowed to control what gets updated and how. Capping at the monitor refresh rate where Dark GDK even caps the main loops per second to the same refresh rate is absurb. The Dark GDK's LoopGDK() callback should at least allow to be looped as many times as possible during the frame per second time period.

With my previous C++ and DirectX 9 programming, I just set the D3DPRESENT_PARAMETERS structure "PresentationInterval" member to
D3DPRESENT_INTERVAL_IMMEDIATE. That pretty much gives the equivalent of setting DBPro's command Sync Rate to the value of 0. Thus, I simply get the deltatime and not have to try to figure out how to code it like above.

I do find it quite interesting that Dark GDK and DBPro are the same engine... why Dark GDK's dbSetRate(0) got broken. It's a conspiracy!

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 8th Feb 2008 07:12
Hey Todd Riggins,

I dont quite see what your problem is, I ran the code about and had a RPS of about 58 to 59 and FPS of 4500~5000/sec.

If you are trying to achieve a perfect 60RPS a second I dont think it is really possible as I made a timing system to give me exactly 60 but it got hit with the limit and slowed it completely to 60

If I can be of any help just let me know

And thanks for using my example I thought everyone thought it was dumb code


Making dreams possible, one line at a time...
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Feb 2008 08:33 Edited at: 8th Feb 2008 08:44
Definetly not dumb, it's very straight forward and to the point for what it is suppose to do.

It may be because that I'm running in my only optimized resolution of 1680x1050 has a contributing factor with the renders per frame. (I have a NEC Opticlear MultiSync 20WMGX monitor for 1080iHD Xbox360 and for Desktop PC, ie: it will get blurry and will complain about being in any other resolution )

Without calling sync every 17ms and calling it normally, I will get 60fps( or monitor refresh rate ). With that though as we know, we get exactly the same amount of loops per second.

The above code for me cuts my Renders per frame in half around 30. Which is wierd and the reason why i know something fishy is going on behind the scenes. It could very well be that it is unhealthy to call sync every 17ms when the Dark GDK's present parameter->PresentationInterval member is NOT set to "D3DPRESENT_INTERVAL_IMMEDIATE". (ofcoarse, Im guessing since another logical reason could be that Lee purposely has set frame limiting code for dbSyncRate(0)... dunno)

Look at it this way, when it's running 30 renders per second for me, why would the frames per second still be high around 3000-5000f/sec? When the Renders per second goes down below the desired rate, should the frames per second be the same rate???

So i will wait until the next DarkGDK update and see if Lee fixes that specific little annoying bug. At least I can press forward with DBPro!

Thanks for the help offer

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 8th Feb 2008 13:43
Yeah - I for some dumb reason thought I MUST call dbSync in the main loop every iteration - maybe because that's all the examples have.

Above I was referring to not calling Sync more than necessary - allowing more raw cpu power to be used for other game tasks - so game not quite as stiffled by rendering!

That is simple - straightforward - and not dumb.

Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 9th Feb 2008 20:43
@Jason
You do not get anymore CPU power

Assuming your monitor is refreshing 60 times a second

If you need an object to rotate once per second it needs to move (360 / 60) or 6 degrees per refresh every 17ms.

What this code does when it shows 6000 fps is rotate the object 6 / 100 or .06 but as the sync only takes places 100th time the object has rotated the same 6 degrees every 17 ms.

To prove it set the rotation to 6 degrees, remark out the timing code add enough objects to slow the "RPS" to 30. delete the remarks and run you will be doing less than 30 RPS & FPS or your object will be moving in a very jerky manner.


Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 9th Feb 2008 22:03
interesting - thank you for post - I'm thinking thinking.... nothing to say yet... just thinking

Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 11th Feb 2008 23:44 Edited at: 12th Feb 2008 07:38
Edit: Wasn't thinking right with db functions. Post deleted

A link in the top of the first post above is my final solution to freeing up the cpu and time based movement.

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 12th Feb 2008 07:51
If you want a constant motion per time simply move the object by the amount you wish to move per second / fps

For example if I wish to move the camera at 5 units per second and my current fps = 50 :

distance to move 5 units per second
move object 5 / 50 fps or .1 unit per frame

To rotate an object 1 rps and y curent frame rate is 50 / second :

rotate object 360 / 50 fps or 7.2 degrees per frame

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 12th Feb 2008 08:05
@Todd Riggins

After I posted the previous message I noticed that you edited out your initial post and the code. Please don't do this as you have made every comment that follows your initial original post irrelevant


please use edits to correct spelling error etc and not rewrite the post

Codger

System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem
Todd Riggins
19
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 12th Feb 2008 11:24 Edited at: 12th Feb 2008 11:28
[UPDATE]
My solution for freeing up cpu time and smooth time based movemnt can be seen here:
Visit http://forum.thegamecreators.com/?m=forum_view&t=123797&b=22
------------------------------------------------------------


@Codger

Put code back up on what the original problem was so it's back to being relevant.

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack

Login to post a reply

Server time is: 2024-09-29 11:32:15
Your offset time is: 2024-09-29 11:32:15