Folks,

I'm having trouble figuring out how to render floating point values to a
texture and then reading them back from the card for use in my app. I can
get byte values to work fine.

Any help would be appreciated.

Thanks,

Brian

Here's a summary of what I'm doing:

texture setup

    osg::TextureRectangle* texture = new osg::TextureRectangle;
    texture->setTextureSize(tex_width, tex_height);
    texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
    texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
    texture->setInternalFormat(GL_RGBA16F_ARB);
    texture->setSourceFormat(GL_RGBA);
    texture->setSourceType(GL_FLOAT);;

rtt camera setup

    camera->attach(osg::Camera::COLOR_BUFFER, texture);
    camera->setRenderOrder(osg::Camera::PRE_RENDER);
    camera->setRenderTargetImplementation(osg::Camera::PIXEL_BUFFER);
//camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

camera callback setup

    osg::Image* image = new osg::Image;
    image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);
    camera->setPostDrawCallback(new MyCameraPostDrawCallback(image));;

camera callback

    const osg::Viewport * vp = camera.getViewport();
    _image->readPixels((int)vp->x(), (int)vp->y(), (int)vp->width(),;;
                        (int)vp->height(), GL_RGBA, GL_FLOAT);
    osgDB::writeImageFile(*_image,"imagexxx.png");

    or write raw data and read from another app;

    std::ofstream fout("imagexxx.raw",std::ios::binary);
    fout.write((char *)_image->data(),_image->getImageSizeInBytes());
    fout.close();

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

Reply via email to