I’m trying to learn opengl through a tutorial and there is typically a main loop like this:
do {
glClear(...);
render_scene_with_lots_of_opengl_commands();
glfwSwapBuffers(...);
} while(true);
As I understand it, there are two buffers - one currently shown and one you draw on. The buffers cannot be swapped at any time because that would cause tearing so swapbuffers() will wait for vertical blanking, a short time time interval that occurs once every 1/60 seconds (if that’s your screens refreshrate) during which the swap can take place without tearing.
Now, let’s say I also want to add a somewhat timeconsuming calculation to be done for every drawn frame that does not involve drawing into the current draw-buffer. I’d expect the code to look like so:
do {
glClear(...);
render_scene_with_lots_of_opengl_commands();
glReadyToSwapBuffers();
doCalculations();
glfwSwapBuffers(...);
} while(true);
The extra gl-call I added, glReadyToSwapBuffers(), may not exist or be called something else. It is supposed to tell the opengl framework that I’m finished drawing the scene and that I want it to be displayed at the next moment when that can be done (vertical blanking). The difference between this and glfwSwapBuffers() is supposed to be that glReadyToSwapBuffers() should simply schedule the switch (perhaps to be completed in an interrupt) and return immediately. The point is that I could then doCalculations() in parallel with waiting for vblank instead of doing these two serially, i.e. if the entire loop takes a little more than 1/60 second I could get, say, 50 fps instead of 30.
My question: is there a call like my suggested glReadyToSwapBuffers() and if not - why not?