Hi Art and Robert,

First of all I dont use my own viewer class, I use osgViewer. I initialize
the viewer camera like this to support osgPPU :

    // Set single thread model
    viewer_.setThreadingModel(osgViewer::Viewer::SingleThreaded);

    // Set the main window position and size
    osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
    traits->x                = windowProperties_.winXPos_;
    traits->y                = windowProperties_.winYPos_;
    traits->width            = windowProperties_.winWidth_;
    traits->height           = windowProperties_.winHeight_;
    traits->windowDecoration = false;
    traits->doubleBuffer     = true;
    traits->sharedContext    = 0;

    // Set the graphics context for the camera
    osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(traits.get());
    gc->setClearColor( osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f) );
    gc->setClearMask( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    gc->clear( );
    viewer_.getCamera()->setGraphicsContext(gc.get());

    // Set the viewport
    viewer_.getCamera()->setViewport( viewportProperties_.viewportXPos_,
                                      viewportProperties_.viewportYPos_,
                                      viewportProperties_.viewportWidth_,
                                      viewportProperties_.viewportHeight_ );


    // Set the projection matrix as perspective
    double aspectRatio;
    if(
viewportProperties_.viewportWidth_/viewportProperties_.viewportHeight_ >=
1.0 )
        aspectRatio =
viewportProperties_.viewportWidth_/viewportProperties_.viewportHeight_;
    else
        aspectRatio =
viewportProperties_.viewportHeight_/viewportProperties_.viewportWidth_;

    viewer_.getCamera()->setProjectionMatrixAsPerspective(
cameraProperties_.cameraFovy_,
                                                           aspectRatio,

cameraProperties_.cameraZNear_, cameraProperties_.cameraZFar_ );

    // Positioning the camera
    osg::Matrix camTrans;
    camTrans.makeTranslate( cameraProperties_.cameraPos_.x(),
cameraProperties_.cameraPos_.y(), -cameraProperties_.cameraPos_.z() );
    viewer_.getCamera()->setViewMatrix( camTrans );

    // tell the camera to use OpenGL frame buffer object where supported.

viewer_.getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

    // create texture to render to
    osg::Texture* texture = createRenderTexture(
viewportProperties_.viewportWidth_, viewportProperties_.viewportHeight_,
false );
    osg::Texture* depthTexture = createRenderTexture(
viewportProperties_.viewportWidth_, viewportProperties_.viewportHeight_,
true);

    // attach the texture and use it as the color and depth buffer.
    viewer_.getCamera()->attach(osg::Camera::COLOR_BUFFER, texture);
    viewer_.getCamera()->attach(osg::Camera::DEPTH_BUFFER, depthTexture);

Ok then I build my particle scene using osgParticle. I use a ModularEmitter
for the placer, shooter and counter.

Finally I set the osgPPU::Processor and attach all the unit I need for the
shader rendering. Then I set the viewer scene data and start the main loop
which look like this :

    osg::Group * rootGroupNode = new osg::Group();
    rootGroupNode->addChild( myParticleScene );
    rootGroupNode->addChild( myOsgPpuProcessor );
    viewer_.setSceneData( rootGroupNode_.get() );

    while (!viewer_.done())
    {
        if( checkForNewMedias() )
            updateSceneWithMedia();

        updateScene();

        // Draw the next frame.
        rendering_ = true;
        viewer_.frame();
        rendering_ = false;

        Sleep(1);
    }

And the application crash with the error message I provide you. If I comment
these lines in my viewer application :

    // Set single thread model
    //viewer_.setThreadingModel(osgViewer::Viewer::SingleThreaded);

    // tell the camera to use OpenGL frame buffer object where supported.

//viewer_.getCamera()->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

    // create texture to render to
    //osg::Texture* texture = createRenderTexture(
viewportProperties_.viewportWidth_, viewportProperties_.viewportHeight_,
false );
    //osg::Texture* depthTexture = createRenderTexture(
viewportProperties_.viewportWidth_, viewportProperties_.viewportHeight_,
true);

    // attach the texture and use it as the color and depth buffer.
    //viewer_.getCamera()->attach(osg::Camera::COLOR_BUFFER, texture);
    //viewer_.getCamera()->attach(osg::Camera::DEPTH_BUFFER, depthTexture);

And don't attach the osgPPU::Processor to my rootGroupNode, everything works
well.

Hope I gave you enough informations, if you need more I'll provide you.

Thanks

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

Reply via email to