Is there a way to remove 60 fps cap in GLFW?

15,551

Is there a way to remove 60 fps cap in GLFW?

The easiest way is to use single buffering instead of double buffering. Since at single buffering is always use the same buffer there is no buffer swap and no "vsync".

Use the glfwWindowHint to disable double buffering:

glfwWindowHint(GLFW_DOUBLEBUFFER, GLFW_FALSE);
GLFWwindow *wnd = glfwCreateWindow(w, h, "OGL window", nullptr, nullptr);

Note, when you use singel buffering, then you have to explicite force execution of the GL commands by (glFlush), instead of the buffer swap (glfwSwapBuffers).


Another possibility is to set the number of screen updates to wait from the time glfwSwapBuffers was called before swapping the buffers to 0. This can be done by glfwSwapInterval, after making the OpenGL context current (glfwMakeContextCurrent):

glfwMakeContextCurrent(wnd);
glfwSwapInterval(0);

But note, whether this solution works or not, may depend on the hardware and the driver.

Share:
15,551

Related videos on Youtube

Manu
Author by

Manu

Updated on September 15, 2022

Comments

  • Manu
    Manu over 1 year

    I'm writting a game with OGL / GLFW in c++.

    My game is always running at 60 fps and without any screen tearing. After doing some research, it seems that the glfwSwapInterval() function should be able to enable/disable V-sync or the 60fps cap.

    However, no matter the value I pass to the function, the framerate stays locked at 60 and there is no tearing whatsoever. I have also checked the compositor settings on linux and the nvidia panel, and they take no effect.

    This is a common thing I assume, is there a way to get around this fps cap?

    • ricco19
      ricco19 almost 6 years
      You may have vsync hard enabled in your GPU driver. Search how to disable it with whatever vendor, and see if it unlocks the framerate.
    • Yakk - Adam Nevraumont
      Yakk - Adam Nevraumont almost 6 years
      10 seconds of google (GLFW vsync) led me to this: glfw.org/docs/latest/… -- a way to query about your GLFW implementations implementation of extensions around tear support. When you called it what did it say about support for those extensions?