Limiting framerate in DirectDraw
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?
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);
}
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement