I want to know the framenumber of the current frame at any time, regardless the bound window or if it was changed. I dont want to implement a framecounter in my window class, since that would 1. require every depending library to check which window is bound and only use frames from there and 2. Isnt independent of windows.

I am sure there is a way to simply know when A opengl context has something new send to it. Please help me find it!

I want a frame number that is in sync with other debugging tools so I can easily compare and contrast.

  • 3
    \$\begingroup\$ What are you trying to do? \$\endgroup\$ – HolyBlackCat Nov 3 '17 at 17:32
  • \$\begingroup\$ What @HolyBlackCat said - what problem are you actually trying to solve? Tell us what you want to do, not how you want to do it. There may be a better way. \$\endgroup\$ – Maximus Minimus Nov 3 '17 at 19:02
  • \$\begingroup\$ @LeComteduMerde-fou I added it \$\endgroup\$ – MoustacheSpy Nov 3 '17 at 19:41

OpenGL cannot tell you this.

The (pure) OpenGL API doesn't even support the actual swap of the front and back buffer, the thing that we generally interpret to signal the end of one frame and the start of the next in modern code. That is all handled by platform-specific APIs, such as SwapBuffers on Windows, flushBuffer on macOS, and so on. The closest thing in the pure OpenGL API is glFlush or glFinish if you're using them, and neither of them come with a way to tell you how many times they've been called.

You have to implement this kind of counter yourself.

If you provide more information about what broader problem you're trying to solve, it's possible we can provide more concrete solutions. Lacking that information, you should probably just increment some number stored in a shared place (that is, not in each window but in a more central location, perhaps in your main Game class that owns all the windows, or whatever) whenever any window completes a frame. The utility of this number seems suspect to me, but I can't say for sure without knowing what you're doing.

  • \$\begingroup\$ I simply want to make the framenumber available to the log class I have written so I can include it in every entry to easily intercooperate with other opengl debugger tools. \$\endgroup\$ – MoustacheSpy Nov 3 '17 at 18:43
  • \$\begingroup\$ Those numbers won't be in sync unless you increment the frame counter based on the same data the debugger is... but fortunately that's almost always the swap call, so it shouldn't be too hard. \$\endgroup\$ – Josh Nov 3 '17 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.