> >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::Texture2D::LINEAR);
offscreenTexture->setFilter(osg::TextureRectangle::MAG_FILTER,osg::Texture2D::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.


>
> >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.


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

Reply via email to