简体   繁体   English

OpenGL具有全屏原始分辨率

[英]OpenGL tearing with fullscreen native resolution

I've got an OpenGL application with win32 api without glut etc...and I run into a problem with screen tearing in fullscreen. 我有一个带有win32 api且没有glut等的OpenGL应用程序...我遇到了全屏屏幕撕裂的问题。 Basicly I have set WS_POPUP as a window style and resolution of my monitor as window size. 基本上,我将WS_POPUP设置为窗口样式,并将显示器的分辨率设置为窗口大小。 I'm running on AMD radeon HD 7770 and I see terrible tearing! 我在AMD radeon HD 7770上运行,我看到可怕的泪水! When I put WS_POPUPWINDOW style instead of WS_POPUP , the tearing is gone, however I have unwanted border around my scene. 当我使用WS_POPUPWINDOW样式而不是WS_POPUP ,撕裂消失了,但是场景周围没有多余的边框。 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. 因此,当我通过my_screen_resolution + 1作为size参数时,撕裂就消失了。

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) 编辑:(提示:这不是垂直同步)

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. 当您创建全屏窗口时,它将绕过DWM合成器。

If the window is not covering the full screen its contents are going through the DWM compositor. 如果窗口未覆盖全屏,则其内容将通过DWM合成器。 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). 只要有迹象表明,DWM合成器本身就会自己制作窗口内容的副本(从WM_PAINT处理程序,EndPaint或SwapBuffers返回)。 The composition itself happens V-synced. 合成本身发生V同步。

Thanks for your advice, but I want to aviod the tearing without vsync. 感谢您的建议,但我想避免不使用vsync的情况。 With vsync I have terrible input lag. 使用vsync时,我的输入延迟非常糟糕。

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. 如果您想花哨的话,可以添加一个卡尔曼滤波器来预测帧显示给用户时的输入状态,并将其用于绘制场景。

To remove OpenGL tearing, you should have "enable" vsync. 要消除OpenGL撕裂,您应该具有“启用” vsync功能。 Follow this link for details: how to enable vertical sync in opengl? 请点击此链接以获取详细信息: 如何在opengl中启用垂直同步?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM