I’m creating an OpenGL application that displays some stimulus to the user and measures their response time with some input device.
My question is, what is the most accurate way to determine when the stimulus has actually been rendered onto the monitor, without using any special hardware device?
From my understanding, glFinish() will block until all previous OpenGL commands have been executed. So should the following code be enough:
Correct me if I am wrong, but doesn’t SwapBuffers call glFinish internally? I mean, the scene has to be ready when you swap the buffers. I think you can just go ahead and delete the glFinish command
After glFinish(), you know every command has been finished, but nothing is visible yet. Because every command is finished, SwapBuffers takes only a minimum amount of time.
SwapBuffers alone is not enough, you can’t be sure that it really blocks until the swap occurs.
Btw. I wouldn’t use the time() command, since it has a fairly low resolution…
SwapBuffers alone is not enough, you can’t be sure that it really blocks until the swap occurs.
This is why I thought that glFinish() should be called after SwapBuffers(), since I want to be sure that the swap has occured. But from what you said it sounds like glFinish() doesn’t block for the SwapBuffers() command, or at least it is driver dependent. Is this correct?
BTW, the time() command was just psuedo-code. I’m using higher resolution timers.