问题描述
我通常使用带有以下参数的wglChoosePixelFormatARB()
创建像素格式:
I usually create a pixel format using wglChoosePixelFormatARB()
with these arguments (among others):
WGL_DOUBLE_BUFFER_ARB = GL_TRUE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 4
即双重缓冲和x4多重采样.这样就可以了.
但是当我尝试打开双缓冲时:
i.e. double buffering on and x4 multisampling. This works just fine.
But when I try to turn of the double buffering:
WGL_DOUBLE_BUFFER_ARB = GL_FALSE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 4
对wglChoosePixelFormatARB()
的调用失败(或者表明它没有创建任何内容)
有效关闭多重采样后:
The call to wglChoosePixelFormatARB()
fails (or rather indicates it didn't create anything)
When I effectively turn multisampling off:
WGL_DOUBLE_BUFFER_ARB = GL_FALSE
WGL_SAMPLE_BUFFERS_ARB = GL_TRUE
WGL_SAMPLES_ARB = 1
我再次工作正常.
是否存在某些内在因素阻止非双缓冲像素格式进行多次采样?
我关闭双缓冲的原因是为了获得不受限制的帧速率.在双缓冲的情况下,我得到的帧率仅高达60 FPS(此笔记本液晶显示器的工作频率为60Hz).但是通过双重缓冲,我可以达到1500 FPS.有没有办法通过双重缓冲来实现这一目标?
The reason I'm turning double buffering off is to achieve unconstrained frame rate. with double buffering the frame rate I get is only up to 60 FPS (this laptop LCD works at 60Hz). But with double buffering off I can get up to 1500 FPS. Is there a way to achieve this with double buffering on?
推荐答案
从理论上讲,以单缓冲区模式绘制意味着您正在直接修改呈现在屏幕上的内容(也就是前缓冲区).由于该内存已经是一种特定的格式,因此您无需选择其他内存.(我说的是理论上的,因为该平台可以在实践中取悦它.例如Aero不允许访问前端缓冲区.)
In theory, drawing in a single-buffer mode means that you're directly modifying what is being presented to the screen (aka the front buffer).Since that memory is in a specific format already, you don't get to choose another one.(I'm saying in theory because the platform does however it pleases it in practice. Aero for example does not allow access to the front-buffer).
此外,在进行多重采样时,将X采样/像素转换为1像素以进行绘制的步骤是将后缓冲区复制到前缓冲区时(称为解析步骤).在单缓冲区模式下,没有这样的步骤.
Moreover, when doing multisampling, the step that converts the X samples/pixel to 1 pixel for drawing is when the back-buffer is copied to the front buffer (what is called the resolve step). In single buffer mode, there is no such step.
关于60 fps锁定,您可能需要查看 WGL_EXT_swap_control
.这里的问题是您通常不希望在屏幕刷新数据时更新屏幕上显示的内容.它会产生撕裂.因此,默认情况下,交换"仅在屏幕垂直同步(aka vsync)时更新,因此您最终只能锁定屏幕的刷新率.
As to your 60 fps locking, you might want to look atWGL_EXT_swap_control
. The issue here is that you don't generally want to update what is being shown on screen while the screen refreshes the data; it creates tearing. So by default, Swap only updates while the screen is vertical syncing (aka vsync), so you end up locking to the refresh rate of the screen.
如果您不介意显示器显示不同框架的部分,则可以将其关闭.
If you don't mind your display showing parts of different frames, you can turn it off.
为完整起见,还有一种称为三重缓冲的替代模式,该模式本质上是在两个后缓冲之间显示GPU乒乓渲染,而显示前缓冲.当需要更改屏幕上显示的内容(vsync)时,由GPU选择最后完成的后缓冲区.可悲的是,我不知道要使用WGL方法进行三重缓冲.
For completeness, there is an alternative mode called triple buffering, that essentially has the GPU ping-pong rendering between 2 back-buffers while the front buffer is shown. It is up to the gpu to pick the last finished back-buffer when comes time to change what shows on screen (vsync). Sadly, I am not aware of a WGL method to ask for triple buffering.
这篇关于WGL:没有双重缓冲+多重采样=失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!