Hi,

> Some of the problem is, I believe, related to the fact that
> the MPV uses the osgSDL library, not sure!!! (could it be
> possible that osgSDL cannot handle the kind of information
> and processing that osgPPU generates?)
> 
osgPPU does only generate some textures and use shaders in between, hence I am 
not sure if osgSDL could have problems with it. 

> <Setup - Done only once>
> 
> When a viewport is created (which gets rendered by the
> osgSDL library), I add a camera to do the rtt for that view.
> Which gets the textures that will be used in the ppu
> processor
>         rttCamera = setupRttCamera( viewport.get() );   see
> bellow for the setupRttCamera function code
> 
Ok, the code below seems to be ok, as far as I see that.

> When my plugin is loaded (different one than the other
> setup) I use the rttCamera that has been setup and use it to
> arrange my post processor
>         // make a new PPU processor
>         mProcessor = new osgPPU::Processor();
>         viewport->getSceneGraph()->addChild(
> mProcessor.get() );
>         // bind it wirth the current viewport RTT camera
>         mProcessor->setCamera(
> viewport->getRttCamera() );
>         mProcessor->setName(
> viewport->getRttCamera()->getName() );
>         mProcessor->dirtyUnitSubgraph();
> 
>         // if I add anything to the processor it causes the
> crash, I tried what I thought would be the most basic post
> processing with just a text... but that did not work
> 
> fpstext = new osgPPU::UnitText();
> fpstext->setName("FPSTextPPU");
> fpstext->setSize(44);
> fpstext->setText("test test test");
> fpstext->setPosition(0.01, 0.95);
> mProcessor->addChild(fpstext);
> // if the text part is commented out (an empty processor
> added to the graph) everything works ok...
>
Here you are missing some output to the screen. UnitText do only render text 
over the input texture. In this case, the input texture would be your camera 
texture (coming from processor). You will need an UnitOut at the end, so that 
you are able to see anything at the screen. You can try also with 
UnitOutCapture to capture your frames to a file and just to see if something is 
there.


Could you start your app with strong notification level, so that one could 
maybe see, why does this crashes. export OSG_NOTIFY_LEVEL=info.
It could also be, that there are some threading issues, since as Robert said, 
osgSDL isn't that kind good tool for working with threading. Try to enable 
singlethreading if it is possible there. Post the log output, maybe we could 
see something out of there.

Best regards,
Art

 
> <Done every frame of when some changes occured>
> 
> When the viewport is updated, I pass the new Matrix along
> to the rttCamera
>         rttCamera->setViewMatrix( viewMatrix );
> 
> after that the update has been done the osgSDL::viewer is
> update by this call and that is when the app crashes (only
> when something is added to the processor)...
>         viewer->runOnce();
> 
> I don't know if this info would be needed to help but
> here it is:
>     viewer is of osgSDL::Viewer
>     viewport is of osgSDL::Viewport
>     camera is osg::Camera
> 
> Also if I do a dump of my scene graph it looks something
> like this
> 
> RttRootNode (not really used other than to keep things
> organized)
>         ViewportNode (used to set the different wiew on the
> "world")
>                 RootNode (world containing much other
> things like entities, terrain, sky ... etc)
>                 RttCamera (used to get the base textures to
> use in the post processing pipeline)
>         there could be more viewportNodes (one per defined
> viewport) with the same structure as above pointing to the
> same RootNode but with a different RttCamera
> 
> 
> 
> ////////////////////////////////////////////////////////////////////////////////
> //! Create a Camera to do Render To Texture
> //! Taken from osgPPU example
> osg::Camera*
> ViewportWrapper::setupRttCamera(osgSDL::Viewport* vp)
> {
>     int width = vp->getWidth();
>     int height = vp->getHeight();
>     // setup viewer's default camera
>     osg::Camera* camera = new osg::Camera();
> 
>     // create texture to render to
>     osg::Texture* texture = createRenderTexture(width,
> height, false);
>     osg::Texture* depthTexture = createRenderTexture(width,
> height, true);
> 
>     // set up the background color and clear mask.
>    
> camera->setClearColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f));
>     camera->setClearMask(GL_COLOR_BUFFER_BIT |
> GL_DEPTH_BUFFER_BIT);
> 
>     // set viewport
>     //camera->setViewport(vp);
>    
> //camera->setView(vp->getSceneView()->getView());
>    
> camera->setViewMatrix(vp->getSceneView()->getViewMatrix());
>     // set camera lens to be the same as the
> viewport[viewID]
>     //camera->setViewMatrix(camMtrx);
>    
> camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
>     camera->setProjectionMatrixAsPerspective(20.0,
> width/height, 0.1, 100.0);
>     //camera.get()->setProjectionMatrixAsOrtho2D(0,
> width, height, 0);
> 
>     // tell the camera to use OpenGL frame buffer object
> where supported.
>    
> camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
> 
>     // attach the texture and use it as the color buffer.
>     camera->attach(osg::Camera::COLOR_BUFFER, texture);
>     camera->attach(osg::Camera::DEPTH_BUFFER,
> depthTexture);
>     
>     return camera;
> }
> 
> 
>  Thank you all for your help and your patience
> 
> Patrick Castonguay
> H: 613 435 2235
> C: 613 325 1341
>  
> Technology Innovation Management (TIM) Student - Modeling
> and Simulation stream
> 
> Carleton University, Ottawa,
> ON_______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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

Reply via email to