我需要在Qt5項目中執行多重採樣,但我不確定如何使用QOpenGLFrameBufferObject來執行FSAA。就我搜索的文檔而言,沒有關於如何執行此操作的示例,文檔僅提及:「如果要使用啓用多重採樣的幀緩衝區對象作爲紋理,則首先需要使用QOpenGLContext將其複製到常規幀緩衝區對象。:: blitFramebuffer()」我的代碼目前看起來是這樣的:Qt5使用QOpenGLFrameBufferObject的OpenGL多重採樣類
//Enable FSAA for better output
int vp[4];
glGetIntegerv(GL_VIEWPORT, vp);
if(m_lpFBO == NULL)
{
//MultiSampling set to 4 now
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setMipmap(true);
format.setSamples(4);
format.setTextureTarget(GL_TEXTURE_2D);
format.setInternalTextureFormat(GL_RGBA32F_ARB);
//Create the FBO
m_lpFBO = new QOpenGLFramebufferObject(vp[2], vp[3], format);
m_lpFBOSurface = new QGLFramebufferObjectSurface(m_lpFBO);
}
QRect rc(0, 0, vp[2], vp[3]);
QGLSubsurface sub(lpPainter->currentSurface(), rc);
m_lpFBO->bind();
sub.setFramebufferObject(m_lpFBO);
lpPainter->pushSurface(&sub);
//Draw as usual
.
.
.
lpPainter->popSurface();
//Now Copy
QOpenGLFramebufferObject::blitFramebuffer(lpPainter->currentSurface()->framebufferObject(), rc, m_lpFBO, rc);
嗨,這個解決方案的工作? – SRINI794