2010/1/11 forest <fores...@163.com>: > hi all, > I want to capture the screen ,what I have done is to add a eventhandler in > which I add code like this > > osg::ref_ptr<osg::Image> image = new osg::Image; > image->readPixels(0,0,m_iWidth,m_iHeight, GL_RGB,GL_UNSIGNED_BYTE); > osgDB::writeImageFile(*image,"D:\\abc.bmp"); > > what I get is blank image. > I googled that maybe I should do this in DrawCallBack. I eagerly want to > know why my code doesn't work. Is pixel in FBO erased before EventTraverse ? > > Thanks for any hint > best regards > forest
If I recall correctly, the reason is OpenGL state. readPixels will call glReadPixels, which must be called when the context is selected (i.e. current) and must not be called in between glBegin and glEnd. As OpenGL is a state machine, some calls can't be made at certain states. I remember Paul's osgWorks should contain a set of helpers, facilitating numerous operations, including taking screenshot. Otherwise, there are too many posts in osg-users group concerning your question. Ismail _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org