Advertisement

Limiting framerate in DirectDraw

Started by February 22, 2002 12:08 PM
3 comments, last by Out of Sync 22 years, 10 months ago
I have a problem with DirectDraw. I use the QueryPerformanceCounter() function to limit the framerate, but the scrolling looks more like "jumping" than scrolling. can anyone help me??
How are you limiting the framerate? Are you defining your animations in terms of time (i.e. units per sec), or are you using Andre LaMothe''s (terrible) method of waiting at the end of the game loop for a certain amount of time to pass?
Advertisement
I use this function:

void LimitFrameRate(void)
{
do
{
QueryPerformanceCounter(&now);

passed = now.QuadPart - last.QuadPart;

framerate = double(Frequenz.QuadPart) / double(passed);
}
while(framerate > FRAMERATE); // FRAMERATE = 60

QueryPerformanceCounter(&last);
}
Is FrameRate in milliseconds?

If so it should be 1000/60 == 16.67. Round it up or down to 16 or 17 it doesn''t matter.

Once you get that working, there is a better way using IF instead of WHILE so you can keep processing input even if a user''s computer is dragging.

Ben

[The Rabbit Hole | The Labyrinth | Programming | Gang Wars | The Wall]
yes I got that to work, but I need "smooth" scrolling
(for a sidescroller).
and with this method it "jumps".

This topic is closed to new replies.

Advertisement