Hello Guest

GLFW Screen Tearing

  • 6 Replies
  • 6952 Views
GLFW Screen Tearing
« on: September 20, 2016, 18:32:23 »
Hello,

I switched to lwjgl3 with glfw recently. I'm experiencing the problem of screen tearing despite using vsync (enabled via glfwSwapInterval(1); ). I think I'm not activating it at the wrong place because it successfully limits the frame rate to the refresh rate. If I set it to 0 and use an fps cap, it gets a slight bit better. If I force vsync in the nvidia control panel, every evidence of screen tearing is gone. When running commercial games, theres no need to force vsync because the games get vsync enabled themselves.

The question is now how do I get glfw to properly use vsync?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: GLFW Screen Tearing
« Reply #1 on: September 20, 2016, 20:50:02 »
What LWJGL version are you using? Is this on Windows? Is your application running in windowed or fullscreen mode? If windowed, does vsync work in fullscreen mode?

Re: GLFW Screen Tearing
« Reply #2 on: September 21, 2016, 17:38:59 »
Thank you for your reply. I've tested it with two lwjgl version: 3.0.0 build 90 and nightly from 19. april on Windows 7. It is running in an undecorated window mode (enlarged to the monitor resolution to have it cover the whole screen without the need for "real" fullscreen). Thanks to your suggestion, I tried out the fullscreen mode and every sign of screen tearing is gone. Furthermore the decorated window mode got on my test list as well and every evidence of screen tearing is gone. Thus I can say it happens when using the undecorated window mode. Sorry for not thinking about trying these things myself before asking the question.

The remaining question is how do I get it work in the undecorated window mode? I would prefer this mode because I can switch out from the "pseudo fullscreen" without waiting time and can reduce it to a smaller window to have a look at the console output.
« Last Edit: September 21, 2016, 17:41:31 by Scourge »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: GLFW Screen Tearing
« Reply #3 on: September 21, 2016, 19:27:18 »
I cannot reproduce what you're describing (on Windows 10, Nvidia GTX 970). Could you try with the latest LWJGL nightly build? Also, have you enabled auto-hiding of your taskbar?

Re: GLFW Screen Tearing
« Reply #4 on: September 21, 2016, 19:54:10 »
I've tried the latest nightly build and it still happens when the window has the same resolution as my monitor which is 1920x1080. When I set the size to 1920x1079 or 1920x1081 then every screen tearing is gone. It seems to be the problem when it matches my monitors resolution. By the way I'm using a msi gtx960 (upgraded from a gt440). I do not auto hide my taskbar, it gets automatically hidden if the window resolution gets equal or greater than the current monitor resolution.
« Last Edit: September 21, 2016, 19:59:36 by Scourge »

Re: GLFW Screen Tearing
« Reply #5 on: September 30, 2016, 20:20:31 »
Do you have any idea why it is acting as described? I also noticed the screen tearing effect keeps sticking to almost the same height while it is more likely to jump around when v-sync is disabled. I don't know if I'm enlarging the window the wrong way but may I ask you if you see any mistake in the following code using to enter the decoration less window "pseudo fullscreen mode" (it's from a very simple window class using glfw I wrote to have a few nice features)?
Code: (java) [Select]
    public synchronized void enterFullscreen(){
        if(isInFullscreenMode()) return;
        this.normalSize.setSize(size.width, size.height);
        setSize(monitorVideoMode.width(), monitorVideoMode.height());
        glfwSetWindowPos(windowPointer, 0, 0);
        isInFullscreen = true;
    }

    private void windowSizeChanged(long window, int width, int height){
        if(window != this.windowPointer){
            System.out.println("Not this window..");
            return;
        }
        GL11.glViewport(0, 0, width, height);
        fireViewportSizeChanged(width, height);
    }
windowPointer is the result from glfwCreateWindow(width, height, "Test", NULL, NULL) and monitorVideoMode contains the GLFWVidMode of my main monitor 
The second method is triggered by a lambda expression GLFWWindowSizeCallback.

The workaround mentioned early, which results in changing the setSize row to setSize(monitorVideoMode.width(), monitorVideoMode.height()+1);, works but that couldn't be a good solution, could it?
« Last Edit: September 30, 2016, 20:31:30 by Scourge »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: GLFW Screen Tearing
« Reply #6 on: September 30, 2016, 20:54:54 »
Sorry, I've no idea what might be causing this. Two more things you can try that might help:

- Disable aero.
- Disable your secondary monitor(s).