我有一个QOpenGLFramebufferObject,已经在我的应用程序中使用texture()进行写入和读取。我添加了第二个颜色附件以包括一些其他数据,但似乎没有数据写入其中。
// creating the FBO (this has been working)
_drawFbo = new QOpenGLFramebufferObject(PAINT_FBO_WIDTH,PAINT_FBO_WIDTH,QOpenGLFramebufferObject::Depth);
// now I'm adding another color attachment
_drawFbo->addColorAttachment(PAINT_FBO_WIDTH,PAINT_FBO_WIDTH);
然后在绑定着色器时,在我的着色器中我写两个附件:
layout(location=0) out vec4 meshWithPaintColor;
layout(location=1) out vec4 primitiveId;
void main() {
...
meshWithPaintColor = vec4(finalColor,0);
primitiveId = vec4(1,1,1);
当我尝试使用绑定到着色器采样器的textures()[1]值从第二个附件读取时,该值似乎始终为零。
我需要对QOpenGLFramebufferObject做任何事情以允许绘制第二个颜色附件吗?