Hi,

I'm using PRE_RENDER cameras rendering to FrameBufferObjects with 
SceneView, in some cases multi-pass as well. I've used a similar setup 
as per the osgprerender example and did not find a difference between 
using SceneView versus osgViewer. I'll splat some code into the bottom 
of the email, maybe it helps. It's with svn osg, Linux, NVidia.

cheers
jp

Argentieri, John-P63223 wrote:
> Robert and pals,
> 
> We are using osg 2.0. I am trying to duplicate the behavior of the 
> osgdistortion example, but we are using osgUtil::SceneView and not 
> osgViewer::Viewer.
> 
> I have been unable to mimic the behavior of the example. If I set my 
> texture camera to PRE_RENDER, all I get is a blank quad set to the color 
> of the osg::geometry. If I set it to NESTED_RENDER, which is wrong, I 
> think it draws the texture to the back buffer, because I can see it on 
> the screen.
> 
> Can anyone offer me some advice in this area?
> 
> Thanks for your help….
> 
> *John Argentieri*
> *Software Engineer*
> *GENERAL DYNAMICS*
> *C4 Systems *
> *(407) 281-5568*
> [EMAIL PROTECTED]

SceneView setup
---8<---
     _SceneView = new osgUtil::SceneView();
     _SceneView->setDefaults();
     osg::StateSet *gstate = _SceneView->getGlobalStateSet();
     gstate->setGlobalDefaults();
     gstate->setMode(GL_BLEND, osg::StateAttribute::OFF);
     gstate->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
     gstate->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);

     _RootNode = new osg::Group();
     _SceneView->setSceneData(_RootNode.get());
     _SceneView->setClearColor(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f));
     gstate->setMode( GL_LIGHTING, osg::StateAttribute::OFF);
     _SceneView->setLightingMode(osgUtil::SceneView::NO_SCENEVIEW_LIGHT);
---8<---

Camera setup
---8<---
     // clearing
     _Camera->setClearColor(osg::Vec4(1.0f,0.0f,0.0f,1.0f));
     _Camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

     // projection and view
     _Camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
     _Camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
     _Camera->setViewMatrix(osg::Matrix::identity());

     // viewport
     _Camera->setViewport(0, 0, _TextureWidth, _TextureHeight);

     _Camera->setRenderOrder(osg::Camera::PRE_RENDER);
 
_Camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

     // attach the texture and use it as the color buffer.
     _Camera->attach(osg::Camera::COLOR_BUFFER, _OutTexture.get());
---8<---

Quad setup
---8<---
osg::ref_ptr<osg::Group> top_group = new osg::Group;

     osg::ref_ptr<osg::Geode> quad_geode = new osg::Geode;

     osg::ref_ptr<osg::Vec3Array> quad_coords = new osg::Vec3Array; // 
vertex coords
     // counter-clockwise
     quad_coords->push_back(osg::Vec3d(0, 0, -1));
     quad_coords->push_back(osg::Vec3d(1, 0, -1));
     quad_coords->push_back(osg::Vec3d(1, 1, -1));
     quad_coords->push_back(osg::Vec3d(0, 1, -1));

     osg::ref_ptr<osg::Vec2Array> quad_tcoords = new osg::Vec2Array; // 
texture coords
     quad_tcoords->push_back(osg::Vec2(0, 0));
     quad_tcoords->push_back(osg::Vec2(_TextureWidth, 0));
     quad_tcoords->push_back(osg::Vec2(_TextureWidth, _TextureHeight));
     quad_tcoords->push_back(osg::Vec2(0, _TextureHeight));

     osg::ref_ptr<osg::Geometry> quad_geom = new osg::Geometry;
     osg::ref_ptr<osg::DrawArrays> quad_da = new 
osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4);

     quad_geom->setVertexArray(quad_coords.get());
     quad_geom->setTexCoordArray(0, quad_tcoords.get());
     quad_geom->addPrimitiveSet(quad_da.get());

     _StateSet = quad_geom->getOrCreateStateSet();
     _StateSet->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
     _StateSet->setTextureAttributeAndModes(0, _InTexture.get(), 
osg::StateAttribute::ON);


     quad_geode->addDrawable(quad_geom.get());

     top_group->addChild(quad_geode.get());

     return top_group;
---8<---

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.

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

Reply via email to