Hi osgUsers,

I've been trying to read some values from the DepthBuffer and I don't seem
to get what I would expect. Here is a cut down version of my code (should be
able to run):

class CTestDrawCallback : public osg::Camera::DrawCallback
{
public:
void operator()( const osg::Camera& cam ) const
{
osg::Image* pTest = new osg::Image;
pTest->readPixels( 256,256,1,1, GL_DEPTH_COMPONENT, GL_FLOAT );
float f = (*(float*)pTest->data());

osg::notify(osg::ALWAYS) <<
"f = " << f <<
std::endl;
}
};

osg::Node* CreateScene()
{
osg::Group* pGroup = new osg::Group;

osg::Geode* pGeode = new osg::Geode();
    pGeode->addDrawable( new osg::ShapeDrawable( new
osg::Box(osg::Vec3(0.0f,0.0f,0.0f),2.0f) ) );
pGroup->addChild( pGeode );

return pGroup;
}

int _tmain(int argc, _TCHAR* argv[])
{
osg::ref_ptr<osgViewer::Viewer> rViewer;

    // construct the viewer
    rViewer = new osgViewer::Viewer;

    // make the viewer create a 512x512 window and position it at 32, 32
    rViewer->setUpViewInWindow( 32, 32, 512, 512 );

    // set the scene-graph data the viewer will render
    rViewer->setSceneData( CreateScene() );

rViewer->getCamera()->setPostDrawCallback( new CTestDrawCallback );

    // execute main loop
    return rViewer->run();
}


I get a value of 0.0642448 and this is not what I expect.
I would expect that the near and far plane are automatically computed to fit
the box, which should mean the near plane is collinear with front of the
box.. which should result with a value of 0

can someone explain to me what I'm doing wrong?

regards,
Peter Wraae Marino

-- 
Bellinge Gymnasterne: http://www.bellingegymnasterne.dk
Power Tumbling: http://www.powertumbling.dk
OSG-Help: http://osghelp.com
Personal Site: http://www.marino.dk
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to