Precise exposition of an image for set number of frames (Vsync?)

Posted by Istrebitel on Game Development See other posts from Game Development or by Istrebitel
Published on 2013-11-11T11:15:53Z Indexed on 2013/11/11 16:18 UTC
Read the original article Hit count: 140

Filed under:

I need to make a simple enough program in C#, but it seems to be impossible via usual WinForms means. I need to show something (a string of text, an image) on the screen for very small time interval. Since typical monitors are 60Hz, this interval would be 1 or 2 frames (16,6 or 33,3 ms). I tried doing this with usual WinForms, and it is not possible because, apparently, there is no way to know how many frames were output to the monitor since some point in time. I can only draw on the controls, and monitor output is totally independant.

So even if I run the timer, say, for 17 ms, between showing and hiding the image, it still sometimes manages not to draw a single frame of my image on the screen (even though theoretically it should, because 17ms > 16,6ms). Moreover, even 20ms seems to slow (even though i should be more than enough).

I did some game development as a hobby in the past (Delphi X, XNA) and I know that you usually draw the whole screen by yourself, each frame. Also, I know that there is an option called Vsync in most modern games, that allows you to synchronize your framerate to your monitor's frame rate.

So, is it possible? I mean, to actually know how many frames were sent to the monitor with w/e I want to show?

© Game Development or respective owner

Related posts about frame-rate