简体   繁体   English

结合使用带有Qt的OpenGL帧缓冲区对象(QOpenGLWidget),如何在绘制到帧缓冲区时禁用多重采样

[英]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.

相关问题 如何使用 QOpenGLFramebufferObject 对两个透明帧缓冲区对象进行 blit? - How to blit two transparent frame buffer objects using QOpenGLFramebufferObject? 如何强制OpenGL清除对象以使用QOpenGLWidget进行缓冲区处理? - How do I force OpenGL to clear an object for buffer processing with a QOpenGLWidget? Windows上的OpenGL顶点缓冲对象如何运行? QT Windows - OpenGL vertex buffer objects on windows-how run it? qt windows 在两个应用程序之间共享OpenGL帧缓冲区/渲染缓冲区 - Share OpenGL frame buffer / render buffer between two applications 需要使用 QT QOpenGLWidget 渲染 YUV 帧(来自 ffmpeg 的 AVFrame) - Need to render YUV frame(AVFrame from ffmpeg) using QT QOpenGLWidget 如何使用 qopenglwidget 中的线将缓冲区中的一些顶点渲染为点而其余顶点渲染? - How to render some vertices in a buffer as points and the rest using lines in qopenglwidget? 如何使用QOpenGLWidget在Qt的单独线程中渲染opengl? - How to render opengl in a separate thread in Qt, using QOpenGLWidget? 使用QOpenGLFrameBufferObject类的Qt5 OpenGL多重采样 - Qt5 OpenGL Multisampling using QOpenGLFrameBufferObject class OpenGL帧缓冲功能无法在单独的类中完全运行 - OpenGL frame-buffer functions not fully working in separate class 如何在Qt中使用“顶点缓冲对象”渲染地形? - How do I render terrain using Vertex Buffer Objects in Qt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM