RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x8cd6
Warning: RenderStage::runCameraSetUp(State&) Pbuffer does not support multiple color outputs.
1、attach(BufferComponent buffer, osg::Texture* texture…)
经测试,相同的源码osg3.4版本报错,osg3.6版本正常。后来经过对3.4版本下,rtt、mtr横向对比,发现出问题的原因是{
osg::Texture2D::setInternalFormat(internalFormat);
osg::Texture2D::setSourceFormat(GL_RGBA);
osg::Texture2D::setSourceType(GL_FLOAT);
}代码段,3.4版本必须明确指定多目标的输出格式如:osg::Texture2D::setSourceFormat(GL_RGBA);而3.6则不用,从此可见 osg不同版本对glsl的支持是有差异的。
2、attach(BufferComponent buffer, osg::Image* image…)
attach到image,但image没有分配内存,错误示例:
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setInternalFormat(GL_RGBA32F_ARB);
texture->setSourceFormat(GL_RGBA);
texture->setSourceType(GL_FLOAT);
texture->setTextureSize(s, t);
...
pCamera->attach(osg::Camera::COLOR_BUFFER1, texture ->getImage());
正确示例:
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
osg::ref_ptr<osg::Image> img = new osg::Image;
img->allocateImage(s, t, 1, GL_RGBA, GL_FLOAT);
img->setInternalTextureFormat(GL_RGBA32F_ARB);
texture->setImage(img);
...
pCamera->attach(osg::Camera::COLOR_BUFFER1, texture ->getImage());