Hi all

I have a composite viewer, where the main camera renders to texture. No I added 
a slave camera (POST_RENDER that uses the same graphics context as the main 
camera). I had a screen quad child on which I would like to render the texture 
from the main camera. But all I get is a black screen.

Regards
Daniel

[code]
    osg::Camera* camera = new osg::Camera;

    // set the projection matrix
    camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1920,0,1200));

    // set the view matrix
    camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    camera->setViewMatrix(osg::Matrix::identity());

    // only clear the depth buffer
    camera->setClearMask(0);

    // draw subgraph after main camera view.
    camera->setRenderOrder(osg::Camera::POST_RENDER);

    //GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
    camera->setDrawBuffer(GL_BACK);
    camera->setReadBuffer(GL_BACK);


    // we don't want the camera to grab event focus from the viewers main 
camera(s).
    camera->setAllowEventFocus(false);


    camera->setGraphicsContext(a_viewer->getCamera()->getGraphicsContext());
    camera->setViewport(a_viewer->getCamera()->getViewport());

    camera->addChild( createScreenQuad(1.0f, 1.0f) );

    osg::Camera::BufferAttachmentMap& map = 
a_viewer->getCamera()->getBufferAttachmentMap();
    osg::Texture* input = map[osg::Camera::COLOR_BUFFER0]._texture.get();
    camera->getOrCreateStateSet()->setTextureAttributeAndModes(0, input);

    a_viewer->addSlave(camera, false);
[/code]

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to