【发布时间】:2013-08-12 08:57:32
【问题描述】:
这是使用投影到屏幕上的帧缓冲区纹理和“主帧缓冲区”的同一对象的比较
左图有点模糊,而右图更清晰。此外,glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ) 等一些选项在渲染到帧缓冲区时无法正常工作。
我的“管道”看起来像这样
Bind frambuffer
draw all geometry
Unbind
Draw on Quad like as texture.
所以我想知道为什么“主帧缓冲区”可以做到这一点而“我的”不能?这两者有什么区别?用户帧缓冲区是否会跳过某些阶段?是否可以匹配主缓冲区的质量?
void Fbo::Build()
{
glGenFramebuffers(1, &fboId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
renderTexId.resize(nColorAttachments);
glGenTextures(renderTexId.size(),&renderTexId[0]);
for(int i=0; i<nColorAttachments; i++)
{
glBindTexture(format,renderTexId[i]);
glTexParameterf(format, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(format, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(format, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(format, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(format, 0, type, width, height, 0, type, GL_FLOAT, 0);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,renderTexId[i], 0);
}
glBindTexture(GL_TEXTURE_2D, 0);
if(hasDepth)
{
glGenRenderbuffers(1, &depthBufferId);
glBindRenderbuffer(GL_RENDERBUFFER, depthBufferId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
//glTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT24, width, height, 0,GL_DEPTH_COMPONENT, GL_FLOAT, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBufferId);
}
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
printf("FBO error, status: 0x%x\n", status);
}
}
【问题讨论】:
-
这很有趣,左边的图像对我来说看起来更干净。看起来左边的图像正在做一些抗锯齿。
-
看起来也是GL_LINEAR(左)和GL_NEAREST(右)的区别
-
看起来像抗锯齿。
-
左边更平滑,好像在使用抗锯齿。如果它是全屏四边形上的纹理,GL_LINEAR 过滤不会做同样的事情吗?