Jonathan Richard wrote on Tuesday, July 07, 2009 7:28 AM: > >Glad you got it working! > > >Is there a reason you didn't just attach an osg::Texture to your camera > >and set the number of samples greater than 1 in the attach call? > > > Well I did attach a texture to my camera and set the number of samples > greater than 1...see: > > osg::ref_ptr<osg::TextureRectangle> offscreenTexture = new > osg::TextureRectangle; > offscreenTexture->setTextureSize(WIDTH, HEIGHT); > offscreenTexture->setFilter(osg::TextureRectangle::MIN_FILTER,osg::Textu re2D::LINEAR); > offscreenTexture->setFilter(osg::TextureRectangle::MAG_FILTER,osg::Textu re2D::LINEAR); > offscreenTexture->setSourceFormat(GL_RGBA); > offscreenTexture->setSourceType(GL_FLOAT); > offscreenTexture->setInternalFormat(GL_FLOAT_RGBA32_NV); > > osg::Camera* camera=m_viewer->getCamera(); > camera->setClearColor(osg::Vec4f(0,0.0f,0.0f,1.0f)); > camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); > camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); > camera->attach(osg::Camera::COLOR_BUFFER0, > offscreenTexture.get(),0,0,false,8,4); > > > then in my draw call back I just get the resolved fbo that osg fills with the > glBlitFramebufferEXT call. This seems to work, I don't know if there is > better or "cleaner" solution to my problem. By the way I was wondering why > osg do not bind the resolved fbo instead of the multisampled fbo in order to > allow subsequent glReadPixels call. If not I don't understand why the > glBlitFramebufferEXT is automatically performed.
When you attach a texture, OSG will fill the texture with the contents of the FBO automatically; you don't need to do the glReadPixels, just use the texture. > >By the way, if you change OpenGL state, be careful that you restore the > >previous state or tell OpenSceneGraph about the changes you make (via > >haveAppliedMode(), haveAppliedAttribute(), etc.); otherwise > >OpenSceneGraph will get confused about what the current OpenGL state is. > > > > you are refering to the binding call ( > fbo->apply(state,osg::FrameBufferObject::READ_FRAMEBUFFER))? As I said before > I'm not sure if my approach is the best one. I just looked at the osg code > and found a way to get my own working. I saw (with your held) that a resolved > fbo was automatically generated when drawing to a multisampled fbo so I just > get it in my draw callback (getMultisampleResolveFramebufferObject()) then > bind it in order to be able to read it. Yes, binding the fbo (and any other OpenGL state changes you do) should be reported to OSG or restored to their original state before leaving the draw callback. HTH, -- Bryan Thrall FlightSafety International bryan.thr...@flightsafety.com _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org