Hello everybody, new to the forums! I’m having trouble understanding the nature of glfwSwapInterval
Question #1
If I don’t call this function at any point of my program, I get a lot of stuttering in my framerate. On the other hand if I call the function and set it to 1, there’s pretty much no stuttering. Maybe a couple of framerate dips here and there, but nothing very noticeable.
If I set the interval to 0, I get the smoothest framerate out of all situations! But, my CPU usage rises, which makes my processor fans spin more. Keep in mind I’m calling glfwSwapInterval once before the game loop in all situations. I read I shouldn’t be setting the interval every frame.
What are the best practices I should take?
Question #2
What are the differences between setting the interval to 1, 0, or just not calling the function?
Question #3
I understand that setting the interval to 1 makes glfw wait for the next screen refresh so that glfwSwapBuffers returns when that happens. Which is also why my profiler timed the SwapBuffers function at 15.x ms, but when the interval is set to 0 …swap buffers takes only 0.2ms.
What if I were rendering a complicated scene with the interval set to 1, does SwapBuffers take those 15.x ms away from my game, or it only uses a the remaining time available? I also thought it could be due to the fact that my scene is very simple and doesn’t get close to 15ms. I’m confused.
I hope I made sense, thank you very much if you read this far. By the way I’ll detail what my scene consist of below.
My scene is simple:
- one quad.
- I bind a texture and shader only once before the update loop.
- I only call the following glfw functions in my update loop: glfwGetTime, glfwSwapBuffers, and glfwPollEvents.
Thanks for reading