OpenGL tearing with fullscreen native resolution

不想你离开。 提交于 2019-12-13 17:08:52

问题


I've got an OpenGL application with win32 api without glut etc...and I run into a problem with screen tearing in fullscreen. Basicly I have set WS_POPUP as a window style and resolution of my monitor as window size. I'm running on AMD radeon HD 7770 and I see terrible tearing! When I put WS_POPUPWINDOW style instead of WS_POPUP, the tearing is gone, however I have unwanted border around my scene. Another thing I noticed is fact, that the tearing disappears when the resolution is NOT native. So when I pass my_screen_resolution + 1 as size parameter, the tearing is gone.

RESx = 1920;
RESy = 1080;
hwnd = CreateWindowEx(NULL, NAME, NAME, WS_POPUP, 0, 0, RESx, RESy, NULL, NULL, hInstance, NULL);
SetWindowPos(hwnd, 0, -1, -1, RESx + 1, RESy + 1, 0); // With this function call, the tearing disappears!

What can I do to get rid of the tearing without having to run on not native resolution?

EDIT: (Hint: It's not V-sync)


回答1:


What can I do to get rid of the tearing without having to run on not native resolution?

EDIT: (Hint: It's not V-sync)

Yes it is V-Sync.

When you make a fullscreen window, it will bypass the DWM compositor.

If the window is not covering the full screen its contents are going through the DWM compositor. The DWM compositor itself makes itself a copy of the window's contents whenever something indicates, that it is done drawing (return from WM_PAINT handler, EndPaint or SwapBuffers called). The composition itself happens V-synced.

Thanks for your advice, but I want to aviod the tearing without vsync. With vsync I have terrible input lag.

Then you're doing something wrong in your input processing. Most likely your event loop only processes one input event at a time then does a redraw. If that's the case and your scene complexity goes up, then you're getting lag, that's proportional to your scene's drawing complexity. You don't want this to happen.

What you should do is accumulate all the input events that piled up between redraws and coalesce them into a single new drawing state. Ideally input events are collected until only just before the scene is set up for drawing to reflect the most recent state. If you want to get fancy you my add a Kalman filter to predict the input state at the moment the frame gets shown to the user and use that for drawing the scene.




回答2:


To remove OpenGL tearing, you should have "enable" vsync. Follow this link for details: how to enable vertical sync in opengl?



来源:https://stackoverflow.com/questions/30293074/opengl-tearing-with-fullscreen-native-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!