Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate? Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Go Back  Xtreme Visual Basic Talk > > > Do there exist methods of controlling framerate?


Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2008, 06:00 PM
FrameRateMax FrameRateMax is offline
Newcomer
 
Join Date: Feb 2008
Posts: 4
Question Do there exist methods of controlling framerate?


Hi, it seems that what framerate I get by using Timers largely depends on what my draw code is (IE alpha image, or bitblt with a buffer form, etc).
Is there a known method of trying to "control" the framerate to keep it at a certain number or within a certain range? Thanks!
Reply With Quote
  #2  
Old 02-06-2008, 01:59 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

The framerate depends on what you are doing and what computer you are on. Even a quick draw operation may be slow on a slower PC.

There is no way to speed your drawing up but you can slow it down so it should run at the same rate.

The way i normally do it is to refresh everything as fast as the PC will allow but time how long it takes. If it takes longer to draw everything then things will move further during that time so everything should move at the same speed no matter what you are drawing. I use the GetTickCount API for this.

The same API can also be used to make your app wait if you put it in a loop. I use this method for splash screens. If i make it visible for 2 seconds then it will time how long it takes for the app to load then keep looping for the remainder of the 2 seconds. As long as the app loads in less than 2 seconds the splash screen will always be shown for exactly 2 seconds
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #3  
Old 02-07-2008, 02:17 AM
AdrianDeAngelis's Avatar
AdrianDeAngelis AdrianDeAngelis is offline
Contributor
 
Join Date: May 2005
Location: Australia
Posts: 549
Default

Firstly you probably need to use a higher resolution timing code than a simple timers or the gettime function, try using gettickcount or queryperformancecounter.

You can do either one of a few things

1) run on a time dependent system where you time how long it takes each cycle to process and then everything is moved according to that time. Eg you time that it takes your code 10ms to process and your ball moves at 5 pixels per sec then your ball will move 5 * 10 ms * 0.001 pixels that cycle. problem with this method is that while everyone's PC will be in synch time-wise, the accuracy of movement and collision detection will be reduced in slow PC's. for example where a fast PC will register a collision with a wall because the ball moves very small amounts in the small time interval it takes to process, on a slow PC with a very large processing time the ball might move so far in a single cycle that it could pass though the wall without registering a collision

2) Make each cycle process some arbitrary timestep: eg 1ms. Each PC running the program will run it as accurately with the same results however a slow PC may struggle noticeably and appear to be moving in slow-mo compared to a fast PC.

3) do a bit of both... because graphics often takes up much more CPU time than physics and other calculations you can disengage the graphics processing from the other processing. This is a bit tricky but say it takes your code 50 -60ms to draw onto the screen and around 10ms to process the other stuff then you could do around 5-6 other cycles in one graphics cycle.

You will still run into problems with slow PC's but at least mid range and high end ones will process more consistently and you still get the benefit of time based graphics.

Code:
TimeStart = Timer 'or other mechanism TimeEnd = TimeStart 'starting loop, no time elapsed Do Until Exit = True Elapsed = TimeEnd -TimeStart TimeStart = TimeEnd TimeLeft = Elapsed Do until TimeLeft < TimeStep 'process other stuff Ball.X = Ball.X + (Ball.SPD * TimeStep) Loop 'Process graphics Ball.Animation = Ball.Animation + (Ball.AnimSPD * Elapsed) TimeEnd = Timer Loop
__________________
Automation error... What do you mean automation error you %#@*&!$ thing!

Star Admiral: 3D tactical space sim *** New Version 0.38 10/01/09 ***
Damage, shields and special weapons systems
Reply With Quote
  #4  
Old 03-03-2008, 10:24 PM
FrameRateMax FrameRateMax is offline
Newcomer
 
Join Date: Feb 2008
Posts: 4
Default

Thanks!!
I'll try those techniques out and see what I get. Cheers.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate? Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate? Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
 
Do there exist methods of controlling framerate?
Do there exist methods of controlling framerate?
 
-->