[英]Using OpenGL frame buffer objects with Qt (QOpenGLWidget), how to disable multisampling when drawing to frame buffer
As the title suggests, I'm using Qt for OpenGL drawing, and with QOpenGLWidget I can turn on multisampling for the main screen buffer with QSurfaceFormat's setSamples() function. 如标题所示,我将Qt用于OpenGL绘图,并且可以使用QOpenGLWidget使用QSurfaceFormat的setSamples()函数打开主屏幕缓冲区的多重采样。 This works fine and looks pretty nice. 这工作正常,看起来非常不错。 However, I'm also drawing into a custom frame buffer (using glGenFramebuffers, glBindFramebuffer(), etc) in the background, where I don't want anti-aliasing (since it's drawing using color encoding for selection purposes), but it seems to be inheriting the multi-sampling from the main QOpenGLWidget somehow. 但是,我还在后台绘制了一个自定义帧缓冲区(使用glGenFramebuffers,glBindFramebuffer()等),在此我不想进行抗锯齿(因为它使用颜色编码进行选择)将以某种方式从主QOpenGLWidget继承多采样。 Any ideas on how to disable that, to use multisampling in the main window but not in my own custom off-screen frame buffers? 关于如何禁用它,在主窗口中而不是在我自己的自定义屏幕外帧缓冲区中使用多重采样的任何想法?
Multisampled rendering is enabled or disabled by using the glEnable/Disable(GL_MULTISAMPLE)
. 使用glEnable/Disable(GL_MULTISAMPLE)
启用或禁用多采样渲染。 This state is not part of the framebuffer's state; 此状态不属于帧缓冲区状态; it's regular context state. 它是常规的上下文状态。 As such, even when you switch framebuffers, that state will be unaffected. 这样,即使您切换帧缓冲区,该状态也不会受到影响。
Additionally, the multisample enable/disable switch doesn't mean anything if your attached images don't have multiple samples. 此外,如果您所连接的图像没有多个样本,则多样本启用/禁用开关没有任何意义。 If you're creating images for non-multisampled rendering, there's no reason to create them with multiple samples. 如果要为非多重采样渲染创建图像,则没有理由使用多个样本创建它们。 So create single-sample images. 因此,创建单样本图像。
好吧,在我的OpenGL代码中找不到禁用或避免它的方法,但是如果我将默认格式设置为0个样本,而QOpenGLWidget的格式设置为2/4/8 /,则为framebuffer对象创建抗锯齿功能时将不会使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.