[osg-users] RTT CompositeViewer

Robert Osfield robert.osfield at gmail.com
Thu Sep 6 10:03:01 PDT 2007


Hi John,

RTT Camera's are set up so they all manage their own
texture/FBO/Pbuffer they are rendering into.

Having multiple RTT Cameras all share the same texture that they are
rendering to is rather off the designed usages for RTT Camera,
although the osgdistortion examples code path for doing 6 cameras
rendering to a single cube map perhaps might provide encouragement
that it might be possible.

CompositeViewer itself probably doesn't make much of directly roll in
all of this, its just really the harness for setting up and managing
the cameras, it defers the actual rendering implementation onto
Camera's and their Renderers (in 2.1.x).

BTW, I have to recommend upgrading to 2.1.x or SVN as their have been
a number of refinements to osgViewer and the OSG in general since 2.0.

Robert.


On 9/6/07, John Donovan <john.donovan at embryonicstudios.com> wrote:
> Hi all,
> I'm using OSG 2.0.0 and I have a osgViewer::CompositeViewer which is made up
> of several cameras looking at the scene from different points of view, and all
> rendering into a regular GraphicsContext.
> How can I set up my scene to render this composite view into a single texture?
> I have some code that I've culled from various samples but it just gives me a
> grey texture.
>
> Image* im = new Image();
> im->allocateImage(totalWidth, vpHeight, 1, GL_RGB, GL_BYTE);
>
> Texture2D* rtt = new Texture2D(im);
> rtt->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::NEAREST);
> rtt->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::NEAREST);
> rtt->setResizeNonPowerOfTwoHint(false);
>
> // Rinse and repeat for each camera.
> Camera* rttcamera = viewer.getView(0)->getCamera();
> rttcamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
> rttcamera->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
> rttcamera->setRenderOrder(osg::Camera::PRE_RENDER);
> rttcamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
> rttcamera->attach(osg::Camera::COLOR_BUFFER, rtt);
> rttcamera->setViewport(new Viewport(0.0, 0.0, vpWidth, vpHeight));
> rttcamera->setProjectionMatrixAsPerspective(fovy, aspect, 1.0, 1000.0);
> // Set up view matrix, GraphicsContext and whatnot.
>
> // Later on I call this code to save the texture.
> Camera::Attachment& foo = rttcamera->getBufferAttachmentMap().begin()->second;
> Image* im = foo._texture->getImage(0);
> if (im) {
>    im->setFileName("c:\\temp\\test.png");
>    osgDB::writeImageFile(*im, im->getFileName());
> }
>
> Is there a step that I'm missing?
>
> -John Donovan
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list