Hi Eric, You OpenGL code looks wrong, you shouldn't unbind the FBO then do glReadPixels as this will mean that you are reading from the main frame buffer not the FBO.
If you look at the RenderStage.cpp RenderStage::drawInner you'll see the where is unbinds the FBO: if (fbo_supported) { // switch of the frame buffer object fbo_ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); doCopyTexture = true; } So the only thing left to clear up was the double call, which lines of OSG code are you thinking of? Robert. On 2/8/07, E. Wing <[EMAIL PROTECTED]> wrote:
I am getting a strange rendering problem using Framebuffer Objects and Renderbuffers. I am trying to render to an offscreen image (osg::Image). I then utilize that image for a Cocoa drag-and-drop effect. It seems that in some situations, parts of my onscreen views get erased partially or completely. I tried reproducing the problem in raw OpenGL/Cocoa. I thought I had reproduced it, but it turns out that I missed two gl framebuffer commands which I was corrected by the Mac-OpenGL list and I am now unable to reproduce the problem. So my problem seems to be OSG related. I still can't tell if it is a driver bug or OSG miscalling OpenGL bug so I'm trying to understand the OSG framebuffer code. I've posted before about using osg::Camera and FBOs. With a SceneView or SimpleViewer, I was told that render to offscreen buffer wouldn't work with the root camera, so I should temporarily insert a second camera node between the root camera and the scene root. This seemed to solve my problem, but I've recently discovered the disappearing problem. So I've been stepping through FrameBufferObject.cpp. Can somebody explain why I'm seeing the sequence I see? In raw OpenGL, I expect this short sequence of commands: glGenFramebuffersEXT(1, & fboID); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame_buffer); glGenRenderbuffersEXT(1, &objectID); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, objectID); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, objectID); // Draw OpenGL scene here glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // make window the target glReadPixels(...); But with OSG I'm seeing some extra stuff: // simpleViewer->frame() called here which starts sequence glGenFramebuffersEXT(1, & fboID); // fboID=1 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID); // fboID=1 glGenRenderbuffersEXT(1, &objectID); // objectID=1 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, objectID); // objectID=1 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, objectID); // objectID=1 glGenRenderbuffersEXT(1, &objectID); // objectID=2, (why do we have another renderbuffer?) glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, objectID); // objectID=2 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, objectID); // objectID=2 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID); // fboID=1 (why not 0?) // frame() returns around here So why am I seeing a second renderbuffer (and maybe why am I not seeing a second framebuffer)? And why does glBindFramebufferEXT get called again? Could this strange sequence of commands be causing the rendering problems I'm seeing? (I'm not getting any errors from glGetError() by the way.) Thanks, Eric _______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/