Waiting for the verticle blank?

Started by
5 comments, last by Kaijin 22 years, 3 months ago
Is it actually worth waiting for the verticle blank before drawing to the screen? i.e. directDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0); Because it imposes a restriction of 70 FPS max on the frame rate as it has to wait for each verticle blank (1/70 of a second). This actually makes my program look choppier rather than smoother like it''s supposed to. - Kaijin
Advertisement
If you''re rendering at a high enough framerate, there''s not much need to wait. What may make your game appear more choppy is if your game loop takes more than 1/70 of a second sometimes. In that case, you could have some refreshes that you don''t update and it could cause that.
Why draw unseen frames? If you want to update your physics, etc more frequently you may, but I don''t understand the need for more frequent screen updates.
first off, why not just flip using the wait flag instead of waiting for the vertical blank and then flipping (less code, same effect). Your probably missing the vertical blank and thats why its choppy. But as far as why do you wait, well if you don''t wait then sometimes it will not draw it correctly. It will start drawing where ever the vertical line is, causing some strange results. What you can do is try triple buffering or using the buffered version of flip (no idea what its actually called as I''ve always been happy with an FPS of 70. But it will flip when it can allowing you to go on, but watch out for buffer overflow).
quote:Original post by TheFez
first off, why not just flip using the wait flag instead of waiting for the vertical blank and then flipping (less code, same effect).


Yeah, I thought that was the case from looking at the DirectX docs. But from looking at André LaMothe''s code in Tricks he uses the DDFLIP_WAIT flag in his flip function, but he also was a wait for verticle blank function too, so I was a little confused.

I was only asking because I''m writing a game engine and the frame rate became choppy when I tried to set the frame rate above 70 FPS. 2 or more logic loops were being called for every graphics loop. And when I took out the wait it was fine.

But I think I''ll leave it in as it''s unlikely the user will need a frame rate above 70 FPS, right?

- Kaijin
That''s André for you. I''ve never been a big fan of his code myself.
The refresh rate will ultimately be equal to the maximum number of frames it is (physically) possible to show. Any calculation showing a higher refresh rate is giving you misleading information. Even if you are drawing at 700 fps, the number of frames that are presented to the user''s eyes will be 70fps. Use the time for better physics/ai/lighting/etc or higher quality textures/sounds/models/etc.

This topic is closed to new replies.

Advertisement