# Swap buffers Callback

**URL:** <https://discourse.glfw.org/t/swap-buffers-callback/748>\
**Category:** support\
**Created:** [September 2, 2016, 2:28pm UTC](https://discourse.glfw.org/t/swap-buffers-callback/748 "2016-09-02T14:28:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Earless](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@Earless](https://discourse.glfw.org/u/Earless)\
**Post date:** [September 2, 2016, 2:28pm UTC](https://discourse.glfw.org/t/swap-buffers-callback/748/1 "2016-09-02T14:28:22Z")

</div>

For my application, timing is quite critical. I need to know when exactly the buffers are swapped.

First I was thinking to use glfwGetTime() and just keep track of the time, however in no way this guarantees a high accuracy; you might be off by a few miliseconds or something.

Hence, I was thinking that it would be awesome if there is a callback, which is called everytime the buffers are swapped. However, after looking in the GLFW documentation, googling and looking through many posts, I haven’t found anything I could use.

My question, thus, is: is there such a callback (I fear not), and if not, what else can I do to have an accurate estimation when the buffers are swapped?

Thanks in advance:)

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 2, 2016, 3:29pm UTC](https://discourse.glfw.org/t/swap-buffers-callback/748/2 "2016-09-02T15:29:39Z")

</div>

GLFW’s buffer swapping simply wraps the OS OpenGL buffer swap API, and this has no callback with the actual time the buffers are swapped - indeed there’s no guarantee that the swap is even complete after the call has returned.

In order to get timing details, you could use OpenGL timer queries - placing one before the swap would allow you to query when it occurred.

---

<div class="post-metadata">

**Author:** ![Earless](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@Earless](https://discourse.glfw.org/u/Earless)\
**Post date:** [September 5, 2016, 7:19am UTC](https://discourse.glfw.org/t/swap-buffers-callback/748/3 "2016-09-05T07:19:45Z")

</div>

Thanks for the reply:)

Yeah, I was already playing around with timer queries. The problem was that it is not that accurate (in the sense that each frame is timed slightly differently). Hence, I thought a callback would be the most accurate way. Guess I will have to continue with the timer queries then.
