Hi, I want to do a thing I never did before. I want to read number from a file after regular time intervals (20 milliseconds for example. )
I am running a runtime programme so I cannot use Sleep() as it makes the screen blank . I am working on an OpenGL code. I have my file reading syntax ready so only thing remains is putting a time interval between reading two numbers !
Can anybody give me a suggestion as to where can I start.
Hi, one way to do it is to use multiple threads, I don't know if your already doing that.
Though that's a bit overboard just to tell the time. The easier option which I would recommend is using timers.
See http://www.cplusplus.com/reference/clibrary/ctime/difftime/ and you can work it how you want. It's really useful, and uses a good example, I've used it loads. Just take two separate times and compare. It should do the job, though I'm not entirely sure of your program setup, you may find it hard to implement, though in many cases it's pretty straight forward.
opengl? if you are using some framework like X, GTK or QT there are timers
available, also input methods for files to invoke a callback when there is data to be read.
that's where I would look first.
for instance in X I have used this: