Hi,

I'm using an osg::Camera to do a render to texture. My setup looks like this
:

    osg::Camera * rttCamera = new osg::Camera();
    rttCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    rttCamera->setRenderOrder(osg::Camera::PRE_RENDER);

rttCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

    osg::Texture2D * rttTex = new osg::Texture2D;
    rttTex->setResizeNonPowerOfTwoHint( false );
    rttTex->setTextureSize( w,h );
    rttTex->setInternalFormat(GL_RGBA16F_ARB);
    rttTex->setSourceFormat(GL_LUMINANCE);
    rttTex->setSourceType(GL_UNSIGNED_BYTE);
    rttTex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
    rttTex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

    osg::Image * rttResultIm = new osg::Image;
    osg::PixelBufferObject* pbo= new osg::PixelBufferObject(rttResultIm);
    rttResultIm->setPixelBufferObject(pbo);

    rttResultIm->allocateImage(w, h, 1, GL_LUMINANCE, GL_UNSIGNED_BYTE);

    rttCamera->attach( osg::Camera::COLOR_BUFFER, rttResultIm );
    rttTex->setImage( rttResultIm );

But when I do this this way, I get the following warning/error :

RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 0x8cd6
Warning: detected OpenGL error 'invalid enumerant' after RenderBin::draw(,)
RenderStage::drawInner(,) FBO status= 0x8cd5

Still everything seems to work fine and my frame rate is about 320 fps. But
if I change the last 2 lines from :

    rttCamera->attach( osg::Camera::COLOR_BUFFER, rttResultIm );
    rttTex->setImage( rttResultIm );

to

    rttCamera->attach( osg::Camera::COLOR_BUFFER, rttTex );
    rttCamera->attach( osg::Camera::COLOR_BUFFER, rttResultIm );

Then I get no error/warning but my frame rate drops to 250 fps.

So can somebody explain to me what's happening ? I just don't get what is
the difference between the 2 methods and why the first one gives me an error
like this, but still work. By the way I'm working on Windows XP and an
NVidia GTX 260.

Thank you in advance

Alexandre
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to