Thank you so much, the patch worked :)
Quoting Carsten Neumann <[EMAIL PROTECTED]>:
> On Thu, 2007-08-30 at 11:29 +0200, [EMAIL PROTECTED] wrote:
> > Hi Carsten,
> > thanks for the reply! Looking at your code I found that the problem was
> in
> > the line
> >
> > m_pFBO->setFboOn(false);
>
> oops, that line should not have been in there, it is a leftover from
> testing and my attempts to figure out what goes wrong...
>
> > which I hadn't. What this line means?
>
> well, it turns off the usage of FBO's and just emulates the effect by
> rendering to the regular framebuffer and copying data to a texture, so
> it probably is not what you want.
> Anyway, the real fix is not to use the GrabForeground at all (because it
> knows nothing of FBOs it can not call glReadBuffer(GL_COLOR_ATTACHMENTx)
> to select the right attachment to read back). The FBOViewport should
> have the ability to read data back, enabled by m_pFBO->setReadBuffer
> (true), but that feature was unimplemented. The attached patch, which
> will also go into cvs soon, fixes that. Also attached a new version of
> the testing program, note that the GrabForeground is not added to the
> FBOViewport and therefore now grabImage.png will be empty while
> fboImage.png will show the scene.
>
> Hope it helps,
> Carsten
>
> > When I added it the grabforeground started
> > working, but shadow maps now have some serious problems.. :)
> >
> > Thanks for your help,
> > Stefano
> >
> >
> > Quoting Carsten Neumann <[EMAIL PROTECTED]>:
> >
> > > Hi Stefano,
> > >
> > > On Wed, 2007-08-29 at 17:33 +0200, [EMAIL PROTECTED] wrote:
> > > > Hi there!
> > > > I'm trying to save the content of an FBO into an image using the
> > > > GrabForeground class.. here is the code I use:
> > > >
> > > > ImagePtr img = Image::create();
> > > > beginEditCP(img);
> > > > img->setPixelFormat(Image::OSG_RGBA_PF);
> > > > endEditCP(img);
> > > >
> > > > GrabForegroundPtr grabber = GrabForeground::create();
> > > > beginEditCP(grabber);
> > > > grabber->setImage(img);
> > > > grabber->setActive(true);
> > > > grabber->setAutoResize(true);
> > > > endEditCP(grabber);
> > > >
> > > > m_pFBO->setBackground(SolidBackground::create());
> > > > m_pFBO->setCamera(m_pRenderAgent->getCamera());
> > > > m_pFBO->setScene(makeCoredNode<Group>());
> > > ^^^^^^^^^^^^^^^^^^
> > > I don't have that method in my FBOViewport (there is only setRoot, which
> > > probably does the same), but it makes me wonder what version you are
> > > using?
> > >
> > > > m_pFBO->addForeground(grabber);
> > > > m_pFBO->render(m_pRenderAgent->getRenderAction());
> > >
> > > There are two issues here, I believe:
> > > 1) You don't add any textures to the FBOViewport, so it does not have
> > > any color buffers to render into. I have attached a (crude) test program
> > > that basically does what you want, not that it is expected that writing
> > > of fboImage fails, but grabImage will contain the image (without
> > > lighting though, because the only light is the headlight added by the
> > > SimpleSceneManager).
> > >
> > > 2) Since you do not have a window to which the FBOViewport is attached,
> > > you must be careful that there is actually an active OpenGL context for
> > > the call to m_pFBO->render(...). That's why the attached program does
> > > the actual creation of the screenshot in the display function and not in
> > > the keyboard function.
> > >
> > > Hope it helps,
> > > Carsten
> > >
> > > > // save data
> > > > char path[255] = "c:\\temp";
> > > > boost::filesystem::path p(path);
> > > > p /= ("hithere.png");
> > > >
> > > > printf("Saving image %s\n", p.string().c_str());
> > > > if (!img->write(p.native_file_string().c_str())) {
> > > > printf("Error writing screenshot\n");
> > > > } else {
> > > > printf("Done writing screenshot\n");
> > > > }
> > > >
> > > > img->write() returns me success, an image with the right dimensions
> gets
> > > saved,
> > > > but it's full of (0,0,0,0) while I should get a full black image,
> right?
> > > > Is there something wrong? GrabForeground (and glReadPixels) should work
> > > > correctly with FBOs as I'm reading on the web... isn't it?
> > > >
> > > > Thanks a lot,
> > > > Stefano Verna
> > > >
> > > >
> > > >
> > > > ----------------------------------------------------------------
> > > > This message was sent using IMP, the Internet Messaging Program.
> > > >
> > > >
> -------------------------------------------------------------------------
> > > > This SF.net email is sponsored by: Splunk Inc.
> > > > Still grepping through log files to find problems? Stop.
> > > > Now Search log events and configuration files using AJAX and a browser.
> > > > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > > > _______________________________________________
> > > > Opensg-users mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/opensg-users
> > >
> >
> >
> >
> >
> > ----------------------------------------------------------------
> > This message was sent using IMP, the Internet Messaging Program.
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc.
> > Still grepping through log files to find problems? Stop.
> > Now Search log events and configuration files using AJAX and a browser.
> > Download your FREE copy of Splunk now >> http://get.splunk.com/
> > _______________________________________________
> > Opensg-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/opensg-users
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users