Hello Eik,

Eik Deistung wrote:
> Hallo
> 
> I want to grap a part of a scene.
> 
> At the moment:
> 
>         x = ComplicateCalculationFor Y ...
>         y = ComplicateCalculationFor Y ...
>         glReadPixels(x, y, width, hight ,  GL_LUMINANCE, 
> GL_UNSIGNED_BYTE,                 memory);
> 
> 
> now I want do the this with Offscreen Rendering in an FBO and used 
> sample 29 as base.
> I want grab the rendert Texture from the FBO.
> 
> In pure OGL it is easy
> 
>         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
>         glReadPixels();
>         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
> 
> this works fine
> 
> but in OSG this seems not to work
> 
>     WindowPtr win = mgr->getWindow();
>     ::fboVP->bind(win.getCPtr());
>      glReadPixels(0, 0, windowWidth-1, windowHeight-1, GL_LUMINANCE, 
> GL_UNSIGNED_BYTE, &pixels);
>     ::fboVP->stop(win.getCPtr());
> 
> this produces:  WARNING:  FBO initalize pre OpenGL Error: invalid operation!
> And the read Pixels are empty.
> 
> How can I Read the Pixels out of the FBO?

the FBOViewport already has the capability to read the texture back to 
main memory, you can enable it with setReadBuffer(true).
The pixel values are then available through the Image used in the 
texture you attached to the FBOViewport. From that you can extract the 
portion you need with Image::subImage.

        Hope it helps,
                Carsten

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to