I want to be able to display and close an image within a few miliseonds.
I generally understand how to do this for a few seconds, but how can I achieve accurate milisecond rendering?
What is the approach to ensure that I can be certain an image has only been open for 10 miliseconds or even 5 milisecond and that my monitor has indeed displayed this image (assuming I have for example a 240hz monitor).
From my limited understanding of a monitors refresh rate, a 240hz monitor may refresh the display 240 times a second which is around every 4 miliseconds. If I want to display something for 5 miliseconds, it's possible that more than half that time my monitor hasn't really been refreshing (therefore not displaying). Under that logic is it correct that I would need to display the image for around 4 or 8 miliseconds? Is there a way to synchronize my displays refresh rate with the output of my program?
I'm planning to do this in c although the language isn't too critical provided the problem can be solved. I haven't managed to find any sources on how to approach this sort of problem. Is there any direction to a solution for this sort of problem?
CodePudding user response:
This sync'ing is known as V-sync (Vertical Sync), since displays are typically oriented in horizontal lines. That means an entire screen is shown after the last line is drawn, just before the next line at the top of the screen will be drawn. I.e. the V-sync event is the vertical wrap-around.
You need a game-oriented API like DirectX or OpenGL