先渲染到帧缓冲FBO,再将帧缓冲FBO的内容拷贝到当前窗口
为什么要通过FBO转以下呢,为什么不直接渲染到当前窗口呢,难道是为了适应桌面、移动等多终端吗
通过使用FBO的多重纹理采样,可以使画面更清晰。
qtdeclarative\src\quick\items\qquickframebufferobject.cpp
class QSGFramebufferObjectNode : public QSGTextureProvider, public QSGSimpleTextureNode
{
void render()
{
if (renderPending) {
renderPending = false;
fbo->bind(); //使用FBO
QOpenGLContext::currentContext()->functions()->glViewport(0, 0, fbo->width(), fbo->height());
renderer->render();//渲染到FBO,这里一般调用用户自定义的渲染过程
fbo->bindDefault();//使用当前窗口
if (msDisplayFbo)
QOpenGLFramebufferObject::blitFramebuffer(msDisplayFbo, fbo);//将渲染内容拷贝到当前窗口
markDirty(QSGNode::DirtyMaterial);
emit textureChanged();
}
}
}