thank you filip! this might just be what i was looking for :)

but i'm getting OpenGL errors here ...

Code:

Warning: detected OpenGL error 'invalid operation' at end of SceneView::draw()
Warning: detected OpenGL error 'invalid operation' at start of State::apply()



the letter one keeps piling up as the app runs.

i wrote this code into the main function just before calling the optimizer and 
viewer.run();

Code:

        osg::ref_ptr<osg::Group> rootNode = new osg::Group;
        {
                osg::Stencil* stencil = new osg::Stencil;
                stencil->setFunction(osg::Stencil::ALWAYS, 1, ~0u);
                stencil->setOperation(osg::Stencil::ZERO, osg::Stencil::ZERO, 
osg::Stencil::REPLACE);

                osg::StateSet* ssb1 = new osg::StateSet();
                ssb1->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
                ssb1->setAttributeAndModes(stencil, osg::StateAttribute::ON);

                rootNode->setStateSet(ssb1);
        }
        rootNode->addChild(loadedModel.get());

        viewer.getCamera()->setPostDrawCallback(new PostDrawCallback());



and then the callback

Code:


class PostDrawCallback : public osg::Camera::DrawCallback {

        virtual void operator () (osg::RenderInfo& renderInfo) const {
                osg::ref_ptr<osg::Image> img = new osg::Image;

                osg::View *view = renderInfo.getView();
                int width = view->getCamera()->getViewport()->width();
                int height = view->getCamera()->getViewport()->height();

                img->readPixels(0, 0, width, height, GL_STENCIL_INDEX, 
GL_UNSIGNED_BYTE);
        }
};



if i comment out the readpixels method, the errors do not apear.
what am i missing  [Question] 

 [Arrow]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=44186#44186





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

Reply via email to